Skip to content

Commit

Permalink
Fix vsphere machine creation error handling (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: Artem Kulyabin <artem.kulyabin@flant.com>
  • Loading branch information
artbin and Artem Kulyabin authored Oct 22, 2024
1 parent df7c3e1 commit 8fe770e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/controller/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const (
)

/*
SECTION
Machine controller - Machine add, update, delete watches
SECTION
Machine controller - Machine add, update, delete watches
*/
func (c *controller) addMachine(obj interface{}) {
klog.V(4).Infof("Adding machine object")
Expand Down Expand Up @@ -247,8 +247,8 @@ func (c *controller) reconcileClusterMachine(machine *v1alpha1.Machine) error {
}

/*
SECTION
Machine controller - nodeToMachine
SECTION
Machine controller - nodeToMachine
*/
func (c *controller) addNodeToMachine(obj interface{}) {
node := obj.(*corev1.Node)
Expand Down Expand Up @@ -515,12 +515,16 @@ func (c *controller) machineCreate(machine *v1alpha1.Machine, driver driver.Driv
actualProviderID = providerID
}
}
var timeoutActive bool
if actualProviderID == "" {
actualProviderID, nodeName, err = driver.Create()
var e drivers.CreateError
if errors.As(err, &e) && e.HasSideEffects() && actualProviderID != "" {
klog.Errorf("Side-effects left, applying machineID %q to Machine object", actualProviderID)

// Without this, the machine object will be stuck in a CrashLoopBackOff state forever
timeoutActive = true

for {
machineName := machine.Name

Expand Down Expand Up @@ -555,7 +559,7 @@ func (c *controller) machineCreate(machine *v1alpha1.Machine, driver driver.Driv
}
currentStatus := v1alpha1.CurrentStatus{
Phase: v1alpha1.MachineCrashLoopBackOff,
TimeoutActive: false,
TimeoutActive: timeoutActive,
LastUpdateTime: metav1.Now(),
}
c.updateMachineStatus(machine, lastOperation, currentStatus)
Expand Down Expand Up @@ -1100,8 +1104,8 @@ func (c *controller) deleteMachineFinalizers(machine *v1alpha1.Machine) {
}

/*
SECTION
Helper Functions
SECTION
Helper Functions
*/
func (c *controller) isHealthy(machine *v1alpha1.Machine) bool {
numOfConditions := len(machine.Status.Conditions)
Expand Down

0 comments on commit 8fe770e

Please sign in to comment.