Skip to content

Commit 6dbec4f

Browse files
authored
Merge pull request #10825 from sbueringer/pr-improv-godoc-replicas
📖 Improve godoc of the autoscaler replica field defaulting
2 parents afdcb4c + a2a2bba commit 6dbec4f

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

internal/webhooks/machinedeployment.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,14 @@ func (webhook *MachineDeployment) validate(oldMD, newMD *clusterv1.MachineDeploy
317317
//
318318
// We are supporting the following use cases:
319319
// * A new MD is created and replicas should be managed by the autoscaler
320-
// - Either via the default annotation or via the min size and max size annotations the replicas field
321-
// is defaulted to a value which is within the (min size, max size) range so the autoscaler can take control.
320+
// - If the min size and max size annotations are set, the replicas field is defaulted to the value of the min size
321+
// annotation so the autoscaler can take control.
322322
//
323323
// * An existing MD which initially wasn't controlled by the autoscaler should be later controlled by the autoscaler
324-
// - To adopt an existing MD users can use the default, min size and max size annotations to enable the autoscaler
325-
// and to ensure the replicas field is within the (min size, max size) range. Without the annotations handing over
326-
// control to the autoscaler by unsetting the replicas field would lead to the field being set to 1. This is very
327-
// disruptive for existing Machines and if 1 is outside the (min size, max size) range the autoscaler won't take
328-
// control.
329-
//
330-
// Notes:
331-
// - While the min size and max size annotations of the autoscaler provide the best UX, other autoscalers can use the
332-
// DefaultReplicasAnnotation if they have similar use cases.
324+
// - To adopt an existing MD users can use the min size and max size annotations to enable the autoscaler
325+
// and to ensure the replicas field is within the (min size, max size) range. Without defaulting based on the annotations, handing over
326+
// control to the autoscaler by unsetting the replicas field would lead to the field being set to 1. This could be
327+
// very disruptive if the previous value of the replica field is greater than 1.
333328
func calculateMachineDeploymentReplicas(ctx context.Context, oldMD *clusterv1.MachineDeployment, newMD *clusterv1.MachineDeployment, dryRun bool) (int32, error) {
334329
// If replicas is already set => Keep the current value.
335330
if newMD.Spec.Replicas != nil {

internal/webhooks/machineset.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,19 +270,14 @@ func validateSkippedMachineSetPreflightChecks(o client.Object) *field.Error {
270270
//
271271
// We are supporting the following use cases:
272272
// * A new MS is created and replicas should be managed by the autoscaler
273-
// - Either via the default annotation or via the min size and max size annotations the replicas field
274-
// is defaulted to a value which is within the (min size, max size) range so the autoscaler can take control.
273+
// - If the min size and max size annotations are set, the replicas field is defaulted to the value of the min size
274+
// annotation so the autoscaler can take control.
275275
//
276276
// * An existing MS which initially wasn't controlled by the autoscaler should be later controlled by the autoscaler
277-
// - To adopt an existing MS users can use the default, min size and max size annotations to enable the autoscaler
278-
// and to ensure the replicas field is within the (min size, max size) range. Without the annotations handing over
279-
// control to the autoscaler by unsetting the replicas field would lead to the field being set to 1. This is very
280-
// disruptive for existing Machines and if 1 is outside the (min size, max size) range the autoscaler won't take
281-
// control.
282-
//
283-
// Notes:
284-
// - While the min size and max size annotations of the autoscaler provide the best UX, other autoscalers can use the
285-
// DefaultReplicasAnnotation if they have similar use cases.
277+
// - To adopt an existing MS users can use the min size and max size annotations to enable the autoscaler
278+
// and to ensure the replicas field is within the (min size, max size) range. Without defaulting based on the annotations, handing over
279+
// control to the autoscaler by unsetting the replicas field would lead to the field being set to 1. This could be
280+
// very disruptive if the previous value of the replica field is greater than 1.
286281
func calculateMachineSetReplicas(ctx context.Context, oldMS *clusterv1.MachineSet, newMS *clusterv1.MachineSet, dryRun bool) (int32, error) {
287282
// If replicas is already set => Keep the current value.
288283
if newMS.Spec.Replicas != nil {

0 commit comments

Comments
 (0)