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 providerID handling + label sanitizing #46

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hrak
Copy link
Contributor

@hrak hrak commented May 5, 2023

This PR changes the way the CloudStack Cloud Controller Manager handles kubelet providerID into a more standardized way that is more common around several other CCM's like the Openstack or vSphere one. The changes were needed to make node labels work again.

The providerID is configured by either setting the kubelet command line flag --provider-id (deprecated) or using the providerID setting in kubelet config yaml. The format of the value is <providername>://region/instance-id so in case of CloudStack for a platform without region f.e. : cloudstack:///4e7689bc-99ea-43d8-8c37-5ff511c01665. With the region being parsed from the providerID, this PR also addresses #39

It also implements the two interface methods InstanceShutdownByProviderID and InstanceShutdown.

And it fixes the way node labels are sanitized. The old regex approach would in some cases strip off allowed characters, for example zone name Development-Internal would turn into DevelopmentInternal, although the - is allowed in label values. The new approach converts all chars that are not allowed in a label value to underscores:

Development-Internal -> Development-Internal
Small Instance (4 GB / 2 CPU) -> Small_Instance__4_GB___2_CPU

hrak added 3 commits April 17, 2023 13:10
- convert providerID to instanceID where needed
- rename provider from external-cloudstack to cloudstack
- implement InstanceShutdown and InstanceShutdownByProviderID
@hrak
Copy link
Contributor Author

hrak commented May 5, 2023

I realize that these changes should probably be reflected in the README. Will address that shortly.

vishesh92
vishesh92 previously approved these changes May 22, 2024
Copy link
Member

@vishesh92 vishesh92 left a comment

Choose a reason for hiding this comment

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

code lgtm

@weizhouapache weizhouapache added this to the 1.1.0 milestone May 22, 2024
@weizhouapache
Copy link
Member

@hrak @vishesh92
it looks this requires some other changes like
Leaseweb@323b493

@vishesh92 vishesh92 dismissed their stale review June 6, 2024 13:06

Seeing errors with these changes.

@vishesh92
Copy link
Member

I am seeing the below errors after applying the changes. I am not sure about the root cause.
I launched a CKS cluster and updated the image.

E0606 13:02:31.408425       1 node_lifecycle_controller.go:149] error checking if node k8s-1273-node-18f3588c91c exists: ProviderID "cloudstack://2d35066b-a8e4-4c2a-b400-256db0a7d2cd" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:36.515139       1 node_lifecycle_controller.go:149] error checking if node k8s-1273-node-18f3588c91c exists: ProviderID "cloudstack://2d35066b-a8e4-4c2a-b400-256db0a7d2cd" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:37.025198       1 node_controller.go:249] Error getting instance metadata for node addresses: ProviderID "" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:37.025248       1 node_controller.go:249] Error getting instance metadata for node addresses: ProviderID "" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:37.025255       1 node_controller.go:249] Error getting instance metadata for node addresses: ProviderID "" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:37.025261       1 node_controller.go:249] Error getting instance metadata for node addresses: ProviderID "" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:37.025267       1 node_controller.go:249] Error getting instance metadata for node addresses: ProviderID "" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:41.584449       1 node_lifecycle_controller.go:149] error checking if node k8s-1273-node-18f3588c91c exists: ProviderID "cloudstack://2d35066b-a8e4-4c2a-b400-256db0a7d2cd" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:46.648644       1 node_lifecycle_controller.go:149] error checking if node k8s-1273-node-18f3588c91c exists: ProviderID "cloudstack://2d35066b-a8e4-4c2a-b400-256db0a7d2cd" didn't match expected format "cloudstack://region/InstanceID"

@weizhouapache
Copy link
Member

I am seeing the below errors after applying the changes. I am not sure about the root cause.
I launched a CKS cluster and updated the image.

E0606 13:02:31.408425       1 node_lifecycle_controller.go:149] error checking if node k8s-1273-node-18f3588c91c exists: ProviderID "cloudstack://2d35066b-a8e4-4c2a-b400-256db0a7d2cd" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:36.515139       1 node_lifecycle_controller.go:149] error checking if node k8s-1273-node-18f3588c91c exists: ProviderID "cloudstack://2d35066b-a8e4-4c2a-b400-256db0a7d2cd" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:37.025198       1 node_controller.go:249] Error getting instance metadata for node addresses: ProviderID "" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:37.025248       1 node_controller.go:249] Error getting instance metadata for node addresses: ProviderID "" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:37.025255       1 node_controller.go:249] Error getting instance metadata for node addresses: ProviderID "" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:37.025261       1 node_controller.go:249] Error getting instance metadata for node addresses: ProviderID "" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:37.025267       1 node_controller.go:249] Error getting instance metadata for node addresses: ProviderID "" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:41.584449       1 node_lifecycle_controller.go:149] error checking if node k8s-1273-node-18f3588c91c exists: ProviderID "cloudstack://2d35066b-a8e4-4c2a-b400-256db0a7d2cd" didn't match expected format "cloudstack://region/InstanceID"
E0606 13:02:46.648644       1 node_lifecycle_controller.go:149] error checking if node k8s-1273-node-18f3588c91c exists: ProviderID "cloudstack://2d35066b-a8e4-4c2a-b400-256db0a7d2cd" didn't match expected format "cloudstack://region/InstanceID"

@vishesh92 did you change the provider name from external-cloudstack to cloudstack?

@vishesh92
Copy link
Member

Yes. I did change that. Before that pod was crashing due to wrong provider name.

@weizhouapache
Copy link
Member

Yes. I did change that. Before that pod was crashing due to wrong provider name.

According to the pr, the providerID should have 3 slashes instead of 2.

cloudstack://2d35066b should be cloudstack:///2d35066b

util.go Outdated Show resolved Hide resolved
Co-authored-by: Vishesh <[email protected]>
@vishesh92
Copy link
Member

I tested the above PR with kuberentes 1.28. It doesn't seem to be adding the zone or region labels. I assume it's because this needs some more changes in the implementation of InstancesV2 interface. Moving this PR to milestone for next release for now.

@vishesh92 vishesh92 modified the milestones: 1.1.0, 1.2.0 Jun 7, 2024
@weizhouapache weizhouapache force-pushed the main branch 2 times, most recently from 97003ba to 0dc33dd Compare June 11, 2024 08:58
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.

3 participants