Skip to content

Commit

Permalink
feat: stop all pods before unmounting ephemeral partition
Browse files Browse the repository at this point in the history
This should address flakiness issues related to partition unmount.
Also changed the order of partitions unmount in the sequencer.

Signed-off-by: Artem Chernyshev <artem.0xD2@gmail.com>
  • Loading branch information
Unix4ever authored and talos-bot committed Feb 16, 2021
1 parent aa9bef2 commit ecd0921
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
28 changes: 21 additions & 7 deletions internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func (*Sequencer) ApplyConfiguration(r runtime.Runtime, req *machineapi.ApplyCon
).Append(
"unmountState",
UnmountStatePartition,
).Append(
"cleanup",
StopAllPods,
).AppendList(
stopAllPhaselist(r),
).Append(
Expand Down Expand Up @@ -273,7 +276,11 @@ func (*Sequencer) Bootstrap(r runtime.Runtime) []runtime.Phase {

// Reboot is the reboot sequence.
func (*Sequencer) Reboot(r runtime.Runtime) []runtime.Phase {
phases := PhaseList{}.AppendList(stopAllPhaselist(r)).
phases := PhaseList{}.Append(
"cleanup",
StopAllPods,
).
AppendList(stopAllPhaselist(r)).
Append("reboot", Reboot)

return phases
Expand Down Expand Up @@ -334,6 +341,10 @@ func (*Sequencer) Reset(r runtime.Runtime, in runtime.ResetOptions) []runtime.Ph
// Shutdown is the shutdown sequence.
func (*Sequencer) Shutdown(r runtime.Runtime) []runtime.Phase {
phases := PhaseList{}.
Append(
"cleanup",
StopAllPods,
).
AppendList(stopAllPhaselist(r)).
Append("shutdown", Shutdown)

Expand All @@ -352,6 +363,9 @@ func (*Sequencer) StageUpgrade(r runtime.Runtime, in *machineapi.UpgradeRequest)
!in.GetPreserve() && (r.Config().Machine().Type() != machine.TypeJoin),
"leave",
LeaveEtcd,
).Append(
"cleanup",
StopAllPods,
).AppendList(
stopAllPhaselist(r),
).Append(
Expand Down Expand Up @@ -396,13 +410,13 @@ func (*Sequencer) Upgrade(r runtime.Runtime, in *machineapi.UpgradeRequest) []ru
"unmount",
UnmountOverlayFilesystems,
UnmountPodMounts,
).Append(
"unmountBind",
UnmountSystemDiskBindMounts,
).Append(
"unmountSystem",
UnmountEphemeralPartition,
UnmountStatePartition,
).Append(
"unmountBind",
UnmountSystemDiskBindMounts,
).Append(
"verifyDisk",
VerifyDiskAvailability,
Expand Down Expand Up @@ -441,13 +455,13 @@ func stopAllPhaselist(r runtime.Runtime) PhaseList {
"umount",
UnmountOverlayFilesystems,
UnmountPodMounts,
).Append(
"unmountBind",
UnmountSystemDiskBindMounts,
).Append(
"unmountSystem",
UnmountEphemeralPartition,
UnmountStatePartition,
).Append(
"unmountBind",
UnmountSystemDiskBindMounts,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1202,10 +1202,10 @@ func UnmountSystemDiskBindMounts(seq runtime.Sequence, data interface{}) (runtim
continue
}

device := fields[0]
device := strings.ReplaceAll(fields[0], "/dev/mapper", "/dev")
mountpoint := fields[1]

if strings.HasPrefix(device, devname) {
if strings.HasPrefix(device, devname) && device != devname {
logger.Printf("unmounting %s\n", mountpoint)

if err = unix.Unmount(mountpoint, 0); err != nil {
Expand Down

0 comments on commit ecd0921

Please sign in to comment.