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

feat: each node pool can now have different init configs #6184

Conversation

Silvest89
Copy link
Contributor

@Silvest89 Silvest89 commented Oct 10, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Currently the Hetzner provider is very lacking and the autoscaler does not know beforehand which custom taints/labels the provided node pools have.
This PR adds support for a each nodepool to have their own initconfig (currently breaking change, but will see if I have the time to make it backwards compatible). It also supports multi arch node pools. I have been running this a month or so~ build my own image

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Currently this PR introduces a breaking change. However if required I can refactor it so it is backwards compatible

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 10, 2023
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 10, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Silvest89 / name: Johnnie Ho (e1408ed)

@k8s-ci-robot
Copy link
Contributor

Welcome @Silvest89!

It looks like this is your first PR to kubernetes/autoscaler 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/autoscaler has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/provider/hetzner Issues or PRs related to Hetzner provider labels Oct 10, 2023
@Shubham82
Copy link
Contributor

Hi @Silvest89
Please sign the CLA before the PR can be reviewed.
See the following document to sign the CLA: Signing Contributor License Agreements(CLA)

@Shubham82
Copy link
Contributor

To check EasyCLA

/easycla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 11, 2023
@Silvest89
Copy link
Contributor Author

Alright, just signed it :)

Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

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

Looks very nice 💯

Two things I would like to see before approving this:

Backwards compatibility: We do not want to break users of the older options, so please add HCLOUD_CLOUD_INIT & HCLOUD_IMAGE back in. If one of the old options as well as a the HCLOUD_CLUSTER_CONFIG is defined, I think we should use the newer options.

Docs: It would be great if you can provide an example of how this can be used and how they relate to the older options.

@Silvest89
Copy link
Contributor Author

Looks very nice 💯

Two things I would like to see before approving this:

Backwards compatibility: We do not want to break users of the older options, so please add HCLOUD_CLOUD_INIT & HCLOUD_IMAGE back in. If one of the old options as well as a the HCLOUD_CLUSTER_CONFIG is defined, I think we should use the newer options.

Docs: It would be great if you can provide an example of how this can be used and how they relate to the older options.

Alright I will be on it. Will update the PR later this week. With updated docs as well :)

@Silvest89 Silvest89 force-pushed the hetzner-provider-multi-node-pools-support branch from 1c595a3 to 70f6275 Compare October 12, 2023 19:28
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 12, 2023
@Silvest89 Silvest89 force-pushed the hetzner-provider-multi-node-pools-support branch from 70f6275 to aa4ea0e Compare October 12, 2023 19:32
@Silvest89
Copy link
Contributor Author

@apricote
Backwards compatibility and updated docs has been implemented

@Silvest89 Silvest89 requested a review from apricote October 13, 2023 11:52
Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

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

Looking good besides one missed error handling and the linting errors from CI :)

https://github.com/kubernetes/autoscaler/actions/runs/6500103013/job/17654801323?pr=6184#step:6:152

if manager.clusterConfig.IsUsingNewFormat {
_, ok := manager.clusterConfig.NodeConfigs[spec.name]
if !ok {
klog.Fatalf("No node config present for node id `%s` error: %v", spec.name, err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
klog.Fatalf("No node config present for node id `%s` error: %v", spec.name, err)
klog.Fatalf("No node config present for node group id `%s` error: %v", spec.name, err)

if err != nil {
return nil, fmt.Errorf("failed to parse cluster config error: %s", err)
}
json.Unmarshal([]byte(string(clusterConfigEnv)), &clusterConfig)
Copy link
Member

Choose a reason for hiding this comment

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

clusterConfigEnv already is a []byte, so no need to convert to string and back to []byte. https://pkg.go.dev/encoding/base64#Encoding.DecodeString

Suggested change
json.Unmarshal([]byte(string(clusterConfigEnv)), &clusterConfig)
json.Unmarshal(clusterConfigEnv, &clusterConfig)

Also please add error handling for failed json.Unmarshal().

StartAfterCreate := true
opts := hcloud.ServerCreateOpts{
Name: newNodeName(n),
UserData: n.manager.cloudInit,
UserData: string(cloudInit),
Copy link
Member

Choose a reason for hiding this comment

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

cloudInit is already a string

Suggested change
UserData: string(cloudInit),
UserData: cloudInit,

@Silvest89 Silvest89 force-pushed the hetzner-provider-multi-node-pools-support branch from aa4ea0e to 412d8e1 Compare October 18, 2023 10:26
@Silvest89
Copy link
Contributor Author

@apricote
I've pushed your suggestions! :) Should be alright now

@Silvest89 Silvest89 force-pushed the hetzner-provider-multi-node-pools-support branch from 412d8e1 to e1408ed Compare October 19, 2023 17:02
@Silvest89 Silvest89 requested a review from apricote October 19, 2023 17:46
@apricote
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 20, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apricote, Silvest89

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 20, 2023
@k8s-ci-robot k8s-ci-robot merged commit f1a5ffe into kubernetes:master Oct 20, 2023
4 checks passed
@bgervan
Copy link

bgervan commented Oct 28, 2023

Am I seeing correctly that it is not included in the latest version yet?

@Shubham82
Copy link
Contributor

yes, @bgervan these changes weren't include in the latest version yet i.e. CA v1.28. This feature will be available in CA v1.29.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cluster-autoscaler area/provider/hetzner Issues or PRs related to Hetzner provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants