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
[OCPCLOUD-778] Add support for autoscaling to/from zero #112
[OCPCLOUD-778] Add support for autoscaling to/from zero #112
Conversation
@@ -9,6 +9,7 @@ require ( | |||
github.com/Azure/go-autorest/autorest/to v0.3.0 | |||
github.com/Azure/go-autorest/autorest/validation v0.2.0 // indirect | |||
github.com/ghodss/yaml v1.0.0 |
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 be in the vendor commit?
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.
Fixed
|
||
// This file was copied from | ||
// https://github.com/openshift/kubernetes-autoscaler/blob/95d5f0927b9347635f1720d6748503415e6921cb/cluster-autoscaler/cloudprovider/azure/azure_instance_types.go | ||
// // https://github.com/kubernetes/kubernetes/issues/79384 |
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.
extra "//"?
can we update all commits to |
units won't pass since there's nothing setting up the environment for envTest yet |
}, nil | ||
} | ||
|
||
func providerSpecFromMachine(in *machineproviderv1.AzureMachineProviderSpec) (machinev1.ProviderSpec, error) { |
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.
Is there any exported method in the actuator machine controller we can reuse 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.
Not exported, but it does already exist in the tests
cluster-api-provider-azure/pkg/cloud/azure/actuators/machine_scope_test.go
Lines 42 to 50 in d80999f
func providerSpecFromMachine(in *machineproviderv1.AzureMachineProviderSpec) (*machinev1.ProviderSpec, error) { | |
bytes, err := json.Marshal(in) | |
if err != nil { | |
return nil, err | |
} | |
return &machinev1.ProviderSpec{ | |
Value: &runtime.RawExtension{Raw: bytes}, | |
}, nil | |
} |
cluster-api-provider-azure/pkg/cloud/azure/actuators/machine/actuator_test.go
Lines 69 to 77 in d80999f
func providerSpecFromMachine(in *machineproviderv1.AzureMachineProviderSpec) (*machinev1.ProviderSpec, error) { | |
bytes, err := yaml.Marshal(in) | |
if err != nil { | |
return nil, err | |
} | |
return &machinev1.ProviderSpec{ | |
Value: &runtime.RawExtension{Raw: bytes}, | |
}, nil | |
} |
a7c8e80
to
3e499da
Compare
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.
All comments fixed
I've added the make test
unit which has the external binaries for env test downloaded as part of it, just need to make this run in CI and should be good! (I copied the scripts from the AWS one merged in openshift/cluster-api-provider-aws#289
}, nil | ||
} | ||
|
||
func providerSpecFromMachine(in *machineproviderv1.AzureMachineProviderSpec) (machinev1.ProviderSpec, error) { |
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.
Not exported, but it does already exist in the tests
cluster-api-provider-azure/pkg/cloud/azure/actuators/machine_scope_test.go
Lines 42 to 50 in d80999f
func providerSpecFromMachine(in *machineproviderv1.AzureMachineProviderSpec) (*machinev1.ProviderSpec, error) { | |
bytes, err := json.Marshal(in) | |
if err != nil { | |
return nil, err | |
} | |
return &machinev1.ProviderSpec{ | |
Value: &runtime.RawExtension{Raw: bytes}, | |
}, nil | |
} |
cluster-api-provider-azure/pkg/cloud/azure/actuators/machine/actuator_test.go
Lines 69 to 77 in d80999f
func providerSpecFromMachine(in *machineproviderv1.AzureMachineProviderSpec) (*machinev1.ProviderSpec, error) { | |
bytes, err := yaml.Marshal(in) | |
if err != nil { | |
return nil, err | |
} | |
return &machinev1.ProviderSpec{ | |
Value: &runtime.RawExtension{Raw: bytes}, | |
}, nil | |
} |
@@ -9,6 +9,7 @@ require ( | |||
github.com/Azure/go-autorest/autorest/to v0.3.0 | |||
github.com/Azure/go-autorest/autorest/validation v0.2.0 // indirect | |||
github.com/ghodss/yaml v1.0.0 |
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.
Fixed
} | ||
|
||
originalMachineSetToPatch := client.MergeFrom(machineSet.DeepCopy()) | ||
defer func() { |
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.
do we need to defer here?
what's the benefit over calling this explicitly at the end of this func? I'd find that more readable. 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.
I did this because I had meant to put a return in the if err != nil
block on lines 96-99, but I seemingly forgot to do that.
I was following a pattern from upstream but happy to rework it to avoid the defer
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.
Added a commit to rework this, gonna squash it before merge, 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.
sgtm. Please keep revendor commit separate
logger.Error(err, "Failed to reconcile MachineSet") | ||
r.recorder.Eventf(machineSet, corev1.EventTypeWarning, "ReconcileError", "%v", err) | ||
} | ||
return 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.
shouldn't this return err
? seems like the err
in l94 is ignored otherwise?
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.
Already fixed that, I think you saw an outdated version
336e982
to
6a33aca
Compare
6a33aca
to
1147e1f
Compare
/test unit |
1147e1f
to
54b56de
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: enxebre 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 |
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.
/lgtm
/retest Please review the full test history for this PR and help us cut down flakes. |
What this PR does / why we need it:
This PR adds a new controller to annotate machinesets with information required to enable autoscaling to/from zero
I haven't tested this yet on a real cluster so will look into doing that
I also haven't added any tests for the controller as whole, happy to add some envtest style tests if that would be useful