Skip to content

Commit d9ee0b4

Browse files
Make machine reconciler backwards compatible:
This gets the controller to work with the Helm charts <= 0.6.2 Signed-off-by: Jacob Weinstock <[email protected]>
1 parent f936782 commit d9ee0b4

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

controller/machine/scope.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,22 @@ func (scope *machineReconcileScope) reconcile(hw *tinkv1.Hardware) error {
143143
return fmt.Errorf("ensure template and workflow returned: %w", err)
144144
}
145145

146-
if wf.Status.State == tinkv1.WorkflowStateFailed || wf.Status.State == tinkv1.WorkflowStateTimeout {
146+
// STATE_* is needed for Helm charts <= 0.6.2
147+
switch wf.Status.State {
148+
case tinkv1.WorkflowStateFailed, tinkv1.WorkflowState("STATE_FAILED"):
147149
return errWorkflowFailed
148-
}
150+
case tinkv1.WorkflowStateTimeout, tinkv1.WorkflowState("STATE_TIMEOUT"):
151+
return errWorkflowTimeout
152+
case tinkv1.WorkflowStateSuccess, tinkv1.WorkflowState("STATE_SUCCESS"):
153+
scope.log.Info("Marking TinkerbellMachine as Ready")
154+
scope.tinkerbellMachine.Status.Ready = true
149155

150-
if wf.Status.State != tinkv1.WorkflowStateSuccess {
156+
if err := scope.patchHardwareAnnotations(hw, map[string]string{HardwareProvisionedAnnotation: "true"}); err != nil {
157+
return fmt.Errorf("failed to patch hardware: %w", err)
158+
}
151159
return nil
152160
}
153161

154-
scope.log.Info("Marking TinkerbellMachine as Ready")
155-
scope.tinkerbellMachine.Status.Ready = true
156-
157-
if err := scope.patchHardwareAnnotations(hw, map[string]string{HardwareProvisionedAnnotation: "true"}); err != nil {
158-
return fmt.Errorf("failed to patch hardware: %w", err)
159-
}
160-
161162
return nil
162163
}
163164

controller/machine/workflow.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
// errWorkflowFailed is the error returned when the workflow fails.
1919
var errWorkflowFailed = errors.New("workflow failed")
2020

21+
var errWorkflowTimeout = errors.New("workflow timed out")
22+
2123
// errISOBootURLRequired is the error returned when the isoURL is required for iso boot mode.
2224
var errISOBootURLRequired = errors.New("iso boot mode requires an isoURL")
2325

0 commit comments

Comments
 (0)