-
Notifications
You must be signed in to change notification settings - Fork 83
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
Added flag to select ProviderID format for Machine #580
Added flag to select ProviderID format for Machine #580
Conversation
✔️ Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready! 🔨 Explore the source changes: c816b5b 🔍 Inspect the deploy log: https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/621f841f0c2ae6000790cbbc 😎 Browse the preview: https://deploy-preview-580--kubernetes-sigs-cluster-api-ibmcloud.netlify.app |
Region *string `json:"region,omitempty"` | ||
|
||
// Zone specifies the Power VS Service instance zone | ||
// +optional | ||
Zone *string `json:"zone,omitempty"` |
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.
keeping them optional will be challenge because is user doesn't provide and then someone set v2 as provider version this will throw an NPE, wondering if we can make these params as required fields.
what other think? @Amulyam24 @Prajyot-Parab
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.
@Karthik-K-N if required, lets setup a meeting to discuss this in detail
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 get the region and zone using the Power VS service instance id and currently its done like that we are not depending on user to provide it.
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.
I think keeping it optional would be fine as the region and zone are always being set before setting the provider ID despite the provider version used.
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 that's the case, I'm wondering if we can have these options in the status instead if it is never set by the user or if we don't take any action if user supplies them?
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.
IMO, +1 to move it as part of status, as we have internal logic to deduce their values.
util/util.go
Outdated
var ProviderIDFormat string | ||
|
||
// ProviderIDFormatV2 will set provider id to machine as ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id> | ||
const ProviderIDFormatV2 = "v2" |
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.
wondering if we can move this to pkg/options
package
main.go
Outdated
fs.StringVar( | ||
&options.PowerVSProviderIDFormat, | ||
"powervs-provider-id-fmt", | ||
"v1", | ||
"ProviderID format is used set the Provider ID format for Machine", | ||
) |
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.
this accepts any random value as of now, can we limit this to accept only v1 or v2
var PowerVSProviderIDFormat string | ||
|
||
// PowerVSProviderIDFormatV2 will set provider id to machine as ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id> | ||
const PowerVSProviderIDFormatV2 = "v2" |
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.
can we add v1 constant as well?
Review comments are being addressed in the latest commit and PR is ready for new review. |
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.
minor fmt issues, other lgtm
main.go
Outdated
@@ -18,6 +18,8 @@ package main | |||
|
|||
import ( | |||
"flag" | |||
"fmt" | |||
"k8s.io/klog/v2/klogr" |
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.
nit: move this k8s.io/klog/v2/klogr
import to down below
main.go
Outdated
@@ -68,6 +70,11 @@ func main() { | |||
|
|||
ctrl.SetLogger(klogr.New()) | |||
|
|||
if err := validateFlags(); err != nil { | |||
setupLog.Info("Flag validation failure", "error", err.Error()) |
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.
how about using Error() if they have one
main.go
Outdated
fs.StringVar( | ||
&options.PowerVSProviderIDFormat, | ||
"powervs-provider-id-fmt", | ||
"v2", |
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.
can we use options.PowerVSProviderIDFormatV2 here instead of v2?
cloud/scope/powervs_machine.go
Outdated
@@ -20,13 +20,12 @@ import ( | |||
"context" | |||
"encoding/base64" | |||
"fmt" | |||
"sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/options" |
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.
nit: move this import to down
337878c
to
a363bf5
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.
/lgtm
/approve
/retest
/hold for @Prajyot-Parab 's review
@Karthik-K-N do run |
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Karthik-K-N, mkumatag, Prajyot-Parab 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 |
/unhold |
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
/area provider/ibmcloud
Release note:
This PR introduce a flag
providerid-format
to select theProviderID
format to set to the machinev1 version will have format, this is default provider id format:
ibmpowervs://<cluster_name>/<vm_hostname>
v2 version will have format:
ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id>
When we are setting the
providerid-format
to v2, We need to explicitly run the external cloud controller manager, which will take the responsibility of setting the ProviderID for node