diff options
Diffstat (limited to 'internal/outcome/process.go')
| -rw-r--r-- | internal/outcome/process.go | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/internal/outcome/process.go b/internal/outcome/process.go index e7b7113d..be919a63 100644 --- a/internal/outcome/process.go +++ b/internal/outcome/process.go @@ -30,7 +30,9 @@ const ( ) // NewStore returns the address of a new instance of [store.Store]. -func NewStore(sc *hst.Paths) *store.Store { return store.New(sc.SharePath.Append("state")) } +func NewStore(sc *hst.Paths) *store.Store { + return store.New(sc.SharePath.Append("state")) +} // main carries out outcome and terminates. main does not return. func (k *outcome) main(msg message.Msg, identifierFd int) { @@ -116,7 +118,11 @@ func (k *outcome) main(msg message.Msg, identifierFd int) { processStatePrev, processStateCur = processStateCur, processState if !processTime.IsZero() && processStatePrev != processLifecycle { - msg.Verbosef("state %d took %.2f ms", processStatePrev, float64(time.Since(processTime).Nanoseconds())/1e6) + msg.Verbosef( + "state %d took %.2f ms", + processStatePrev, + float64(time.Since(processTime).Nanoseconds())/1e6, + ) } processTime = time.Now() @@ -141,7 +147,10 @@ func (k *outcome) main(msg message.Msg, identifierFd int) { case processCommit: if isBeforeRevert { - perrorFatal(newWithMessage("invalid transition to commit state"), "commit", processLifecycle) + perrorFatal( + newWithMessage("invalid transition to commit state"), + "commit", processLifecycle, + ) continue } @@ -238,15 +247,26 @@ func (k *outcome) main(msg message.Msg, identifierFd int) { case <-func() chan struct{} { w := make(chan struct{}) - // this ties processLifecycle to ctx with the additional compensated timeout duration - // to allow transition to the next state on a locked up shim - go func() { <-ctx.Done(); time.Sleep(k.state.Shim.WaitDelay + shimWaitTimeout); close(w) }() + // This ties processLifecycle to ctx with the additional + // compensated timeout duration to allow transition to the next + // state on a locked up shim. + go func() { + <-ctx.Done() + time.Sleep(k.state.Shim.WaitDelay + shimWaitTimeout) + close(w) + }() return w }(): - // this is only reachable when wait did not return within shimWaitTimeout, after its WaitDelay has elapsed. - // This is different from the container failing to terminate within its timeout period, as that is enforced - // by the shim. This path is instead reached when there is a lockup in shim preventing it from completing. - msg.GetLogger().Printf("process %d did not terminate", shimCmd.Process.Pid) + // This is only reachable when wait did not return within + // shimWaitTimeout, after its WaitDelay has elapsed. This is + // different from the container failing to terminate within its + // timeout period, as that is enforced by the shim. This path is + // instead reached when there is a lockup in shim preventing it + // from completing. + msg.GetLogger().Printf( + "process %d did not terminate", + shimCmd.Process.Pid, + ) } msg.Resume() @@ -271,8 +291,8 @@ func (k *outcome) main(msg message.Msg, identifierFd int) { ec := system.Process if entries, _, err := handle.Entries(); err != nil { - // it is impossible to continue from this point, - // per-process state will be reverted to limit damage + // it is impossible to continue from this point, per-process + // state will be reverted to limit damage perror(err, "read store segment entries") } else { // accumulate enablements of remaining instances @@ -295,7 +315,10 @@ func (k *outcome) main(msg message.Msg, identifierFd int) { if n == 0 { ec |= system.User } else { - msg.Verbosef("found %d instances, cleaning up without user-scoped operations", n) + msg.Verbosef( + "found %d instances, cleaning up without user-scoped operations", + n, + ) } ec |= rt ^ (hst.EWayland | hst.EX11 | hst.EDBus | hst.EPulse) if msg.IsVerbose() { @@ -335,7 +358,9 @@ func (k *outcome) main(msg message.Msg, identifierFd int) { // start starts the shim via cmd/hsu. // -// If successful, a [time.Time] value for [hst.State] is stored in the value pointed to by startTime. +// If successful, a [time.Time] value for [hst.State] is stored in the value +// pointed to by startTime. +// // The resulting [exec.Cmd] and write end of the shim setup pipe is returned. func (k *outcome) start(ctx context.Context, msg message.Msg, hsuPath *check.Absolute, |
