Skip to content

Commit

Permalink
Merge pull request #2913 from benmoss/machineset-replicas-default
Browse files Browse the repository at this point in the history
🏃 Remove MachineSet controller Update fallback
  • Loading branch information
k8s-ci-robot committed Apr 15, 2020
2 parents 0b964b7 + 0d46af2 commit e3a4ed7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
3 changes: 2 additions & 1 deletion api/v1alpha3/machineset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ type MachineSetStatus struct {
Selector string `json:"selector,omitempty"`

// Replicas is the most recently observed number of replicas.
Replicas int32 `json:"replicas"`
// +optional
Replicas int32 `json:"replicas,omitempty"`

// The number of replicas that have labels matching the labels of the machine template of the MachineSet.
// +optional
Expand Down
2 changes: 0 additions & 2 deletions config/crd/bases/cluster.x-k8s.io_machinesets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,6 @@ spec:
be in the same format as the query-param syntax. More info about
label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors'
type: string
required:
- replicas
type: object
type: object
served: true
Expand Down
12 changes: 1 addition & 11 deletions controllers/machineset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,17 +671,7 @@ func (r *MachineSetReconciler) patchMachineSetStatus(ctx context.Context, ms *cl

newStatus.DeepCopyInto(&ms.Status)
if err := r.Client.Status().Patch(ctx, ms, patch); err != nil {
// TODO(vincepri): Try to fix this once we upgrade to CRDv1.
// Our Status.Replicas field is a required non-pointer integer, Go defaults this field to "0" value when decoding
// the data from the API server. For this reason, when we try to write the value "0", the patch is going to think
// the value is already there and shouldn't be patched, making it fail validation.
// Fallback to Update.
if !apierrors.IsInvalid(err) {
return nil, err
}
if err := r.Client.Status().Update(ctx, ms); err != nil {
return nil, err
}
return nil, err
}
return ms, nil
}
Expand Down

0 comments on commit e3a4ed7

Please sign in to comment.