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

✨ Deprecate NoCloudProvider and add CloudProviderEnabled #2108

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

adilGhaffarDev
Copy link
Member

@adilGhaffarDev adilGhaffarDev commented Nov 22, 2024

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

@metal3-io-bot metal3-io-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 22, 2024
@adilGhaffarDev adilGhaffarDev force-pushed the deprecate-noCloudProvider/adil branch from 7f7a168 to 18178b7 Compare November 22, 2024 08:11
@adilGhaffarDev
Copy link
Member Author

cc @lentzi90

@tuminoid
Copy link
Member

cc @lentzi90

Btw use
/cc @lentzi90
So instead of just pinging him, it actually requests review.

Copy link
Member

@lentzi90 lentzi90 left a 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.

api/v1beta1/metal3cluster_types.go Outdated Show resolved Hide resolved
@adilGhaffarDev adilGhaffarDev force-pushed the deprecate-noCloudProvider/adil branch from 18178b7 to 476a183 Compare January 21, 2025 08:33
@metal3-io-bot metal3-io-bot added needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 21, 2025
@adilGhaffarDev adilGhaffarDev force-pushed the deprecate-noCloudProvider/adil branch from 476a183 to 8fc1141 Compare January 21, 2025 08:37
@metal3-io-bot metal3-io-bot removed the needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. label Jan 21, 2025
@adilGhaffarDev adilGhaffarDev force-pushed the deprecate-noCloudProvider/adil branch from 8fc1141 to 5cd0acc Compare January 21, 2025 11:02
Copy link
Member

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

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

/approve

@metal3-io-bot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 21, 2025
@tuminoid
Copy link
Member

/test metal3-centos-e2e-integration-test-main metal3-ubuntu-e2e-integration-test-main

Copy link
Member

@tuminoid tuminoid left a 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?

api/v1beta1/metal3cluster_types.go Outdated Show resolved Hide resolved
api/v1beta1/metal3cluster_types.go Show resolved Hide resolved
docs/api.md Show resolved Hide resolved
examples/cluster/cluster.yaml Outdated Show resolved Hide resolved
examples/clusterctl-templates/clusterctl-cluster.yaml Outdated Show resolved Hide resolved
examples/templates/clusterclass.yaml Outdated Show resolved Hide resolved
@adilGhaffarDev adilGhaffarDev force-pushed the deprecate-noCloudProvider/adil branch from 5cd0acc to c78073b Compare January 21, 2025 13:20
@adilGhaffarDev
Copy link
Member Author

Do we really need to put that comment everywhere?

Perhaps not, I have removed it from test yamls and some other places where it was not necessary.

@tuminoid
Copy link
Member

Thanks, LGTM.

Let's run tests for it.
/test metal3-centos-e2e-integration-test-main metal3-ubuntu-e2e-integration-test-main

@adilGhaffarDev adilGhaffarDev force-pushed the deprecate-noCloudProvider/adil branch from c78073b to a16844f Compare January 21, 2025 15:38
@adilGhaffarDev
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main metal3-ubuntu-e2e-integration-test-main

1 similar comment
@adilGhaffarDev
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main metal3-ubuntu-e2e-integration-test-main

@tuminoid
Copy link
Member

Should we make this PR title sparkles? ✨

@adilGhaffarDev adilGhaffarDev changed the title 🌱 Deprecate NoCloudProvider and add CloudProviderEnabled ✨ Deprecate NoCloudProvider and add CloudProviderEnabled Jan 22, 2025
Copy link
Member

@mquhuy mquhuy left a comment

Choose a reason for hiding this comment

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

Nits.

@@ -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 {
Copy link
Member

@mquhuy mquhuy Jan 22, 2025

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?

Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

api/v1beta1/metal3cluster_webhook.go Show resolved Hide resolved
@adilGhaffarDev adilGhaffarDev force-pushed the deprecate-noCloudProvider/adil branch from a16844f to 4a79c35 Compare January 22, 2025 09:05
Copy link
Member

@mquhuy mquhuy left a 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.

@@ -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 {
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

if oldM3C != nil {
// Validate cloudProviderEnabled
if c.Spec.CloudProviderEnabled != nil && oldM3C.Spec.NoCloudProvider != nil {
if !*c.Spec.CloudProviderEnabled && !*oldM3C.Spec.NoCloudProvider {
Copy link
Member

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


// Validate noCloudProvider
if c.Spec.NoCloudProvider != nil && oldM3C.Spec.CloudProviderEnabled != nil {
if !*c.Spec.NoCloudProvider && !*oldM3C.Spec.CloudProviderEnabled {
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@adilGhaffarDev adilGhaffarDev force-pushed the deprecate-noCloudProvider/adil branch from 4a79c35 to 5e733bd Compare January 22, 2025 10:37
@mquhuy
Copy link
Member

mquhuy commented Jan 22, 2025

/test metal3-centos-e2e-integration-test-main
/test metal3-ubuntu-e2e-integration-test-main

@tuminoid
Copy link
Member

/retest
Network flake

@mquhuy
Copy link
Member

mquhuy commented Jan 23, 2025

LGTM

Copy link
Member

@tuminoid tuminoid left a comment

Choose a reason for hiding this comment

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

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 23, 2025
@metal3-io-bot metal3-io-bot merged commit b4480cf into metal3-io:main Jan 23, 2025
18 checks passed
@metal3-io-bot metal3-io-bot added this to the CAPM3 - v1.10 milestone Jan 23, 2025
@metal3-io-bot metal3-io-bot deleted the deprecate-noCloudProvider/adil branch January 23, 2025 10:31
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. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants