Skip to content

Commit

Permalink
Allow detachment from an old node when migrating to a down node
Browse files Browse the repository at this point in the history
Longhorn 3401

Signed-off-by: Eric Weber <eric.weber@suse.com>
  • Loading branch information
ejweber committed Jun 24, 2024
1 parent 68d0cad commit f267d5b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions controller/volume_attachment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,26 @@ func (vac *VolumeAttachmentController) handleVolumeMigrationConfirmation(va *lon
return
}

// This is not technically a confirmation. However, there is no good reason to allow the volume to remain attached
// under these conditions.
// - Kubernetes does not want it attached to the old node.
// - We can't get a migration engine up on the new down node.
// Stop the migration and detach from the old node. If the upper layer changes nothing and the new node comes back,
// the volume can exclusively attach to it.
if downOrDeleted, err := vac.ds.IsNodeDownOrDeleted(vol.Status.CurrentMigrationNodeID); err != nil {
log.WithError(err).Warn("Failed to check if node is down")
} else if downOrDeleted {
vol.Spec.NodeID = ""
vol.Spec.MigrationNodeID = ""
log = getLoggerForMigratingLHVolumeAttachment(vac.logger, va, vol)
log.Warn("Detaching volume for attempted migration to down node")
return
}
// We can consider a similar optimization for the case in which the old node is down. However, in that case, the
// situation is eventually resolved when Longhorn realizes the old engine is no longer running (we have to wait
// until Kubernetes tries to evict its instance-manager). Then, the volume becomes detached automatically and the
// migration ends. For now, the existing behavior seems safest.

if !vac.isVolumeAvailableOnNode(vol.Name, vol.Status.CurrentMigrationNodeID) {
log.Warn("Waiting to confirm migration until migration engine is ready")
return
Expand Down

0 comments on commit f267d5b

Please sign in to comment.