-
Notifications
You must be signed in to change notification settings - Fork 101
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
✨ Deprecate NoCloudProvider and add CloudProviderEnabled #2108
✨ Deprecate NoCloudProvider and add CloudProviderEnabled #2108
Conversation
7f7a168
to
18178b7
Compare
cc @lentzi90 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
I think we need to add some validation or other logic to make sure we don't end up in confusing situations where these two contradict each other. Do you think it is possible to do this and also add a testcase for it?
I'm not sure if it is best to do this in the validating webhook or if we can somehow detect later which one of them were set explicitly.
18178b7
to
476a183
Compare
476a183
to
8fc1141
Compare
8fc1141
to
5cd0acc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lentzi90 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 |
/test metal3-centos-e2e-integration-test-main metal3-ubuntu-e2e-integration-test-main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits.
Do we really need to put that comment everywhere?
config/crd/bases/infrastructure.cluster.x-k8s.io_metal3clusters.yaml
Outdated
Show resolved
Hide resolved
config/crd/bases/infrastructure.cluster.x-k8s.io_metal3clustertemplates.yaml
Outdated
Show resolved
Hide resolved
test/e2e/data/infrastructure-metal3/bases/cluster/cluster-with-kcp.yaml
Outdated
Show resolved
Hide resolved
test/e2e/data/infrastructure-metal3/bases/clusterclass-cluster/cluster-with-kcp.yaml
Outdated
Show resolved
Hide resolved
5cd0acc
to
c78073b
Compare
Perhaps not, I have removed it from test yamls and some other places where it was not necessary. |
Thanks, LGTM. Let's run tests for it. |
c78073b
to
a16844f
Compare
/test metal3-centos-e2e-integration-test-main metal3-ubuntu-e2e-integration-test-main |
1 similar comment
/test metal3-centos-e2e-integration-test-main metal3-ubuntu-e2e-integration-test-main |
Should we make this PR title sparkles? ✨ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits.
api/v1beta1/metal3cluster_webhook.go
Outdated
@@ -68,6 +74,79 @@ func (c *Metal3Cluster) validate() error { | |||
) | |||
} | |||
|
|||
if c.Spec.CloudProviderEnabled != nil && c.Spec.NoCloudProvider != nil { | |||
if !*c.Spec.CloudProviderEnabled && !*oldM3C.Spec.NoCloudProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can merge the two ifs in this block to if *c.Spec.CloudProviderEnabled == *oldM3C.Spec.NoCloudProvider
, and what if oldM3C == nil
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, this is a mistake it should be
if !*c.Spec.CloudProviderEnabled && !*c.Spec.NoCloudProvider {
Let me fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
a16844f
to
4a79c35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Still some nits.
Honestly I think it would be best if you could put this repetitive logic into a function, but that's up to you.
api/v1beta1/metal3cluster_webhook.go
Outdated
@@ -68,6 +74,79 @@ func (c *Metal3Cluster) validate() error { | |||
) | |||
} | |||
|
|||
if c.Spec.CloudProviderEnabled != nil && c.Spec.NoCloudProvider != nil { | |||
if !*c.Spec.CloudProviderEnabled && !*c.Spec.NoCloudProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if !*c.Spec.CloudProviderEnabled && !*c.Spec.NoCloudProvider
and if *c.Spec.CloudProviderEnabled && *c.Spec.NoCloudProvider
can be combined to if *c.Spec.CloudProviderEnabled == *c.Spec.NoCloudProvider
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
api/v1beta1/metal3cluster_webhook.go
Outdated
if oldM3C != nil { | ||
// Validate cloudProviderEnabled | ||
if c.Spec.CloudProviderEnabled != nil && oldM3C.Spec.NoCloudProvider != nil { | ||
if !*c.Spec.CloudProviderEnabled && !*oldM3C.Spec.NoCloudProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. if *c.Spec.CloudProviderEnabled == *oldM3C.Spec.NoCloudProvider
api/v1beta1/metal3cluster_webhook.go
Outdated
|
||
// Validate noCloudProvider | ||
if c.Spec.NoCloudProvider != nil && oldM3C.Spec.CloudProviderEnabled != nil { | ||
if !*c.Spec.NoCloudProvider && !*oldM3C.Spec.CloudProviderEnabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
Signed-off-by: Muhammad Adil Ghaffar <[email protected]>
4a79c35
to
5e733bd
Compare
/test metal3-centos-e2e-integration-test-main |
/retest |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
What this PR does / why we need it:
Deprecate NoCloudProvider add CloudProviderEnabled, and set the default value of CloudProviderEnabled to true.
NoCloudProvider was bool and defaulted to false whenever it was accessed. This PR is changing both NoCloudProvider and adding CloudProviderEnabled to *bool so we can easily see if the user changes the value. We need to check if the value is changed by the user or not to check the conflict between these variables.
We are setting the default value of CloudProviderEnabled to true because this was the default behavior of NoCloudProvider in CAPM3 when it was added.
There is a plan to fix this defaulting when we remove NoCloudProvider completely. Check the linked issue.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Part of #2255