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

✨Make machine's providerID consistent with node providerID #1730

Merged
merged 1 commit into from
May 26, 2020
Merged

✨Make machine's providerID consistent with node providerID #1730

merged 1 commit into from
May 26, 2020

Conversation

alexander-demicev
Copy link
Contributor

Closes #1693

This PR makes providerID of the machine more consistent with the node's providerID. See the attached issue for more details

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 20, 2020
@k8s-ci-robot k8s-ci-robot requested review from chuckha and sethp-nr May 20, 2020 12:18
@k8s-ci-robot
Copy link
Contributor

Welcome @alexander-demichev!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-aws 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-aws has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 20, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @alexander-demichev. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 20, 2020
@randomvariable
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 20, 2020
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 20, 2020
@@ -411,7 +412,7 @@ func (r *AWSMachineReconciler) reconcileNormal(_ context.Context, machineScope *
}

// Make sure Spec.ProviderID is always set.
machineScope.SetProviderID(fmt.Sprintf("aws:////%s", instance.ID))
machineScope.SetProviderID(fmt.Sprintf("aws:///%s/%s", aws.StringValue(machineScope.AWSMachine.Spec.FailureDomain), instance.ID))
Copy link
Member

Choose a reason for hiding this comment

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

This still needs to be addressed #1730 (comment)

failureDomain := machineScope.AWSMachine.Spec.FailureDomain
if failureDomain == nil {
failureDomain = machineScope.Machine.Spec.FailureDomain
}
Copy link
Member

Choose a reason for hiding this comment

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

Now this logic and the format fmt.Sprintf("aws:///%s/%s", aws.StringValue(failureDomain) are invariant. If we move them inside the SetProviderID() func and we pass only the instance.ID we can unit test the multiple scenarios for failureDomain, e.g both empty, one empty, both filled. wdyt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, that's definitely easier to test

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 20, 2020
@@ -411,7 +410,7 @@ func (r *AWSMachineReconciler) reconcileNormal(_ context.Context, machineScope *
}

// Make sure Spec.ProviderID is always set.
machineScope.SetProviderID(fmt.Sprintf("aws:////%s", instance.ID))
machineScope.SetProviderID(instance.ID)
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to update getOrCreate to also return the current AZ based on the returned AWS calls instead of trying to rely on the AWSMachine or Machine fields having FailureDomain set, since it's an optional field on both resources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. getOrCreate will end up converting aws.instance to infrav1.instance using SDKToInstance, maybe we can add AZ to infrav1.Instance and have conversion logic in SDKToInstance ? Is this an acceptable API change?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me, I don't expect there to be any downstream consumers of that part of the API, so changes should not be an issue.

@detiber
Copy link
Member

detiber commented May 21, 2020

/milestone v0.5.4

@k8s-ci-robot k8s-ci-robot added this to the v0.5.4 milestone May 21, 2020
@@ -138,8 +139,9 @@ func (m *MachineScope) GetProviderID() string {
}

// SetProviderID sets the AWSMachine providerID in spec.
func (m *MachineScope) SetProviderID(v string) {
m.AWSMachine.Spec.ProviderID = pointer.StringPtr(v)
func (m *MachineScope) SetProviderID(instanceID, availabilityZone string) {
Copy link
Member

@enxebre enxebre May 22, 2020

Choose a reason for hiding this comment

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

I'd appreciate if we can put some units for this?

Copy link
Member

@enxebre enxebre May 22, 2020

Choose a reason for hiding this comment

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

it might seem trivial enough as to not deserve a test, but the func is actually relying in a handwritten fmt "arbitrary" format and an external given implementation for StringPtr. It’s very cheap fo us to put a unit and it becomes fairly valuable if some one considers to change the impl details in the future. Also it makes way easier to visualise at a glange what provider should look like for the different cases for someone with less context.

@enxebre
Copy link
Member

enxebre commented May 22, 2020

thanks Alex!
can we please make sure there's an appropriate release note for this?
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 22, 2020
Copy link
Member

@detiber detiber left a comment

Choose a reason for hiding this comment

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

This looks great, just need to fix up the lossy conversion for the new field in the status and then lgtm

api/v1alpha2/zz_generated.conversion.go Show resolved Hide resolved
@detiber
Copy link
Member

detiber commented May 26, 2020

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexander-demichev, detiber

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 26, 2020
@k8s-ci-robot k8s-ci-robot merged commit 13ceee9 into kubernetes-sigs:master May 26, 2020
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. 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ProviderID more consistent with kube manager cloud provider
5 participants