From 6a821efde40540fb33e9ec54073c82012d14f168 Mon Sep 17 00:00:00 2001 From: Redm4x <2829180+Redm4x@users.noreply.github.com> Date: Fri, 3 May 2024 11:13:29 -0400 Subject: [PATCH] fix: prevent duplicate persistent attribute when using ram storage --- src/sdl/index.ts | 2 +- ...dl_persistent_storage_attributes.spec.ts.snap | 16 ++++++++++++++++ tests/fixtures/persistent_storage_valid.sdl.yml | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/sdl/index.ts b/src/sdl/index.ts index 836c8e6..fafed34 100644 --- a/src/sdl/index.ts +++ b/src/sdl/index.ts @@ -258,7 +258,7 @@ export class SDL { const pairs = Object.keys(attributes).map(key => ({ key, value: attributes[key].toString() })); - if (attributes.class === "ram" && !attributes.persistent) { + if (attributes.class === "ram" && !("persistent" in attributes)) { pairs.push({ key: "persistent", value: "false" }); } diff --git a/tests/__snapshots__/sdl_persistent_storage_attributes.spec.ts.snap b/tests/__snapshots__/sdl_persistent_storage_attributes.spec.ts.snap index c055655..eef08d4 100644 --- a/tests/__snapshots__/sdl_persistent_storage_attributes.spec.ts.snap +++ b/tests/__snapshots__/sdl_persistent_storage_attributes.spec.ts.snap @@ -194,6 +194,22 @@ exports[`test sdl persistent storage SDL: Persistent Storage Manifest: SDL: Pers "val": 1073741824, }, }, + { + "attributes": [ + { + "key": "class", + "value": "ram", + }, + { + "key": "persistent", + "value": "false", + }, + ], + "name": "shm2", + "size": { + "val": 1073741824, + }, + }, ], }, "params": { diff --git a/tests/fixtures/persistent_storage_valid.sdl.yml b/tests/fixtures/persistent_storage_valid.sdl.yml index 0462bd1..7ed5dfb 100644 --- a/tests/fixtures/persistent_storage_valid.sdl.yml +++ b/tests/fixtures/persistent_storage_valid.sdl.yml @@ -79,6 +79,11 @@ profiles: size: 1Gi attributes: class: ram + - name: shm2 + size: 1Gi + attributes: + class: ram + persistent: false placement: akash: #######################################################