-
Notifications
You must be signed in to change notification settings - Fork 578
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
✨Make machine's providerID consistent with node providerID #1730
Conversation
Welcome @alexander-demichev! |
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 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. |
/ok-to-test |
controllers/awsmachine_controller.go
Outdated
@@ -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)) |
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 still needs to be addressed #1730 (comment)
controllers/awsmachine_controller.go
Outdated
failureDomain := machineScope.AWSMachine.Spec.FailureDomain | ||
if failureDomain == nil { | ||
failureDomain = machineScope.Machine.Spec.FailureDomain | ||
} |
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.
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
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.
Good idea, that's definitely easier to test
controllers/awsmachine_controller.go
Outdated
@@ -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) |
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.
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?
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.
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?
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.
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.
/milestone v0.5.4 |
@@ -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) { |
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'd appreciate if we can put some units for this?
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.
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.
thanks Alex! |
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 looks great, just need to fix up the lossy conversion for the new field in the status and then lgtm
/approve |
[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 |
Closes #1693
This PR makes
providerID
of the machine more consistent with the node'sproviderID
. See the attached issue for more details