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

🌱 ipam: add spec.clusterName to IPAddressClaim #10182

Merged

Conversation

schrej
Copy link
Member

@schrej schrej commented Feb 20, 2024

What this PR does / why we need it:
Adds a spec.clusterName property to IPAddressClaims to allow properly referencing the Cluster to which the claim belongs. This is required for pausing claim reconciliation when the cluster is paused, which in turn is necessary for clusterctl move support.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Discussed in #9883

/area ipam

@k8s-ci-robot k8s-ci-robot added area/ipam Issues or PRs related to ipam size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 20, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 20, 2024
Comment on lines 79 to 89
if _, ok := dst.ObjectMeta.Labels["cluster.x-k8s.io/cluster-name"]; !ok {
if dst.ObjectMeta.Annotations == nil {
dst.ObjectMeta.Annotations = map[string]string{}
}
dst.ObjectMeta.Annotations["conversion.cluster.x-k8s.io/cluster-name-label-set"] = "false"
}
Copy link
Member Author

@schrej schrej Feb 20, 2024

Choose a reason for hiding this comment

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

This is done to make the fuzzy conversion tests happy. I preferred this over an annotation with a json representation of the old object, but can switch to that "standard" approach as well.

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer if we use the standard approach here for consistency

Copy link
Member

Choose a reason for hiding this comment

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

Or is it a use case that we intentionally want to cover that controllers written against v1alpha1 might be able to get the cluster-name from the annotation? (which would only work if the spec.clusterName field is set)

Wondering if these controllers can simply upgrade to v1beta1 instead? Or does somebody already rely on the label?

Copy link
Member

Choose a reason for hiding this comment

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

I guess if we don't have to support some use cases around this I would prefer to just go with the standard conversion approach and avoid additional complexity.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the idea was to support old providers. If we don't want that we can also just be forward-compatible instead. I'd be fine with just keeping the annotation when converting old to new, but fuzzy testing is unhappy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we keep it this way? Since this is still considered experimental API we can probably remove v1alpha1 rather soon anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I'll get back to it to take another look.

The way the apiserver is working today we'll never going to be able to actually drop v1alpha1 & the corresponding conversion (just set served: false)
(xref: #10051 (comment))

Copy link
Member Author

@schrej schrej Apr 17, 2024

Choose a reason for hiding this comment

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

Ouch, ok. Well, then let me know if you're fine with this approach or whether I should switch to the regular one. I guess once we've set it to served: false we no longer need to update conversion for newer changes?

Maybe we can also just always set it and adapt the tests so they're fine with that.

Copy link
Member

@sbueringer sbueringer Apr 29, 2024

Choose a reason for hiding this comment

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

Discussed this with Jakob here: https://kubernetes.slack.com/archives/C8TSNPY4T/p1714405639788599

Overall we will go the way with the additional annotation. The problem is that the annotation and the funcs we usually use doesn't cover metadata. So we can't use it to backup/restore the cluster-name. But even if we could use it to backup/restore the cluster-name label, we wouldn't want to do it. If someone modifies the cluster-name label on the v1alpha1 type we don't want to preserve the value that that label might have had before the conversion on the v1beta1 type.

Copy link
Member

@mcbenjemaa mcbenjemaa left a comment

Choose a reason for hiding this comment

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

This is okay,
but I don't see the part where the claim pauses the reconciliation if the cluster is paused

my bad, I got confused sometimes.
after this is merged and released, we need to support this field in the ipam providers.

@mcbenjemaa
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Feb 21, 2024
@schrej schrej force-pushed the ipam-ipaddressclaim-cluster-name branch from 0cb1e43 to b54469d Compare March 25, 2024 11:49
@schrej schrej force-pushed the ipam-ipaddressclaim-cluster-name branch from b54469d to dbc96ca Compare April 29, 2024 16:05
@schrej schrej force-pushed the ipam-ipaddressclaim-cluster-name branch from dbc96ca to 0498a29 Compare April 29, 2024 16:17
@schrej schrej force-pushed the ipam-ipaddressclaim-cluster-name branch from 0498a29 to bb75a9f Compare April 29, 2024 16:24
@sbueringer
Copy link
Member

Thank you very much!

/lgtm

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

LGTM label has been added.

Git tree hash: cb301a63ac3fb264c7b93042a0eaac5b32d5e9dc

@sbueringer sbueringer added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Apr 29, 2024
@sbueringer
Copy link
Member

/assign @chrischdi

For a sanity check

@chrischdi
Copy link
Member

/approve

Looks good, thanks

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi

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 Apr 30, 2024
@sbueringer
Copy link
Member

/lgtm

Accidentally dropped it when adding the squash label

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

LGTM label has been added.

Git tree hash: cb301a63ac3fb264c7b93042a0eaac5b32d5e9dc

@k8s-ci-robot k8s-ci-robot merged commit c6e5706 into kubernetes-sigs:main Apr 30, 2024
22 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.8 milestone Apr 30, 2024
@schrej schrej deleted the ipam-ipaddressclaim-cluster-name branch April 30, 2024 10:17
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/ipam Issues or PRs related to ipam cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants