-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2929 from threefoldtech/development_2.6
Development 2.6
- Loading branch information
Showing
122 changed files
with
15,544 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Link Checker | ||
|
||
on: | ||
schedule: | ||
- cron: '0 8 * * *' | ||
|
||
jobs: | ||
check-links: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Link Checker | ||
id: checker | ||
uses: docker://ghcr.io/threefoldfoundation/website-link-checker:latest | ||
with: | ||
args: 'https://staging.dashboard.dev.grid.tf -e 404 501 503 504 -w all' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# When the action is executed, it runs yarn audit command in all the paths that is mentioned in the input. The exit codes of the commands are compared and if it is greater than 7 (only high severity as of now), the action will try to fetch the open issues in the repo with the label provided in the input. The label is mandatory to prevent from creating duplicate issues. If there are no open issues with the given label in open state, the action will try to create a Github Issue with the details provided in the input. | ||
|
||
name: Full Clients Audit | ||
|
||
on: | ||
push: | ||
branches: [development, development_2.6] | ||
pull_request: | ||
branches: [development, development_2.6] | ||
|
||
jobs: | ||
audit-and-open-issue: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Yarn Audit | ||
uses: pragatheeswarans/[email protected] | ||
with: | ||
token: ${{ github.token }} | ||
label: 'audit' | ||
title: "${{ github.workflow }}: Critical Security Vulnerability Identified" | ||
description: 'High severity issues are identified in the repo.' | ||
paths: | | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Decimal } from "decimal.js"; | ||
|
||
const GB = 1024; | ||
|
||
interface RootFSOptions { | ||
/** The machine CPU, should be in cores e.g. 5 cores*/ | ||
CPUCores: number; | ||
/** The machine memory, should be in megabytes e.g. 1024 or 2048 MG*/ | ||
RAMInMegaBytes: number; | ||
} | ||
|
||
/** | ||
* Calculate the root filesystem size (CU - Compute Units) based on provided options. | ||
* | ||
* This function calculates the compute units (CU) required based on the CPU cores and RAM in megabytes. | ||
* If both CPU cores and RAM are provided in the `options` parameter, it calculates CU by multiplying | ||
* the CPU cores with RAM and dividing by 8 * GB, then converting the result to an integer. If the | ||
* calculated CU is zero, it returns 500 / GB; otherwise, it returns 2. | ||
* | ||
* @param {RootFSOptions} [options] - Optional configuration object. | ||
* @param {number} [options.CPUCores] - The number of CPU cores. | ||
* @param {number} [options.RAMInMegaBytes] - The RAM size in megabytes. | ||
* | ||
* @returns {number} - The calculated compute units (CU) based on the provided options. | ||
*/ | ||
function calculateRootFileSystem(options?: RootFSOptions): number { | ||
let cu = 0; | ||
|
||
if (options && options.CPUCores && options.RAMInMegaBytes) { | ||
cu = new Decimal(options.CPUCores) | ||
.mul(options.RAMInMegaBytes) | ||
.divToInt(8 * GB) | ||
.toNumber(); | ||
} | ||
|
||
return cu === 0 ? 500 / GB : 2; | ||
} | ||
|
||
export { calculateRootFileSystem, RootFSOptions }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { PublicIPResult, ResultStates } from "../zos"; | ||
|
||
interface NetworkInterface { | ||
/** The network identifier */ | ||
network: string; | ||
/** The IP address of the interface */ | ||
ip: string; | ||
} | ||
|
||
interface ComputeCapacity { | ||
/** Number of CPU cores allocated */ | ||
cpu: number; | ||
/** Amount of memory allocated in MB */ | ||
memory: number; | ||
} | ||
|
||
interface BaseMountData { | ||
/** The name of the mount */ | ||
name: string; | ||
/** The mount point in the filesystem */ | ||
mountPoint: string; | ||
} | ||
|
||
interface ExtendedMountData extends BaseMountData { | ||
/** The size of the mount (optional) */ | ||
size?: number; | ||
/** The state of the mount result (optional) */ | ||
state?: ResultStates; | ||
/** Message providing additional information about the mount result (optional) */ | ||
message?: string; | ||
/** Cache information (optional) */ | ||
cache?: any; | ||
/** Prefix information (optional) */ | ||
prefix?: any; | ||
/** Minimal shards (optional) */ | ||
minimal_shards?: number; | ||
/** Expected shards (optional) */ | ||
expected_shards?: number; | ||
/** QSFS ZDBs name (optional) */ | ||
qsfs_zdbs_name?: string; | ||
/** Metrics endpoint (optional) */ | ||
metricsEndpoint?: string; | ||
} | ||
|
||
// Union type for the mount data | ||
type MountData = BaseMountData | ExtendedMountData; | ||
|
||
interface ZmachineData { | ||
/** The version of the workload */ | ||
version: number; | ||
/** The contract ID associated with the workload */ | ||
contractId: number; | ||
/** The node ID where the workload is deployed */ | ||
nodeId: string; | ||
/** The name of the workload */ | ||
name: string; | ||
/** The creation timestamp of the workload result */ | ||
created: number; | ||
/** The current state of the workload */ | ||
status: string; | ||
/** Message providing additional information about the workload state */ | ||
message: string; | ||
/** The flist (file list) used by the workload */ | ||
flist: string; | ||
/** The public IP address obtained by the machine */ | ||
publicIP: PublicIPResult; | ||
/** The planetary IP address of the machine */ | ||
planetary: string; | ||
/** The Mycelium IP address of the machine, if applicable */ | ||
myceliumIP: string; | ||
/** List of network interfaces */ | ||
interfaces: NetworkInterface[]; | ||
/** The compute capacity (CPU and memory) allocated to the machine */ | ||
capacity: ComputeCapacity; | ||
/** List of mounts associated with the machine */ | ||
mounts: MountData[]; | ||
/** Environment variables set for the workload */ | ||
env: Record<string, unknown>; | ||
/** The entrypoint command for the workload */ | ||
entrypoint: string; | ||
/** Metadata associated with the workload */ | ||
metadata: string; | ||
/** Description of the workload */ | ||
description: string; | ||
/** Size of the root filesystem */ | ||
rootfs_size: number; | ||
/** Indicates if corex is enabled */ | ||
corex: boolean; | ||
/** The list of the GPUs */ | ||
gpu: string[] | undefined; | ||
} | ||
|
||
interface VM extends ZmachineData { | ||
customDomain?: string; | ||
deploymentName: string; | ||
projectName: string; | ||
wireguard: string; | ||
} | ||
|
||
export { ZmachineData, VM }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { ComputeCapacity, Mount, Zmachine, ZmachineNetwork } from "../../src"; | ||
|
||
const zmachine = new Zmachine(); | ||
|
||
beforeAll(() => { | ||
const computeCapacity = new ComputeCapacity(); | ||
computeCapacity.cpu = 1; | ||
computeCapacity.memory = 5; | ||
|
||
const network = new ZmachineNetwork(); | ||
network.planetary = true; | ||
network.public_ip = "10.249.0.0/16"; | ||
network.interfaces = [ | ||
{ | ||
network: "znetwork", | ||
ip: "10.20.2.2", | ||
}, | ||
]; | ||
|
||
const rootfs_size = 2; | ||
|
||
const disks = new Mount(); | ||
disks.name = "zdisk"; | ||
disks.mountpoint = "/mnt/data"; | ||
|
||
zmachine.flist = "https://hub.grid.tf/tf-official-vms/ubuntu-22.04.flist"; | ||
zmachine.network = network; | ||
zmachine.size = rootfs_size * 1024 ** 3; | ||
zmachine.mounts = [disks]; | ||
zmachine.entrypoint = "/sbin/zinit init"; | ||
zmachine.compute_capacity = computeCapacity; | ||
zmachine.env = {}; | ||
zmachine.corex = false; | ||
zmachine.gpu = []; | ||
}); | ||
|
||
describe("Zmachine Class Tests", () => { | ||
it("should create a valid Zmachine instance", () => { | ||
expect(zmachine).toBeInstanceOf(Zmachine); | ||
}); | ||
|
||
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"; | ||
|
||
expect(zmachine.challenge()).toBe(expectedChallenge); | ||
}); | ||
|
||
it("should fail validation for missing required fields", () => { | ||
const result = () => { | ||
zmachine.flist = ""; | ||
zmachine.entrypoint = ""; | ||
}; | ||
expect(result).toThrow(); | ||
Check failure on line 62 in packages/grid_client/tests/modules/zmachine.test.ts
|
||
}); | ||
}); |
Oops, something went wrong.