Skip to content

Commit

Permalink
fix: run the 'post' stage of the service always
Browse files Browse the repository at this point in the history
For most of the Talos service `post` stage does nothing, so it was never
properly noticed. FOr extension service, pre/post stages perform
mounting and unmounting of the overlayfs, so if post stage doesn't run
(if the runner can't be created), next time service is started, it won't
start as the post stage never ran.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Apr 20, 2022
1 parent 992e230 commit 257dfb8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/app/machined/pkg/system/service_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,15 @@ func (svcrunner *ServiceRunner) Start() {
return
}

defer func() {
// PostFunc passes in the state so that we can take actions that depend on the outcome of the run
state := svcrunner.GetState()

if err := svcrunner.service.PostFunc(svcrunner.runtime, state); err != nil {
svcrunner.UpdateState(events.StateFailed, "Failed to run post stage: %v", err)
}
}()

if runnr == nil {
svcrunner.UpdateState(events.StateSkipped, "Service skipped")

Expand All @@ -250,15 +259,6 @@ func (svcrunner *ServiceRunner) Start() {
} else {
svcrunner.UpdateState(events.StateFinished, "Service finished successfully")
}

// PostFunc passes in the state so that we can take actions that depend on the outcome of the run
state := svcrunner.GetState()

if err := svcrunner.service.PostFunc(svcrunner.runtime, state); err != nil {
svcrunner.UpdateState(events.StateFailed, "Failed to run post stage: %v", err)

return
}
}

//nolint:gocyclo
Expand Down

0 comments on commit 257dfb8

Please sign in to comment.