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

Conversation

0oM4R
Copy link
Contributor

@0oM4R 0oM4R commented Feb 6, 2025

The issue that checking if the node is definded and already created breaks the creation of the workers, it passes with master as there is no network was created yet so it will continue normally then to the workers will face the break line before adding the workers

Changes

  • k8s: for workers and masters only check if the network is loaded if not create a new network without break;

Related Issues

Tested Scenarios

  • deployed a cluster with 2 workers from dashboard
image
  • deployed cluster using kubernetes_leader script
    image
  • passed already created network and the cluster deployed normally on it
image

Documentation PR

For UI changes, Please provide the Documentation PR on info_grid

To consider

Preliminary Checks:

  • Preliminary Checks
    • Does it completely address the issue linked?
    • What about edge cases?
    • Does it meet the specified acceptance criteria?
    • Are there any unintended side effects?
    • Does the PR adhere to the team's coding conventions, style guides, and best practices?
    • Does it integrate well with existing features?
    • Does it impact the overall performance of the application?
    • Are there any bottlenecks or slowdowns?
    • Has it been optimized for efficiency?
    • Has it been adequately tested with unit, integration, and end-to-end tests?
    • Are there any known defects or issues?
    • Is the code well-documented?
    • Are changes to documentation reflected in the code?

UI Checks:

  • UI Checks
    • If a UI design is provided/ does it follow it?
    • Does every button work?
    • Is the data displayed logical? Is it what you expected?
    • Does every validation work?
    • Does this interface feel intuitive?
    • What about slow network? Offline?
    • What if the gridproxy/graphql/chain is failing?
    • What would a first time user have a hard time navigating here?

Code Quality Checks:

  • Code Quality Checks
    • Code formatted/linted? Are there unused imports? .. etc
    • Is there redundant/repeated code?
    • Are there conditionals that are always true or always false?
    • Can we write this more concisely?
    • Can we reuse this code? If yes, where?
    • Will the changes be easy to maintain and update in the future?
    • Can this code become too complex to understand for other devs?
    • Can this code cause future integration problems?

Testing Checklist

  • Does it Meet the specified acceptance criteria.
  • Test if changes can affect any other functionality.
  • Tested with unit, integration, and end-to-end tests.
  • Tested the un-happy path and rollback scenarios.
  • Documentation updated to meet the latest changes.
  • Check automated tests working successfully with the changes.
  • Can be covered by automated tests.

General Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring
  • Screenshots/Video attached (needed for UI changes)

- k8s: for workers and masters only check if the network is loaded if not create a new network without break;
Copy link
Contributor

@amiraabouhadid amiraabouhadid left a comment

Choose a reason for hiding this comment

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

