Skip to content
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
3 changes: 2 additions & 1 deletion packages/grid_client/src/modules/capacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class Capacity {
@expose
@validateInput
async getNodeFreeResources(options?: NodeFreeResourcesModel): Promise<NodeResources> {
return await this.nodes.getNodeFreeResources(options!.nodeId);
return await this.nodes.getNodeFreeResources(options!.nodeId, "proxy", "", options?.nodeTwinId);
}

/**
Expand Down Expand Up @@ -306,6 +306,7 @@ class Capacity {
options.hddDisks,
options.rootfsDisks,
options.nodeId,
options.nodeTwinId,
);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/grid_client/src/modules/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ class ContractState {

class NodeFreeResourcesModel {
@Expose() @IsInt() @Min(1) nodeId: number;
@Expose() @IsOptional() @IsInt() @Min(1) nodeTwinId?: number;
}

class FarmIdFromFarmNameModel {
Expand All @@ -605,6 +606,7 @@ class CapacityPoolCheckModel {
@Expose() @IsInt({ each: true }) @Min(0, { each: true }) rootfsDisks: number[]; //Byte
@Expose() @IsInt({ each: true }) @Min(250 * 1024 ** 2, { each: true }) ssdDisks: number[]; //Byte
@Expose() @IsInt({ each: true }) @Min(250 * 1024 ** 2, { each: true }) hddDisks: number[]; //Byte
@Expose() @IsOptional() @IsInt() @Min(1) nodeTwinId?: number;
}

class PingNodeOptionsModel {
Expand Down
26 changes: 15 additions & 11 deletions packages/grid_client/src/primitives/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,17 @@ class Nodes {
});
}

async getNodeFreeResources(nodeId: number, source: "proxy" | "zos" = "proxy", url = ""): Promise<NodeResources> {
async getNodeFreeResources(
nodeId: number,
source: "proxy" | "zos" = "proxy",
url = "",
nodeTwinId?: number,
): Promise<NodeResources> {
if (source == "zos") {
const node_twin_id = await this.getNodeTwinId(nodeId);
const twinId = nodeTwinId ?? (await this.getNodeTwinId(nodeId));

return this.rmb
.request([node_twin_id], "zos.statistics.get", "")
.request([twinId], "zos.statistics.get", "")
.then(res => {
const node: RMBNodeCapacity = res;
const ret: NodeResources = {
Expand Down Expand Up @@ -513,8 +518,8 @@ class Nodes {
return convertObjectToQueryString(params);
}

async nodeHasResources(nodeId: number, options: FilterOptions): Promise<boolean> {
const resources = await this.getNodeFreeResources(nodeId, "zos");
async nodeHasResources(nodeId: number, options: FilterOptions, nodeTwinId?: number): Promise<boolean> {
const resources = await this.getNodeFreeResources(nodeId, "zos", "", nodeTwinId);
if (
(options.mru && options.mru > 0 && resources.mru < this._g2b(options.mru)) ||
(options.sru && options.sru > 0 && resources.sru < this._g2b(options.sru)) ||
Expand Down Expand Up @@ -603,17 +608,16 @@ class Nodes {
hddDisks: number[],
rootFileSystemDisks: number[],
nodeId: number,
nodeTwinId?: number,
): Promise<boolean> {
const ssdPools: number[] = [];
const hddPools: number[] = [];

try {
const nodeTwinId = await this.getNodeTwinId(nodeId);
((await this.rmb.request([nodeTwinId], "zos.storage.pools", "")) as StoragePool[]).forEach(
(disk: StoragePool) => {
disk.type === DiskTypes.SSD ? ssdPools.push(disk.size - disk.used) : hddPools.push(disk.size - disk.used);
},
);
const twinId = nodeTwinId ?? (await this.getNodeTwinId(nodeId));
((await this.rmb.request([twinId], "zos.storage.pools", "")) as StoragePool[]).forEach((disk: StoragePool) => {
disk.type === DiskTypes.SSD ? ssdPools.push(disk.size - disk.used) : hddPools.push(disk.size - disk.used);
});
} catch (e) {
(e as Error).message = formatErrorMessage(`Error getting node ${nodeId}`, e);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
"
/>

<input-tooltip
tooltip="Node ID to deploy on."
align-center
>
<input-tooltip tooltip="Node ID to deploy on." align-center>
<VTextField
v-model.number="nodeId"
label="Node ID"
Expand All @@ -40,9 +37,9 @@
:disabled="!validFilters"
:persistent-hint="
(nodeId && !validationTask.initialized) ||
!validFilters ||
validationTask.loading ||
(validationTask.initialized && validationTask.data === true)
!validFilters ||
validationTask.loading ||
(validationTask.initialized && validationTask.data === true)
"
:hint="
!validFilters
Expand Down Expand Up @@ -199,7 +196,7 @@ export default {
} Feature${missingFeatures.length > 1 ? "s" : ""}. Please check compatibility or upgrade the node.`;
}

const args = [nodeId, "proxy", gridStore.client.config.proxyURL] as const;
const args = [nodeId, "proxy", gridStore.client.config.proxyURL, node.twinId] as const;
const [resources, e2] = await resolveAsync(gridStore.client.capacity.nodes.getNodeFreeResources(...args));
if (e2) {
throw normalizeError(e2, _defaultError);
Expand Down
1 change: 1 addition & 0 deletions packages/playground/src/utils/nodeSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ export async function checkNodeCapacityPool(
ssdDisks: [filters.solutionDisk ?? 0, ...(filters.ssdDisks || [])].filter(Boolean).map(disk => disk * 1024 ** 3),
rootfsDisks: [(filters.rootFilesystemSize ?? 0) * 1024 ** 3],
hddDisks: filters.hddDisks || [],
nodeTwinId: node.twinId,
});
return true;
} catch (error) {
Expand Down