Skip to content

Drop strategy field in favour of annotation #415

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

Merged
merged 1 commit into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ spec:
- type: integer
description: Any farther remediation is only allowed if at most "MaxUnhealthy"
machines selected by "selector" are not healthy.
remediationStrategy:
description: RemediationStrategy to use in case of problem detection
default is machine deletion
type: string
selector:
description: Label selector to match machines whose health will be exercised
properties:
Expand Down
8 changes: 0 additions & 8 deletions pkg/apis/healthchecking/v1alpha1/machinehealthcheck_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
)

// ConfigMapNodeUnhealthyConditions contains the name of the unhealthy conditions config map
const ConfigMapNodeUnhealthyConditions = "node-unhealthy-conditions"

// RemediationStrategyType contains remediation strategy type
type RemediationStrategyType string

Expand Down Expand Up @@ -41,11 +38,6 @@ type MachineHealthCheckList struct {

// MachineHealthCheckSpec defines the desired state of MachineHealthCheck
type MachineHealthCheckSpec struct {
// RemediationStrategy to use in case of problem detection
// default is machine deletion
// +optional
RemediationStrategy *RemediationStrategyType `json:"remediationStrategy,omitempty"`

// Label selector to match machines whose health will be exercised
Selector metav1.LabelSelector `json:"selector"`

Expand Down
5 changes: 0 additions & 5 deletions pkg/apis/healthchecking/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 15 additions & 12 deletions pkg/controller/machinehealthcheck/machinehealthcheck_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ import (
)

const (
machineAnnotationKey = "machine.openshift.io/machine"
machineRebootAnnotationKey = "healthchecking.openshift.io/machine-remediation-reboot"
ownerControllerKind = "MachineSet"
nodeMasterLabel = "node-role.kubernetes.io/master"
machineRoleLabel = "machine.openshift.io/cluster-api-machine-role"
machineMasterRole = "master"
machinePhaseFailed = "Failed"
remediationStrategyReboot = healthcheckingv1alpha1.RemediationStrategyType("reboot")
timeoutForMachineToHaveNode = 10 * time.Minute
machineAnnotationKey = "machine.openshift.io/machine"
machineRebootAnnotationKey = "healthchecking.openshift.io/machine-remediation-reboot"
ownerControllerKind = "MachineSet"
nodeMasterLabel = "node-role.kubernetes.io/master"
machineRoleLabel = "machine.openshift.io/cluster-api-machine-role"
machineMasterRole = "master"
machinePhaseFailed = "Failed"
remediationStrategyAnnotation = "healthchecking.openshift.io/strategy"
remediationStrategyReboot = healthcheckingv1alpha1.RemediationStrategyType("reboot")
timeoutForMachineToHaveNode = 10 * time.Minute
)

// Add creates a new MachineHealthCheck Controller and adds it to the Manager. The Manager will set fields on the Controller
Expand Down Expand Up @@ -360,9 +361,11 @@ func (t *target) remediate(r *ReconcileMachineHealthCheck) error {
return nil
}

remediationStrategy := t.MHC.Spec.RemediationStrategy
if remediationStrategy != nil && *remediationStrategy == remediationStrategyReboot {
return t.remediationStrategyReboot(r)
remediationStrategy, ok := t.MHC.Annotations[remediationStrategyAnnotation]
if ok {
if healthcheckingv1alpha1.RemediationStrategyType(remediationStrategy) == remediationStrategyReboot {
return t.remediationStrategyReboot(r)
}
}
if t.isMaster() {
glog.Infof("%s: master node, skipping remediation", t.string())
Expand Down