-
Notifications
You must be signed in to change notification settings - Fork 39.4k
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
Modified providerID to unified format #81859
Modified providerID to unified format #81859
Conversation
Hi @bells17. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bells17 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cc @andrewsykim |
Sorry before a review, I fixed typo I found. |
providerID := node.Spec.ProviderID | ||
if providerID == "" { | ||
var err error | ||
providerID, err = instances.InstanceID(context.TODO(), types.NodeName(node.Name)) | ||
providerID, err = cloudprovider.GetInstanceProviderID(context.TODO(), cloud, types.NodeName(node.Name)) |
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 is originally calling InstanceID
for legacy reasons. It only applies if a provider ID isn't already set which shouldn't be the case.
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.
@andrewsykim Thank you for commenting.
This is originally calling InstanceID for legacy reasons. It only applies if a provider ID isn't already set which shouldn't be the case.
I understand. But I think if the situation that InstanceID can get an instance id, cloud.ProviderName can get a provider name.
because of cloud.ProviderName is a very simple method what return a provider name string only.
So if the situation that a provider id can use <provider name>://<instance id>
, I think a provider id should be a unified format.
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.
Sorry I don't quite follow the reasoning yet.
The main reason for actually calling InstanceID
here is because (for legacy reasons) it can actually return the cloudprovider.InstanceNotFound
error which we check for below. Some providers still depend on that behavior IIRC
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.
@andrewsykim Ah...I see. Sorry, I mistake.
I fixed my code 😅
providerID := node.Spec.ProviderID | ||
if providerID == "" { | ||
var err error | ||
providerID, err = instances.InstanceID(context.TODO(), types.NodeName(node.Name)) |
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.
Oddly I think using the raw instance type is expected here. See how the AWS provider parses this for example in https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/legacy-cloud-providers/aws/instances.go#L50-L91. I agree it's confusing and not ideal, but I think trying to force the format <provider>://<instance-id>
could break some implementations.
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.
@andrewsykim Um...Sorry, I don't understand.
It looks support <provider>://<instance-id>
format because bellow:
kubernetes/staging/src/k8s.io/legacy-cloud-providers/aws/instances.go
Lines 61 to 72 in 41049fd
if !strings.HasPrefix(s, "aws://") { // Assume a bare aws volume id (vol-1234...) // Build a URL with an empty host (AZ) s = "aws://" + "/" + "/" + s } url, err := url.Parse(s) if err != nil { return "", fmt.Errorf("Invalid instance name (%s): %v", name, err) } if url.Scheme != "aws" { return "", fmt.Errorf("Invalid scheme for AWS instance (%s)", name) } kubernetes/staging/src/k8s.io/legacy-cloud-providers/aws/instances.go
Lines 52 to 53 in 41049fd
// * aws:///<zone>/<awsInstanceId> // * aws:////<awsInstanceId>
And other legacy cloud providers looks support <provider>://<instance-id>
too:
azure
azureNodeProviderIDRE = regexp.MustCompile(`^azure:///subscriptions/(?:.*)/resourceGroups/(?:.*)/providers/Microsoft.Compute/(?:.*)`) kubernetes/staging/src/k8s.io/legacy-cloud-providers/azure/azure_wrap.go
Lines 326 to 330 in 41049fd
// IsNodeUnmanagedByProviderID returns true if the node is not managed by Azure cloud provider. // All managed node's providerIDs are in format 'azure:///subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Compute/.*' func (az *Cloud) IsNodeUnmanagedByProviderID(providerID string) bool { return !azureNodeProviderIDRE.Match([]byte(providerID)) }
gcp
kubernetes/staging/src/k8s.io/legacy-cloud-providers/gce/gce_util.go
Lines 206 to 215 in 41049fd
// splitProviderID splits a provider's id into core components. // A providerID is build out of '${ProviderName}://${project-id}/${zone}/${instance-name}' // See cloudprovider.GetInstanceProviderID. func splitProviderID(providerID string) (project, zone, instance string, err error) { matches := providerIDRE.FindStringSubmatch(providerID) if len(matches) != 4 { return "", "", "", errors.New("error splitting providerID") } return matches[1], matches[2], matches[3], nil }
vsphere
kubernetes/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere_util.go
Lines 615 to 619 in 41049fd
// ProviderID is UUID for nodes v1.9.3+ if node.VMUUID == GetUUIDFromProviderID(providerID) || node.NodeName == providerID { nodeName = node.NodeName break } kubernetes/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere_util.go
Lines 628 to 630 in 41049fd
func GetUUIDFromProviderID(providerID string) string { return strings.TrimPrefix(providerID, ProviderPrefix) }
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.
@andrewsykim Hi, as wrote above that looks like InstanceExistsByProviderID method in AWS and other providers support <provider>://<instance-id>
format.
So maybe provider ID format could be unified.
But, shouldn't provider ID format be unified?
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.
Ideally it should, but there are some contraints here because we have to support legacy formats of the provider ID.
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.
Thank you. I understand.
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@bells17: PR needs rebase. 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. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Modified providerID to unified format.
I think instances.InstanceExistsByProviderID's providerID is needed
<provider name>://<instance id>
format.But currently 2 patterns exists like below:
<provider name>://<instance id>
<instance id>
e.g.:
Which issue(s) this PR fixes:
Special notes for your reviewer:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: