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: fix gateway being required for IPAddress #8506

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

schrej
Copy link
Member

@schrej schrej commented Apr 11, 2023

What this PR does / why we need it:
The validating webhook for IPAddress ensures that .spec.gateway is a valid IP address. This check fails if the field is empty, making it a required field. Since it is defined as omitempty it should be optional.

This PR wraps it with an is-empty check to allow the field to be empty.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
related to kubernetes-sigs/cluster-api-ipam-provider-in-cluster#70
Fixes #8536

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 11, 2023
@schrej schrej force-pushed the ipam-fix-required-gateway branch from f5e6246 to e498306 Compare April 11, 2023 09:03
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

/lgtm

I don't have any expertise in the IPAM provider, but this change seems to make sense.

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

LGTM label has been added.

Git tree hash: b1c1c5010355868c45260ded50512732577c365f

@schrej schrej force-pushed the ipam-fix-required-gateway branch from e498306 to 450658e Compare April 12, 2023 10:15
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 12, 2023
@schrej schrej requested a review from vincepri April 12, 2023 10:15
@schrej
Copy link
Member Author

schrej commented Apr 13, 2023

there is an alternative implementation here, that makes gateway required for ipv4, and allows it to be optional with ipv6: #8525
We should decide which one we want to use.

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 13, 2023
@sbueringer
Copy link
Member

@schrej can you maybe open an issue for discussion? Then we can close/open PRs according to consensus

@sbueringer
Copy link
Member

sbueringer commented Apr 26, 2023

@schrej let's add "Fixes #8536" to the PR description

@schrej
Copy link
Member Author

schrej commented Apr 26, 2023

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 26, 2023
@schrej schrej force-pushed the ipam-fix-required-gateway branch from 450658e to d9a6aa7 Compare April 26, 2023 13:41
@sbueringer
Copy link
Member

/lgtm

Maybe you want to do a quick manual test somewhere to see if it works as expected (as we don't have e2e test coverage with IPAM)

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

LGTM label has been added.

Git tree hash: 4118c42282f5fa0f41d6c98d36851a0e5a1d7f55

Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

Maybe you want to do a quick manual test somewhere to see if it works as expected (as we don't have e2e test coverage with IPAM)

Maybe a stupid question - really don't know much about the IPAM implementations - how difficult would it be to set up an e2e test for this API? Could we create a simplified provider or use an existing one?

@schrej
Copy link
Member Author

schrej commented Apr 26, 2023

Maybe you want to do a quick manual test somewhere to see if it works as expected (as we don't have e2e test coverage with IPAM)

Maybe a stupid question - really don't know much about the IPAM implementations - how difficult would it be to set up an e2e test for this API? Could we create a simplified provider or use an existing one?

Depends on what's considered end-to-end for this API at this level. Imo we need to ensure that the two IPAM resources work as expected/defined, so IPAM and infra providers can rely on it.

If we want to include the apiserver in the scope, we could use envtest - but I don't know if and how webhooks can be tested with that. For now we have unit tests for what those webhooks do.
I don't see benefit in having a simplified provider (or using an existing one) since CAPI doesn't implement any behaviour for those resources. It just specifies how the resources look like, and we describe how they are supposed to be used. But it's on ipam providers to implement and test that.

The ipam providers should of course have e2e tests with these resources (we currently do not, since envtest doesn't run webhooks). Same goes for infra providers that want to support the contract.

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve

Based on the discussion in the related issue

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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 26, 2023
@k8s-ci-robot k8s-ci-robot merged commit e7ba6c8 into kubernetes-sigs:main Apr 26, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.5 milestone Apr 26, 2023
@christianang
Copy link
Contributor

I'd be interested in this being backported to release 1.4 if we could.

@vincepri
Copy link
Member

/cherry-pick release-1.4

@k8s-infra-cherrypick-robot

@vincepri: cannot checkout release-0.14: error checking out release-0.14: exit status 1. output: error: pathspec 'release-0.14' did not match any file(s) known to git

In response to this:

/cherry-pick release-0.14

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-infra-cherrypick-robot

@vincepri: new pull request created: #8574

In response to this:

/cherry-pick release-1.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@schrej schrej deleted the ipam-fix-required-gateway branch April 26, 2023 19:13
@johannesfrey
Copy link
Contributor

/area ipam

@k8s-ci-robot k8s-ci-robot added the area/ipam Issues or PRs related to ipam label Jun 16, 2023
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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IPAddress.spec.gateway should be optional for IPv6 and maybe for IPv4
8 participants