From b66beec6aababe8c80e0e2c8a6cb461dee43125a Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Wed, 31 Jul 2024 11:37:32 +0300 Subject: [PATCH 01/42] Fix zmachine test --- .../tests/modules/zmachine.test.ts | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/grid_client/tests/modules/zmachine.test.ts b/packages/grid_client/tests/modules/zmachine.test.ts index 1090f8d2c8..f7bd56db75 100644 --- a/packages/grid_client/tests/modules/zmachine.test.ts +++ b/packages/grid_client/tests/modules/zmachine.test.ts @@ -1,13 +1,14 @@ import { ComputeCapacity, Mount, Zmachine, ZmachineNetwork } from "../../src"; const zmachine = new Zmachine(); +const computeCapacity = new ComputeCapacity(); +const network = new ZmachineNetwork(); +const disks = new Mount(); beforeAll(() => { - const computeCapacity = new ComputeCapacity(); computeCapacity.cpu = 1; - computeCapacity.memory = 5; + computeCapacity.memory = 256 * 1024 ** 2; - const network = new ZmachineNetwork(); network.planetary = true; network.public_ip = "10.249.0.0/16"; network.interfaces = [ @@ -19,7 +20,6 @@ beforeAll(() => { const rootfs_size = 2; - const disks = new Mount(); disks.name = "zdisk"; disks.mountpoint = "/mnt/data"; @@ -41,15 +41,12 @@ describe("Zmachine Class Tests", () => { it("should correctly compute the challenge string", () => { const expectedChallenge = - "https://hub.grid.tf/tf-official-vms/ubuntu-22.04.flist" + - "10.249.0.0/16" + - "true" + - "znetwork" + - "10.20.2.22" + - "14748364815" + - "zdisk" + - "/mnt/data" + - "/sbin/zinit init"; + zmachine.flist + + network.challenge() + + zmachine.size + + computeCapacity.challenge() + + zmachine.mounts[0].challenge() + + zmachine.entrypoint; expect(zmachine.challenge()).toBe(expectedChallenge); }); From f2c4bffedc94d934b71a989aedfab6348d6a8bb5 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Wed, 31 Jul 2024 11:39:32 +0300 Subject: [PATCH 02/42] validate zmachine, remove unused code --- packages/grid_client/src/zos/zmachine.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/grid_client/src/zos/zmachine.ts b/packages/grid_client/src/zos/zmachine.ts index eb6c958347..e97d4ce729 100644 --- a/packages/grid_client/src/zos/zmachine.ts +++ b/packages/grid_client/src/zos/zmachine.ts @@ -2,17 +2,16 @@ import { Expose, Transform, Type } from "class-transformer"; import { IsBoolean, IsDefined, - isDefined, IsInt, IsIP, IsNotEmpty, IsOptional, IsString, Max, - Min, ValidateNested, } from "class-validator"; +import { ValidateMembers } from "../helpers/validator"; import { ComputeCapacity } from "./computecapacity"; import { WorkloadData, WorkloadDataResult } from "./workload_base"; @@ -58,6 +57,7 @@ class Mount { } } +@ValidateMembers() class Zmachine extends WorkloadData { @Expose() @IsString() @IsNotEmpty() flist: string; @Expose() @Type(() => ZmachineNetwork) @ValidateNested() network: ZmachineNetwork; From 73d46032c63458597a99b5924591cd94525cf70f Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Wed, 31 Jul 2024 18:09:45 +0300 Subject: [PATCH 03/42] Add a test case to test invalid parsed object --- .../tests/modules/zmachine.test.ts | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/grid_client/tests/modules/zmachine.test.ts b/packages/grid_client/tests/modules/zmachine.test.ts index f7bd56db75..9a8daff13f 100644 --- a/packages/grid_client/tests/modules/zmachine.test.ts +++ b/packages/grid_client/tests/modules/zmachine.test.ts @@ -1,6 +1,8 @@ +import { plainToClass } from "class-transformer"; + import { ComputeCapacity, Mount, Zmachine, ZmachineNetwork } from "../../src"; -const zmachine = new Zmachine(); +let zmachine = new Zmachine(); const computeCapacity = new ComputeCapacity(); const network = new ZmachineNetwork(); const disks = new Mount(); @@ -51,11 +53,32 @@ describe("Zmachine Class Tests", () => { expect(zmachine.challenge()).toBe(expectedChallenge); }); - it("should fail validation for missing required fields", () => { + it("should fail validation for entering invalid data", () => { const result = () => { zmachine.flist = ""; zmachine.entrypoint = ""; + zmachine.network.public_ip = ""; + }; + expect(result).toThrow(); + }); + + it("should fail if zmachine is parsed to an invalid object", () => { + const invalidZmachine = `{ + "flist": "", + "network": "invalid_network_object", + "size": "not_a_number", + "compute_capacity": {}, + "mounts": "not_an_array", + "entrypoint": 123, + "env": "not_an_object", + "corex": "not_a_boolean", + "gpu": [123, "valid_string", false] + }`; + + const result = () => { + zmachine = plainToClass(Zmachine, JSON.parse(invalidZmachine)); }; + expect(result).toThrow(); }); }); From d22f49609c737b0f98f27f5fe9d736fed52b9463 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Sun, 11 Aug 2024 14:43:12 +0300 Subject: [PATCH 04/42] Add types, remove unnessecary code, ping node before deploying on it --- .../orchestrators/kubernetes_with_qsfs.ts | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts b/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts index 65080b3eec..b85fde8a90 100644 --- a/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts +++ b/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts @@ -1,37 +1,37 @@ -import { FilterOptions, K8SModel, QSFSZDBSModel } from "../../src"; +import { FilterOptions, GridClient, K8SModel, QSFSZDBSModel } from "../../src"; import { config, getClient } from "../client_loader"; -import { log } from "../utils"; +import { log, pingNodes } from "../utils"; -async function deployQsfs(client, qsfs) { +async function deployQsfs(client: GridClient, qsfs: QSFSZDBSModel) { const res = await client.qsfs_zdbs.deploy(qsfs); log("================= Deploying QSFS ================="); log(res); log("================= Deploying QSFS ================="); } -async function deploy(client, k8s) { +async function deploy(client: GridClient, k8s: K8SModel) { const res = await client.k8s.deploy(k8s); log("================= Deploying K8s ================="); log(res); log("================= Deploying K8s ================="); } -async function getDeployment(client, k8s) { +async function getDeployment(client: GridClient, k8s: string) { const res = await client.k8s.getObj(k8s); log("================= Getting deployment information ================="); log(res); log("================= Getting deployment information ================="); } -async function cancel(client, k8s) { - const res = await client.k8s.delete(k8s); +async function cancel(client: GridClient, k8s: string) { + const res = await client.k8s.delete({ name: k8s }); log("================= Canceling the deployment ================="); log(res); log("================= Canceling the deployment ================="); } -async function deleteQsfs(client, qsfs) { - const res = await client.qsfs_zdbs.delete(qsfs); +async function deleteQsfs(client: GridClient, qsfs: string) { + const res = await client.qsfs_zdbs.delete({ name: qsfs }); log("================= Deleting QSFS ================="); log(res); log("================= Deleting QSFS ================="); @@ -43,7 +43,7 @@ async function main() { const qsfs_name = "testQsfsK8sq1"; - const masterQueryOptions: FilterOptions = { + const options: FilterOptions = { cru: 2, mru: 2, // GB sru: 6, @@ -51,14 +51,6 @@ async function main() { farmId: 1, }; - const workerQueryOptions: FilterOptions = { - cru: 1, - mru: 1, // GB - sru: 3, - availableFor: grid3.twinId, - farmId: 1, - }; - const qsfsQueryOptions: FilterOptions = { hru: 15, availableFor: grid3.twinId, @@ -68,12 +60,19 @@ async function main() { const qsfsNodes: number[] = []; const allNodes = await grid3.capacity.filterNodes(qsfsQueryOptions); + if (allNodes.length >= 2) { qsfsNodes.push(+allNodes[0].nodeId, +allNodes[1].nodeId); } else { throw Error("Couldn't find nodes for qsfs"); } + async function getNodeId(client: GridClient, options: FilterOptions) { + const nodes = await client.capacity.filterNodes(options); + const nodeId = await pingNodes(client, nodes); + return nodeId; + } + //create qsfs object const qsfs: QSFSZDBSModel = { name: qsfs_name, @@ -95,7 +94,7 @@ async function main() { masters: [ { name: "master", - node_id: +(await grid3.capacity.filterNodes(masterQueryOptions))[0].nodeId, + node_id: await getNodeId(grid3, options), cpu: 1, memory: 1024, rootfs_size: 0, @@ -121,7 +120,7 @@ async function main() { workers: [ { name: "worker", - node_id: +(await grid3.capacity.filterNodes(workerQueryOptions))[0].nodeId, + node_id: await getNodeId(grid3, options), cpu: 1, memory: 1024, rootfs_size: 0, @@ -147,8 +146,8 @@ async function main() { await getDeployment(grid3, name); // //Uncomment the line below to cancel the deployment - // await cancel(grid3, { name: k.name }); - // await deleteQsfs(grid3, { name: qsfs_name }); + await cancel(grid3, k.name); + await deleteQsfs(grid3, qsfs_name); await grid3.disconnect(); } From 4e26f157d56c93ba936f31cbf02c0a591d5156be Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Sun, 11 Aug 2024 18:00:05 +0300 Subject: [PATCH 05/42] Loops over filtered nodes and push in qsfsNodes until required resources reached --- .../orchestrators/kubernetes_with_qsfs.ts | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts b/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts index b85fde8a90..4b3307607e 100644 --- a/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts +++ b/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts @@ -42,6 +42,8 @@ async function main() { const grid3 = await getClient(`kubernetes/${name}`); const qsfs_name = "testQsfsK8sq1"; + const disk_size = 1; + const count = 8; const options: FilterOptions = { cru: 2, @@ -58,13 +60,23 @@ async function main() { }; const qsfsNodes: number[] = []; + let usedResources = 0; - const allNodes = await grid3.capacity.filterNodes(qsfsQueryOptions); + const nodes = await grid3.capacity.filterNodes(qsfsQueryOptions); - if (allNodes.length >= 2) { - qsfsNodes.push(+allNodes[0].nodeId, +allNodes[1].nodeId); - } else { - throw Error("Couldn't find nodes for qsfs"); + // Loop over filtered nodes and push in qsfsNodes until they have the required resources + for (const node of nodes) { + const freeResources = await grid3.capacity.nodes.getNodeFreeResources(node.nodeId); + const freeHRU = freeResources.hru / 1024 ** 3; + + if (freeHRU >= disk_size && usedResources <= disk_size * count) { + qsfsNodes.push(node.nodeId); + usedResources += freeHRU; + } + + if (usedResources >= disk_size * count) { + break; + } } async function getNodeId(client: GridClient, options: FilterOptions) { @@ -76,10 +88,10 @@ async function main() { //create qsfs object const qsfs: QSFSZDBSModel = { name: qsfs_name, - count: 8, + count, node_ids: qsfsNodes, password: "mypassword1", - disk_size: 1, + disk_size, description: "my qsfs test", metadata: "", }; From 465fd7fbb985108279cf69e078baae46538fbd63 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Tue, 13 Aug 2024 07:59:50 +0300 Subject: [PATCH 06/42] Add more tests --- .../tests/modules/zmachine.test.ts | 99 +++++++++++++++++-- 1 file changed, 92 insertions(+), 7 deletions(-) diff --git a/packages/grid_client/tests/modules/zmachine.test.ts b/packages/grid_client/tests/modules/zmachine.test.ts index 9a8daff13f..90b519969b 100644 --- a/packages/grid_client/tests/modules/zmachine.test.ts +++ b/packages/grid_client/tests/modules/zmachine.test.ts @@ -7,7 +7,7 @@ const computeCapacity = new ComputeCapacity(); const network = new ZmachineNetwork(); const disks = new Mount(); -beforeAll(() => { +beforeEach(() => { computeCapacity.cpu = 1; computeCapacity.memory = 256 * 1024 ** 2; @@ -19,6 +19,10 @@ beforeAll(() => { ip: "10.20.2.2", }, ]; + network.mycelium = { + network: "mycelium_net", + hex_seed: "abc123", + }; const rootfs_size = 2; @@ -31,9 +35,9 @@ beforeAll(() => { zmachine.mounts = [disks]; zmachine.entrypoint = "/sbin/zinit init"; zmachine.compute_capacity = computeCapacity; - zmachine.env = {}; + zmachine.env = { key: "value" }; zmachine.corex = false; - zmachine.gpu = []; + zmachine.gpu = ["AMD", "NIVIDIA"]; }); describe("Zmachine Class Tests", () => { @@ -41,6 +45,19 @@ describe("Zmachine Class Tests", () => { expect(zmachine).toBeInstanceOf(Zmachine); }); + it("should correctly serialize and deserialize a Zmachine instance", () => { + const serialized = JSON.stringify(zmachine); + const deserialized = plainToClass(Zmachine, JSON.parse(serialized)); + + expect(deserialized).toBeInstanceOf(Zmachine); + expect(deserialized.challenge()).toBe(zmachine.challenge()); + }); + it("should correctly handle env vars", () => { + const challenge = zmachine.challenge(); + + expect(challenge).toContain("key=value"); + }); + it("should correctly compute the challenge string", () => { const expectedChallenge = zmachine.flist + @@ -48,17 +65,85 @@ describe("Zmachine Class Tests", () => { zmachine.size + computeCapacity.challenge() + zmachine.mounts[0].challenge() + - zmachine.entrypoint; + zmachine.entrypoint + + JSON.stringify(zmachine.env) + .replace(/[{"}"]/g, "") + .replace(":", "=") + + zmachine.gpu?.toString().replace(",", ""); expect(zmachine.challenge()).toBe(expectedChallenge); + expect(zmachine.challenge()).toContain("key=value"); + }); + + it("should correctly handle the gpu array", () => { + expect(zmachine.gpu).toContain("NIVIDIA"); + + zmachine.gpu = []; + + expect(zmachine.challenge()).not.toContain("NIVIDIA"); + + zmachine.gpu = ["NIVIDIA", "AMD"]; + + expect(zmachine.challenge()).toContain("NIVIDIA"); + expect(zmachine.challenge()).toContain("AMD"); + }); + + it("should handle network configurations", () => { + const challenge = zmachine.challenge(); + + expect(challenge).toContain("10.249.0.0/16"); + expect(challenge).toContain("znetwork"); + expect(challenge).toContain("mycelium_net"); + expect(challenge).toContain("abc123"); }); it("should fail validation for entering invalid data", () => { - const result = () => { + const invalidFlist = () => { zmachine.flist = ""; - zmachine.entrypoint = ""; - zmachine.network.public_ip = ""; }; + const invalidEntrypoint = () => (zmachine.entrypoint = undefined as any); + const invalidSize = () => (zmachine.size = 10 * 1024 ** 5); + + expect(invalidFlist).toThrow(); + expect(invalidEntrypoint).toThrow(); + expect(invalidSize).toThrow(); + }); + + it("should throw error if network public_ip is invalid", () => { + const invalidNetwork = new ZmachineNetwork(); + invalidNetwork.public_ip = "invalid_ip"; + invalidNetwork.planetary = true; + invalidNetwork.interfaces = [{ network: "znetwork", ip: "10.20.2.2" }]; + + const result = () => { + zmachine.network = invalidNetwork; + }; + + expect(result).toThrow(); + }); + + it("should throw error if network interfaces are empty", () => { + const invalidNetwork = new ZmachineNetwork(); + invalidNetwork.public_ip = "10.249.0.0/16"; + invalidNetwork.planetary = true; + invalidNetwork.interfaces = []; + + const result = () => { + zmachine.network = invalidNetwork; + }; + + expect(result).toThrow(); + }); + + it("should throw an error if mount name is empty", () => { + const invalidMount = new Mount(); + invalidMount.name = ""; + invalidMount.mountpoint = "/mnt/data"; + + const result = () => { + zmachine.mounts = [invalidMount]; + }; + expect(result).toThrow(); }); From 7d40a921a5f9d79ca1c44474c37e1c783706489b Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Wed, 14 Aug 2024 11:01:56 +0300 Subject: [PATCH 07/42] Fix tests --- packages/grid_client/tests/modules/zmachine.test.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/grid_client/tests/modules/zmachine.test.ts b/packages/grid_client/tests/modules/zmachine.test.ts index 90b519969b..bab1d7aec4 100644 --- a/packages/grid_client/tests/modules/zmachine.test.ts +++ b/packages/grid_client/tests/modules/zmachine.test.ts @@ -1,6 +1,6 @@ import { plainToClass } from "class-transformer"; -import { ComputeCapacity, Mount, Zmachine, ZmachineNetwork } from "../../src"; +import { ComputeCapacity, Mount, Zmachine, ZmachineNetwork, ZNetworkInterface } from "../../src"; let zmachine = new Zmachine(); const computeCapacity = new ComputeCapacity(); @@ -111,7 +111,7 @@ describe("Zmachine Class Tests", () => { it("should throw error if network public_ip is invalid", () => { const invalidNetwork = new ZmachineNetwork(); - invalidNetwork.public_ip = "invalid_ip"; + invalidNetwork.public_ip = undefined as any; invalidNetwork.planetary = true; invalidNetwork.interfaces = [{ network: "znetwork", ip: "10.20.2.2" }]; @@ -122,11 +122,13 @@ describe("Zmachine Class Tests", () => { expect(result).toThrow(); }); - it("should throw error if network interfaces are empty", () => { + it("should throw error if network interfaces values are invalid", () => { const invalidNetwork = new ZmachineNetwork(); invalidNetwork.public_ip = "10.249.0.0/16"; invalidNetwork.planetary = true; - invalidNetwork.interfaces = []; + invalidNetwork.interfaces = [new ZNetworkInterface()]; + invalidNetwork.interfaces[0].network = ""; + invalidNetwork.interfaces[0].ip = ""; const result = () => { zmachine.network = invalidNetwork; From a50cc48392f9b8e6df40ab98c91792c033b7bea7 Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Thu, 15 Aug 2024 14:20:02 +0300 Subject: [PATCH 08/42] docs: Documented the mycelium options: - Documented the 'mycelium' option - Documented the 'myceliumSeed' option - Documented the 'seed' option --- packages/grid_client/src/modules/models.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/grid_client/src/modules/models.ts b/packages/grid_client/src/modules/models.ts index 173d155505..2a56d78c71 100644 --- a/packages/grid_client/src/modules/models.ts +++ b/packages/grid_client/src/modules/models.ts @@ -94,6 +94,12 @@ class NetworkModel { } class MyceliumNetworkModel { + /** + * ### Mycelium Network Seed: + * - The `seed` is an optional field used to provide a specific seed for the Mycelium network. + * - If not provided, the `GridClient` will generate a seed automatically when the `mycelium` flag is enabled. + * - **Use Case:** If you need the new machine to have the same IP address as a previously deleted machine, you can reuse the old seed by setting the `myceliumSeed` field. + */ @Expose() @IsString() @Length(32) seed?: string; @Expose() @IsInt() @Min(1) nodeId: number; } @@ -110,7 +116,20 @@ class MachineModel { @Expose() @IsBoolean() public_ip: boolean; @Expose() @IsOptional() @IsBoolean() public_ip6?: boolean; @Expose() @IsBoolean() planetary: boolean; + /** + * ### Mycelium Flag Behavior: + * - When the `mycelium` flag is enabled, there’s no need to manually provide the `myceliumSeed` flag. + * - The `GridClient` will automatically generate the necessary seed for you. + * - **However**, if you have **an existing seed** from a previously deleted machine and wish to deploy a new machine that retains the same IP address, + * - **you can simply pass in the old seed during deployment instead of calling the `generateRandomHexSeed()` function**. + */ @Expose() @IsBoolean() mycelium: boolean; + /** + * ### Mycelium Seed: + * - The `myceliumSeed` is an optional field used to provide a specific seed for the Mycelium network. + * - If not provided, the `GridClient` will generate a seed automatically when the `mycelium` flag is enabled. + * - **Use Case:** If you need the new machine to have the same IP address as a previously deleted machine, you can reuse the old seed by setting the `myceliumSeed` field. + */ @Expose() @IsOptional() @IsString() @Length(6) myceliumSeed?: string; @Expose() @IsInt() @Min(1) cpu: number; @Expose() @Min(256) memory: number; // in MB From 539acd2fda4e6eff96e821461f1cac0c8cbb1122 Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Thu, 15 Aug 2024 14:36:16 +0300 Subject: [PATCH 09/42] feat: Enhanced the 'single_vm_mycelium' script: - Docuemented the 'network.myceliumSeeds.seed', 'machines.machine[any].mycelium', and 'machines.machine[any].myceliumSeed' options. - Imported the missing types --- .../grid_client/scripts/single_vm_mycelium.ts | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/packages/grid_client/scripts/single_vm_mycelium.ts b/packages/grid_client/scripts/single_vm_mycelium.ts index 07b7152260..fcb521936a 100644 --- a/packages/grid_client/scripts/single_vm_mycelium.ts +++ b/packages/grid_client/scripts/single_vm_mycelium.ts @@ -1,23 +1,23 @@ -import { MachinesModel } from "../src"; +import { generateRandomHexSeed, GridClient, MachinesDeleteModel, MachinesModel } from "../src"; import { config, getClient } from "./client_loader"; import { log } from "./utils"; -async function deploy(client, vms) { +async function deploy(client: GridClient, vms: MachinesModel) { const res = await client.machines.deploy(vms); log("================= Deploying VM ================="); log(res); log("================= Deploying VM ================="); } -async function getDeployment(client, vms) { - const res = await client.machines.getObj(vms); +async function getDeployment(client: GridClient, name: string) { + const res = await client.machines.getObj(name); log("================= Getting deployment information ================="); log(res); log("================= Getting deployment information ================="); } -async function cancel(client, vms) { - const res = await client.machines.delete(vms); +async function cancel(client: GridClient, options: MachinesDeleteModel) { + const res = await client.machines.delete(options); log("================= Canceling the deployment ================="); log(res); log("================= Canceling the deployment ================="); @@ -32,12 +32,18 @@ async function main() { network: { name: "hellotest", ip_range: "10.249.0.0/16", - // myceliumSeeds: [ - // { - // nodeId: 168, - // seed: "050d109829d8492d48bfb33b711056080571c69e46bfde6b4294c4c5bf468a76", //(HexSeed of length 32) - // }, - // ], + myceliumSeeds: [ + { + nodeId: 168, + /** + * ### Mycelium Network Seed: + * - The `seed` is an optional field used to provide a specific seed for the Mycelium network. + * - If not provided, the `GridClient` will generate a seed automatically when the `mycelium` flag is enabled. + * - **Use Case:** If you need the new machine to have the same IP address as a previously deleted machine, you can reuse the old seed by setting the `myceliumSeed` field. + */ + seed: generateRandomHexSeed(32), + }, + ], }, machines: [ { @@ -53,8 +59,21 @@ async function main() { public_ip: false, public_ip6: false, planetary: true, + /** + * ### Mycelium Flag Behavior: + * - When the `mycelium` flag is enabled, there’s no need to manually provide the `myceliumSeed` flag. + * - The `GridClient` will automatically generate the necessary seed for you. + * - **However**, if you have **an existing seed** from a previously deleted machine and wish to deploy a new machine that retains the same IP address, + * - **you can simply pass in the old seed during deployment instead of calling the `generateRandomHexSeed()` function**. + */ mycelium: true, - // myceliumSeed: "1e1404279b3d", //(HexSeed of length 6) + /** + * ### Mycelium Seed: + * - The `myceliumSeed` is an optional field used to provide a specific seed for the Mycelium network. + * - If not provided, the `GridClient` will generate a seed automatically when the `mycelium` flag is enabled. + * - **Use Case:** If you need the new machine to have the same IP address as a previously deleted machine, you can reuse the old seed by setting the `myceliumSeed` field. + */ + myceliumSeed: generateRandomHexSeed(3), // (HexSeed of length 6) cpu: 1, memory: 1024 * 2, rootfs_size: 0, From 54aaa91cf1c86f45019f0d9330c4d0315a4bb6dc Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Sun, 18 Aug 2024 15:03:58 +0300 Subject: [PATCH 10/42] Remove unnecessary getNodeResources call, comment delete deployment --- .../scripts/orchestrators/kubernetes_with_qsfs.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts b/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts index 4b3307607e..41e109284e 100644 --- a/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts +++ b/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts @@ -54,7 +54,7 @@ async function main() { }; const qsfsQueryOptions: FilterOptions = { - hru: 15, + hru: count * disk_size, availableFor: grid3.twinId, farmId: 1, }; @@ -66,8 +66,7 @@ async function main() { // Loop over filtered nodes and push in qsfsNodes until they have the required resources for (const node of nodes) { - const freeResources = await grid3.capacity.nodes.getNodeFreeResources(node.nodeId); - const freeHRU = freeResources.hru / 1024 ** 3; + const freeHRU = (node.total_resources.hru - node.used_resources.hru) / 1024 ** 3; if (freeHRU >= disk_size && usedResources <= disk_size * count) { qsfsNodes.push(node.nodeId); @@ -158,8 +157,8 @@ async function main() { await getDeployment(grid3, name); // //Uncomment the line below to cancel the deployment - await cancel(grid3, k.name); - await deleteQsfs(grid3, qsfs_name); + // await cancel(grid3, k.name); + // await deleteQsfs(grid3, qsfs_name); await grid3.disconnect(); } From 9e491f3a391bf4968d5d25fbc57f08aad23db76b Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Mon, 19 Aug 2024 13:04:41 +0300 Subject: [PATCH 11/42] Refactor condition --- .../grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts b/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts index 41e109284e..5650fc10c4 100644 --- a/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts +++ b/packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts @@ -68,7 +68,7 @@ async function main() { for (const node of nodes) { const freeHRU = (node.total_resources.hru - node.used_resources.hru) / 1024 ** 3; - if (freeHRU >= disk_size && usedResources <= disk_size * count) { + if (freeHRU >= disk_size) { qsfsNodes.push(node.nodeId); usedResources += freeHRU; } From b3371e31e25fcd8eb2e74e2368b7f502d2d9f158 Mon Sep 17 00:00:00 2001 From: kassem Date: Mon, 19 Aug 2024 16:42:37 +0300 Subject: [PATCH 12/42] chore: - clearify error in dao by logging the error. - clearify duplicated vote error by rephrase the toast message --- packages/playground/src/dashboard/dao_view.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/playground/src/dashboard/dao_view.vue b/packages/playground/src/dashboard/dao_view.vue index 2d1410d419..9e301c893e 100644 --- a/packages/playground/src/dashboard/dao_view.vue +++ b/packages/playground/src/dashboard/dao_view.vue @@ -288,7 +288,7 @@