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

Added flag to select ProviderID format for Machine #580

Merged
merged 2 commits into from
Mar 2, 2022

Conversation

Karthik-K-N
Copy link
Contributor

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

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:


This PR introduce a flag providerid-format to select the ProviderID format to set to the machine

v1 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

@k8s-ci-robot k8s-ci-robot added area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 1, 2022
@netlify
Copy link

netlify bot commented Mar 1, 2022

✔️ 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

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 1, 2022
@Karthik-K-N
Copy link
Contributor Author

/cc @mkumatag @Prajyot-Parab

Comment on lines 80 to 84
Region *string `json:"region,omitempty"`

// Zone specifies the Power VS Service instance zone
// +optional
Zone *string `json:"zone,omitempty"`
Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Contributor

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.

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
util/util.go Outdated
Comment on lines 29 to 32
var ProviderIDFormat string

// ProviderIDFormatV2 will set provider id to machine as ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id>
const ProviderIDFormatV2 = "v2"
Copy link
Member

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
Comment on lines 215 to 226
fs.StringVar(
&options.PowerVSProviderIDFormat,
"powervs-provider-id-fmt",
"v1",
"ProviderID format is used set the Provider ID format for Machine",
)
Copy link
Member

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"
Copy link
Member

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?

@Karthik-K-N
Copy link
Contributor Author

Review comments are being addressed in the latest commit and PR is ready for new review.

Copy link
Member

@mkumatag mkumatag left a 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"
Copy link
Member

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())
Copy link
Member

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",
Copy link
Member

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?

@@ -20,13 +20,12 @@ import (
"context"
"encoding/base64"
"fmt"
"sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/options"
Copy link
Member

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

Copy link
Member

@mkumatag mkumatag left a 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

@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 Mar 2, 2022
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 2, 2022
@Prajyot-Parab
Copy link
Contributor

@Karthik-K-N do run make generate-go-conversions-core target command, let me know if it generates new changes to be pushed else PR changes lgtm!

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 2, 2022
Copy link
Contributor

@Prajyot-Parab Prajyot-Parab left a comment

Choose a reason for hiding this comment

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

/lgtm

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

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

@mkumatag mkumatag added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Mar 2, 2022
@mkumatag
Copy link
Member

mkumatag commented Mar 2, 2022

/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 Mar 2, 2022
@k8s-ci-robot k8s-ci-robot merged commit 78b9d0e into kubernetes-sigs:main Mar 2, 2022
@Karthik-K-N Karthik-K-N deleted the add-providerid-flag branch July 12, 2022 06:40
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/provider/ibmcloud Issues or PRs related to ibmcloud provider 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/L Denotes a PR that changes 100-499 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