-
Notifications
You must be signed in to change notification settings - Fork 635
✨ feat: Implement autoscaling from zero by auto-populating AWSMachineTemplate capacity #5711
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
base: main
Are you sure you want to change the base?
✨ feat: Implement autoscaling from zero by auto-populating AWSMachineTemplate capacity #5711
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
Hi @LiangquanLi930. 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-sigs/prow repository. |
/ok-to-test |
50f8188
to
f1ee365
Compare
/test pull-cluster-api-provider-aws-e2e-blocking |
f1ee365
to
3be8f4d
Compare
01be987
to
915f55b
Compare
915f55b
to
b3850d1
Compare
/assign |
if len(awsMachineTemplate.Status.Capacity) > 0 { | ||
return ctrl.Result{}, nil | ||
} |
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.
What if the capacity is not correct? Or is the .spec.template.spec.instanceType immutable?
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.
IIUC, spec.template.spec.instanceType is immutable:
cluster-api-provider-aws/api/v1beta2/awsmachinetemplate_webhook.go
Lines 230 to 240 in 427f450
if !topology.ShouldSkipImmutabilityChecks(req, newAWSMachineTemplate) && !cmp.Equal(newAWSMachineTemplate.Spec, oldAWSMachineTemplate.Spec) { | |
if oldAWSMachineTemplate.Spec.Template.Spec.InstanceMetadataOptions == nil { | |
oldAWSMachineTemplate.Spec.Template.Spec.InstanceMetadataOptions = newAWSMachineTemplate.Spec.Template.Spec.InstanceMetadataOptions | |
} | |
if !cmp.Equal(newAWSMachineTemplate.Spec.Template.Spec, oldAWSMachineTemplate.Spec.Template.Spec) { | |
allErrs = append(allErrs, | |
field.Invalid(field.NewPath("spec", "template", "spec"), newAWSMachineTemplate, "AWSMachineTemplate.Spec is immutable"), | |
) | |
} | |
} |
The webhook enforces that spec.template.spec cannot be changed after creation, except when
topology.ShouldSkipImmutabilityChecks()
returns true (which is only for ClusterClass topology patches).
Therefore, I think the current early-return logic is correct.
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
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" | ||
) | ||
|
||
func TestAWSMachineTemplateReconciler(t *testing.T) { |
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.
Could there also be a unit test which expects actual correct values instead of just checking "capacity" is set?
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.
+1
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.
Should this also add the nodeInfo
information as described in https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md ?
that said, |
/test pull-cluster-api-provider-aws-e2e |
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.
in general this is looking good to me, i tend to agree with Christian's questions.
/test pull-cluster-api-provider-aws-e2e |
679c53a
to
3208d4c
Compare
/test pull-cluster-api-provider-aws-e2e |
@LiangquanLi930: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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-sigs/prow repository. I understand the commands that are listed here. |
3208d4c
to
5abc575
Compare
✨ Implement autoscaling from zero by auto-populating AWSMachineTemplate capacity
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR implements the Cluster API autoscaling from zero proposal for CAPA by adding a controller that automatically populates
AWSMachineTemplate.Status.Capacity
with instance type information.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:
Checklist:
Release note: