Skip to content

Commit 95ac248

Browse files
committed
Do not fail eviction on failed migration
The migrate api call may fail temporarily, for example when the instance is in the process of being deleted. So rather set the error condition on the individual migration, but continue with the next instance.
1 parent 558b17e commit 95ac248

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

internal/controller/eviction_controller.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,13 @@ func (r *EvictionReconciler) liveMigrate(ctx context.Context, uuid string, evict
485485
res := servers.LiveMigrate(ctx, r.computeClient, uuid, liveMigrateOpts)
486486
if res.Err != nil {
487487
err := fmt.Errorf("failed to evict VM %s due to %w", uuid, res.Err)
488-
r.addCondition(ctx, eviction, metav1.ConditionFalse, err.Error(), kvmv1.ConditionReasonFailed)
489-
return res.Err
488+
meta.SetStatusCondition(&eviction.Status.Conditions, metav1.Condition{
489+
Type: kvmv1.ConditionTypeMigration,
490+
Status: metav1.ConditionFalse,
491+
Message: err.Error(),
492+
Reason: kvmv1.ConditionReasonFailed,
493+
})
494+
return err
490495
}
491496

492497
log.Info("Live migrating server", "server", uuid, "source", eviction.Spec.Hypervisor, "X-Openstack-Request-Id", res.Header["X-Openstack-Request-Id"][0])
@@ -499,7 +504,12 @@ func (r *EvictionReconciler) coldMigrate(ctx context.Context, uuid string, evict
499504
res := servers.Migrate(ctx, r.computeClient, uuid)
500505
if res.Err != nil {
501506
err := fmt.Errorf("failed to evict stopped server %s due to %w", uuid, res.Err)
502-
r.addCondition(ctx, eviction, metav1.ConditionFalse, err.Error(), kvmv1.ConditionReasonFailed)
507+
meta.SetStatusCondition(&eviction.Status.Conditions, metav1.Condition{
508+
Type: kvmv1.ConditionTypeMigration,
509+
Status: metav1.ConditionFalse,
510+
Message: err.Error(),
511+
Reason: kvmv1.ConditionReasonFailed,
512+
})
503513
return err
504514
}
505515

0 commit comments

Comments
 (0)