Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#370 from sidharthsurana/feature/su…
Browse files Browse the repository at this point in the history
…pport-maintenance-mode

Add support for Machine maintenance window
  • Loading branch information
k8s-ci-robot committed Jun 26, 2019
2 parents dbbf044 + cb4b5b5 commit 3ba76a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/cloud/vsphere/actuators/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func (a *Actuator) Create(
return err
}

if _, ok := machine.Annotations[constants.MaintenanceAnnotationLabel]; ok {
ctx.Logger.V(4).Info("skipping operations on machine", "reason", "annotation", "annotation-key", constants.MaintenanceAnnotationLabel)
return &clustererr.RequeueAfterError{RequeueAfter: constants.DefaultRequeue}
}

defer func() {
opErr = actuators.PatchAndHandleError(ctx, "Create", opErr)
}()
Expand Down Expand Up @@ -113,6 +118,11 @@ func (a *Actuator) Delete(
return err
}

if _, ok := machine.Annotations[constants.MaintenanceAnnotationLabel]; ok {
ctx.Logger.V(4).Info("skipping operations on machine", "reason", "annotation", "annotation-key", constants.MaintenanceAnnotationLabel)
return &clustererr.RequeueAfterError{RequeueAfter: constants.DefaultRequeue}
}

defer func() {
opErr = actuators.PatchAndHandleError(ctx, "Delete", opErr)
}()
Expand Down Expand Up @@ -179,6 +189,11 @@ func (a *Actuator) Exists(
return false, err
}

if _, ok := machine.Annotations[constants.MaintenanceAnnotationLabel]; ok {
ctx.Logger.V(4).Info("skipping operations on machine", "reason", "annotation", "annotation-key", constants.MaintenanceAnnotationLabel)
return false, &clustererr.RequeueAfterError{RequeueAfter: constants.DefaultRequeue}
}

defer func() {
opErr = actuators.PatchAndHandleError(ctx, "Exists", opErr)
}()
Expand Down
4 changes: 4 additions & 0 deletions pkg/cloud/vsphere/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ const (
// ReadyAnnotationLabel is the annotation used to indicate a machine and/or
// cluster are ready.
ReadyAnnotationLabel = "capv.sigs.k8s.io/ready"

// MaintenanceAnnotationLabel is the annotation used to indicate a machine and/or
// cluster are in maintenance mode.
MaintenanceAnnotationLabel = "capv.sigs.k8s.io/maintenance"
)

0 comments on commit 3ba76a0

Please sign in to comment.