Skip to content

Commit

Permalink
Merge pull request #475 from beekhof/patch-1
Browse files Browse the repository at this point in the history
Bug 1800423: Apply the reboot annotation to the machine
  • Loading branch information
openshift-merge-robot committed Feb 11, 2020
2 parents d189f5d + 1216944 commit 65f3660
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,17 @@ func (t *target) remediate(r *ReconcileMachineHealthCheck) error {

func (t *target) remediationStrategyReboot(r *ReconcileMachineHealthCheck) error {
// we already have reboot annotation on the node, stop reconcile
if _, ok := t.Node.Annotations[machineRebootAnnotationKey]; ok {
if _, ok := t.Machine.Annotations[machineRebootAnnotationKey]; ok {
return nil
}

if t.Node.Annotations == nil {
t.Node.Annotations = map[string]string{}
if t.Machine.Annotations == nil {
t.Machine.Annotations = map[string]string{}
}

glog.Infof("Machine %s has been unhealthy for too long, adding reboot annotation", t.Machine.Name)
t.Node.Annotations[machineRebootAnnotationKey] = ""
if err := r.client.Update(context.TODO(), t.Node); err != nil {
t.Machine.Annotations[machineRebootAnnotationKey] = ""
if err := r.client.Update(context.TODO(), &t.Machine); err != nil {
r.recorder.Eventf(
&t.Machine,
corev1.EventTypeWarning,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ func TestApplyRemediationReboot(t *testing.T) {
machineHealthCheck := maotesting.NewMachineHealthCheck("machineHealthCheck")
request := reconcile.Request{
NamespacedName: types.NamespacedName{
Namespace: "",
Name: nodeUnhealthyForTooLong.Name,
Namespace: namespace,
Name: machineUnhealthyForTooLong.Name,
},
}
recorder := record.NewFakeRecorder(2)
Expand All @@ -391,13 +391,13 @@ func TestApplyRemediationReboot(t *testing.T) {
recorder.Events,
)

node := &corev1.Node{}
if err := r.client.Get(context.TODO(), request.NamespacedName, node); err != nil {
machine := &mapiv1beta1.Machine{}
if err := r.client.Get(context.TODO(), request.NamespacedName, machine); err != nil {
t.Errorf("Expected: no error, got: %v", err)
}

if _, ok := node.Annotations[machineRebootAnnotationKey]; !ok {
t.Errorf("Expected: node to have reboot annotion %s, got: %v", machineRebootAnnotationKey, node.Annotations)
if _, ok := machine.Annotations[machineRebootAnnotationKey]; !ok {
t.Errorf("Expected: node to have reboot annotion %s, got: %v", machineRebootAnnotationKey, machine.Annotations)
}
}

Expand Down

0 comments on commit 65f3660

Please sign in to comment.