works, good job
{ "masters": [ { "version": 0, "type": "zmachine", "contractId": 191373, "nodeId": 153, "name": "mrtyklo", "created": 1739174873, "status": "ok", "message": "", "flist": "https://hub.grid.tf/tf-official-apps/threefolddev-k3s-v1.31.0.flist", "publicIP": null, "myceliumIP": "42e:525:4c9e:f4e4:ff0f:0:400:2", "interfaces": [ { "network": "nwkies6", "ip": "10.20.4.2" } ], "capacity": { "cpu": 1, "memory": 4096 }, "mounts": [ { "name": "mrtyklo_disk", "mountPoint": "/mnt/data", "size": 107374182400, "state": "ok", "message": "" } ], "env": { "SSH_KEY": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDfqmofYkYQUFPeerDyZloK61Zslbwov5o41QcaBjmsUodYiO1+crAqO4OCFX4EFXIRJLkCq20wELaFuVEkPoXufbLyOpcCqD79yuU+LikXQgi7lYFolDVX506kL2b/pTnkP6PapJnAOMUoaSjI41fKsw44mog7IgCHzq05age6Md/RKcytH75N2DcxX+Eo6xtAF2+2lF0jvBYu1A4GYnwfWjOQ74TIv/YP1lrSJs6RO1t+I3gEokn6hwYsVe+0HKhsMWAFA97Uis2XMCzWoZFTy41jBC9BXL873tAQA9KDueRjHJ583HUGGfIXZIVH0rkXcxhfsYU0OUvyo1Dn95liFw6EE+INdLt2GDlb6MbLQthomuu6Si8jhoP2jgpBenjFdSEwNmX0dVg8uzA+qUFXaGITQQsbHnleEk7MYiozBCkq5HfhdYYP8Dtp+UBj0vuzBZK2EANin7GnRU8pu7Z/J53D2CBr08m8oFH9N5Zep/G9l6joaIYZ3eN0h5WZCSvGxTUw7WThlS/jwefPY1AdU8OliTN1WrObt9sDa6RnKpKXzfOJL4UdRAJ5MbW7JPwif4Ag4lTVKZfJpFgiWfitO64gz8pkUmFyTXF5YvrSpcPQJgiXcFktd0eqqVITnC45r2jndx2QuM9wwdExr7lel5tqN9hIIGtPhhUHYvFIsw== cosmos", "K3S_TOKEN": "YiEwYq98B6", "K3S_DATA_DIR": "/mnt/data", "K3S_FLANNEL_IFACE": "eth0", "K3S_NODE_NAME": "mrtyklo", "K3S_URL": "" }, "entrypoint": "/sbin/zinit init", "metadata": "", "description": "", "rootfs_size": 524288000, "corex": false, "gpu": [] } ], "workers": [ { "version": 0, "type": "zmachine", "contractId": 191372, "nodeId": 128, "name": "wrcjlrr", "created": 1739174874, "status": "ok", "message": "", "flist": "https://hub.grid.tf/tf-official-apps/threefolddev-k3s-v1.31.0.flist", "publicIP": null, "myceliumIP": "554:d273:2e79:9ec6:ff0f:0:500:2", "interfaces": [ { "network": "nwkies6", "ip": "10.20.5.2" } ], "capacity": { "cpu": 1, "memory": 4096 }, "mounts": [ { "name": "wrcjlrr_disk", "mountPoint": "/mnt/data", "size": 107374182400, "state": "ok", "message": "" } ], "env": { "SSH_KEY": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDfqmofYkYQUFPeerDyZloK61Zslbwov5o41QcaBjmsUodYiO1+crAqO4OCFX4EFXIRJLkCq20wELaFuVEkPoXufbLyOpcCqD79yuU+LikXQgi7lYFolDVX506kL2b/pTnkP6PapJnAOMUoaSjI41fKsw44mog7IgCHzq05age6Md/RKcytH75N2DcxX+Eo6xtAF2+2lF0jvBYu1A4GYnwfWjOQ74TIv/YP1lrSJs6RO1t+I3gEokn6hwYsVe+0HKhsMWAFA97Uis2XMCzWoZFTy41jBC9BXL873tAQA9KDueRjHJ583HUGGfIXZIVH0rkXcxhfsYU0OUvyo1Dn95liFw6EE+INdLt2GDlb6MbLQthomuu6Si8jhoP2jgpBenjFdSEwNmX0dVg8uzA+qUFXaGITQQsbHnleEk7MYiozBCkq5HfhdYYP8Dtp+UBj0vuzBZK2EANin7GnRU8pu7Z/J53D2CBr08m8oFH9N5Zep/G9l6joaIYZ3eN0h5WZCSvGxTUw7WThlS/jwefPY1AdU8OliTN1WrObt9sDa6RnKpKXzfOJL4UdRAJ5MbW7JPwif4Ag4lTVKZfJpFgiWfitO64gz8pkUmFyTXF5YvrSpcPQJgiXcFktd0eqqVITnC45r2jndx2QuM9wwdExr7lel5tqN9hIIGtPhhUHYvFIsw== cosmos", "K3S_TOKEN": "YiEwYq98B6", "K3S_DATA_DIR": "/mnt/data", "K3S_FLANNEL_IFACE": "eth0", "K3S_NODE_NAME": "wrcjlrr", "K3S_URL": "https://10.20.4.2:6443" }, "entrypoint": "/sbin/zinit init", "metadata": "", "description": "", "rootfs_size": 524288000, "corex": false, "gpu": [] } ], "wireguard": "[Interface]\nAddress = 100.64.20.3/32\nPrivateKey = x/ugVx7GragYRHRZE/lQ+dZRBXx6RE21ge74J/c35hM=\n\n[Peer]\nPublicKey = XugpkuEvSbnBwDkHyP+y3juqzCjmuQ23EmaWkRy+uTk=\nAllowedIPs = 10.20.0.0/16, 100.64.20.0/32\nPersistentKeepalive = 25\nEndpoint = 185.206.122.31:17621" }

// 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

Comment on lines 227 to +242
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();
}
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

@0oM4R 0oM4R merged commit 1c2d461 into development Feb 10, 2025
9 checks passed
@0oM4R 0oM4R deleted the development_fix_deploy_k8sWorkers branch February 10, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants