Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent duplicate persistent attribute when using ram storage #85

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sdl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
export const GPU_SUPPORTED_VENDORS = ["nvidia", "amd"];
export const GPU_SUPPORTED_INTERFACES = ["pcie", "sxm"];

function isArray<T>(obj: any): obj is Array<T> {

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

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type
return Array.isArray(obj);
}

function isString(str: any): str is string {

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

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type
return typeof str === "string";
}

Expand Down Expand Up @@ -244,7 +244,7 @@
);
}

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

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

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type
return (
attributes &&
Object.keys(attributes)
Expand All @@ -258,7 +258,7 @@

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" });
}

Expand Down Expand Up @@ -689,7 +689,7 @@

const units = {
endpoints: null
} as any;

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

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type

if (resource.cpu) {
units.cpu = this.resourceUnitCpu(resource, asString);
Expand Down Expand Up @@ -790,7 +790,7 @@
resource: res,
price: price,
count: svcdepl.count
} as any);

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

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type

group.boundComputes[placementName][svcdepl.profile] = group.dgroup.resources.length - 1;
} else {
Expand All @@ -798,7 +798,7 @@
// resources.id = group.dgroup.resources[location].id;

group.dgroup.resources[location].count += svcdepl.count;
group.dgroup.resources[location].endpoints += endpoints as any;

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

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type
group.dgroup.resources[location].endpoints.sort();
}
}
Expand All @@ -813,7 +813,7 @@
const yamlJson = this.data;
const ipEndpointNames = this.computeEndpointSequenceNumbers(yamlJson);

const groups = {} as any;

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

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type

Object.keys(yamlJson.services).forEach(svcName => {
const svc = yamlJson.services[svcName];
Expand Down Expand Up @@ -851,7 +851,7 @@
};

if (group.requirements.attributes) {
group.requirements.attributes = group.requirements.attributes.sort((a: any, b: any) => a.key < b.key);

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

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type

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

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type
}

groups[group.name] = group;
Expand All @@ -863,7 +863,7 @@
count: svcdepl.count
};

const endpoints = [] as any[];

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

View workflow job for this annotation

GitHub Actions / Code Style / Lint

Unexpected any. Specify a different type
svc?.expose?.forEach(expose => {
expose?.to
?.filter(to => to.global)
Expand Down
16 changes: 16 additions & 0 deletions tests/__snapshots__/sdl_persistent_storage_attributes.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/persistent_storage_valid.sdl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ profiles:
size: 1Gi
attributes:
class: ram
- name: shm2
size: 1Gi
attributes:
class: ram
persistent: false
placement:
akash:
#######################################################
Expand Down
Loading