Skip to content
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

Fix handling of machine creation errors in the vsphere driver #13

Merged
merged 1 commit into from
Oct 22, 2024
Merged
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
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
Loading