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 deploy Kubernetes cluster with workers #3870

Merged
merged 1 commit into from
Feb 10, 2025
Merged
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
26 changes: 16 additions & 10 deletions packages/grid_client/src/modules/k8s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,25 @@ class K8sModule extends BaseModule {
throw new ValidationError(`Another master with the same name ${master.name} already exists.`);
masters_names.push(master.name);

if (network) break;
// Sets the network and contractMetadata based on the node's zos version
const nodeTwinId = await this.capacity.getNodeTwinId(master.node_id);
const features = await this.rmb.request([nodeTwinId], "zos.system.node_features_get", "", 20, 3);
if (features.some(item => item.includes("zmachine-light") || item.includes("network-light"))) {
network = new ZNetworkLight(options.network.name, options.network.ip_range, this.config);
await network.load();
if (!network) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this network be defined at any point?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check that in the rest of the changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this network be defined at any point?

Yes it will be defined in the next iteration also in the workers

network = new ZNetworkLight(options.network.name, options.network.ip_range, this.config);
await network.load();
}
contractMetadata = JSON.stringify({
version: 4,
type: "kubernetes",
name: options.name,
projectName: this.config.projectName || `kubernetes/${options.name}`,
});
} else {
network = new Network(options.network.name, options.network.ip_range, this.config);
await network.load();
if (!network) {
network = new Network(options.network.name, options.network.ip_range, this.config);
await network.load();
}
contractMetadata = JSON.stringify({
version: 3,
type: "kubernetes",
Expand Down Expand Up @@ -219,21 +222,24 @@ class K8sModule extends BaseModule {
throw new ValidationError(`Another worker with the same name ${worker.name} already exists.`);
workers_names.push(worker.name);

if (network) break;
const nodeTwinId = await this.capacity.getNodeTwinId(worker.node_id);
const features = await this.rmb.request([nodeTwinId], "zos.system.node_features_get", "", 20, 3);
if (features.some(item => item.includes("zmachine-light") || item.includes("network-light"))) {
network = new ZNetworkLight(options.network.name, options.network.ip_range, this.config);
await network.load();
if (!network) {
network = new ZNetworkLight(options.network.name, options.network.ip_range, this.config);
await network.load();
}
contractMetadata = JSON.stringify({
version: 4,
type: "kubernetes",
name: options.name,
projectName: this.config.projectName || `kubernetes/${options.name}`,
});
} else {
network = new Network(options.network.name, options.network.ip_range, this.config);
await network.load();
if (!network) {
network = new Network(options.network.name, options.network.ip_range, this.config);
await network.load();
}
Comment on lines 227 to +242
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this part repeated?

Copy link
Contributor Author

@0oM4R 0oM4R Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to create a function in utils that does those steps, but the function will take the network argument, network, and network type, so there will be more lines

example

awat createOrLoadNetowrk(options.network.name, options.network.ip_range, this.config, network, 'ZNetworkLight`)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the case you might have only workers if you add a worker to an existing cluster

contractMetadata = JSON.stringify({
version: 3,
type: "kubernetes",
Expand Down
Loading