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

Add zone-id topology label to nodes #855

Merged
merged 2 commits into from Mar 4, 2024
Merged

Conversation

mmerkes
Copy link
Contributor

@mmerkes mmerkes commented Mar 3, 2024

What type of PR is this?
/kind feature

What this PR does / why we need it:
As part of 1.30, we added the ability to add custom labels from the cloud provider to nodes, and AWS customers are looking for a way to label nodes with a zone ID, which will be consistent across account. That label is added here.\

Which issue(s) this PR fixes:

Fixes #300

Special notes for your reviewer:
Added a new e2e case for this change.

Does this PR introduce a user-facing change?:

Label nodes with zone-id topology label. AWS customers can use the `topology.k8s.aws/zone-id`
label on their nodes to associate observations across AWS accounts in a consistent way.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 3, 2024
@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 3, 2024
@mmerkes
Copy link
Contributor Author

mmerkes commented Mar 3, 2024

/triage accepted
/assign @cartermckinnon

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 3, 2024
@olemarkus
Copy link
Member

Generally lgtm, but may want to split the deps upgrade as a separate PR. At least clean up/fixup the "merge" commit.

@mmerkes
Copy link
Contributor Author

mmerkes commented Mar 4, 2024

Generally lgtm, but may want to split the deps upgrade as a separate PR.

@olemarkus That's fair. I put up another PR to separate it out. I can remove the changes here once that's merged.

Comment on lines 1 to 15
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Formatting got weird here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya, I just copied the other test file. I'll make it nicer when I rebase.

@@ -63,6 +64,25 @@ func (c *Cloud) InstanceShutdown(ctx context.Context, node *v1.Node) (bool, erro
return c.InstanceShutdownByProviderID(ctx, providerID)
}

func (c *Cloud) getAdditionalLabels(zoneName string) (map[string]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function could just add the zone ID label to an existing map, probably cleaner in the long run as more labels are set:

Suggested change
func (c *Cloud) getAdditionalLabels(zoneName string) (map[string]string, error) {
func (c *Cloud) addLabelZoneID(labels map[string]string, zoneName string) (error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya, I had considered that, but I preferred to keep encapsulate creating the additional labels in it's own method to keep the InstanceMetadata method as dumb as possible.

That being said, I could still pull out zone ID logic into it's own method and create one as you suggest, but I left the restructuring to when we have more than a single label.

That being said, I don't feel that strongly here if you do. One downside to having a single method for labels that calls out to other methods is that the list of inputs could potentially grow awkwardly over time.

Copy link
Member

Choose a reason for hiding this comment

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

Why not

Suggested change
func (c *Cloud) getAdditionalLabels(zoneName string) (map[string]string, error) {
func (c *Cloud) getZoneIDByZoneName(zoneName string) (string, error) {

This would make it more in line with the other functions. And since only one label is being returned anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tx for the discussion. I did kind of a mix of all of this. I moved the zone logic out to the zones file so that this is just getting a value and setting the label.

Includes node e2e test to verify that the label is actually applied
Copy link
Contributor

@cartermckinnon cartermckinnon left a comment

Choose a reason for hiding this comment

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

one nit, but lgtm

pkg/providers/v1/zones.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 4, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cartermckinnon

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 Mar 4, 2024
@olemarkus
Copy link
Member

Remember to change the PR description.

@cartermckinnon
Copy link
Contributor

/retest

Co-authored-by: Carter <cartermckinnon@gmail.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 4, 2024
@cartermckinnon
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 4, 2024
@k8s-ci-robot k8s-ci-robot merged commit 4dd7719 into kubernetes:master Mar 4, 2024
13 checks passed
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. 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Availability Zone ID topology labels
4 participants