Skip to content

Commit

Permalink
fix: add required persistent attribute when using ram class storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Redm4x committed Apr 23, 2024
1 parent df59bb0 commit 8c895ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/sdl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export class SDL {
? {
name: storage.name || "default",
[key]: this.resourceUnit(storage.size, asString),
attributes: this.serviceResourceAttributes(storage.attributes)
attributes: this.serviceResourceStorageAttributes(storage.attributes)
}
: {
name: storage.name || "default",
Expand All @@ -252,6 +252,20 @@ export class SDL {
);
}

serviceResourceStorageAttributes(attributes?: Record<string, any>) {

Check warning on line 255 in src/sdl/index.ts

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type
if (!attributes) return undefined;

const pairs = Object.keys(attributes).map(key => ({ key, value: attributes[key].toString() }));

if (attributes.class === "ram" && !attributes.persistent) {
pairs.push({ key: "persistent", value: "false" });
}

pairs.sort((a, b) => a.key.localeCompare(b.key));

return pairs;
}

serviceResourceGpu(resource: v3ResourceGPU | undefined, asString: boolean) {
const value = resource?.units || 0;
const numVal = isString(value) ? Buffer.from(value, "ascii") : value;
Expand Down Expand Up @@ -625,14 +639,7 @@ export class SDL {
quantity: {
val: this.resourceValue(convertResourceString(storage.size), asString)
},
attributes:
storage.attributes &&
Object.entries(storage.attributes)
.sort(([k0], [k1]) => k0.localeCompare(k1))
.map(([key, value]) => ({
key: key,
value: value.toString()
}))
attributes: this.serviceResourceStorageAttributes(storage.attributes)
}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ exports[`test sdl persistent storage SDL: Persistent Storage Manifest: SDL: Pers
"key": "class",
"value": "ram",
},
{
"key": "persistent",
"value": "false",
},
],
"name": "shm",
"size": {
Expand Down

0 comments on commit 8c895ea

Please sign in to comment.