Skip to content

Commit d5a823a

Browse files
committed
fix: run the 'post' stage of the service always
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> (cherry picked from commit 257dfb8)
1 parent 71991a9 commit d5a823a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

internal/app/machined/pkg/system/service_runner.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,15 @@ func (svcrunner *ServiceRunner) Start() {
239239
return
240240
}
241241

242+
defer func() {
243+
// PostFunc passes in the state so that we can take actions that depend on the outcome of the run
244+
state := svcrunner.GetState()
245+
246+
if err := svcrunner.service.PostFunc(svcrunner.runtime, state); err != nil {
247+
svcrunner.UpdateState(events.StateFailed, "Failed to run post stage: %v", err)
248+
}
249+
}()
250+
242251
if runnr == nil {
243252
svcrunner.UpdateState(events.StateSkipped, "Service skipped")
244253

@@ -250,15 +259,6 @@ func (svcrunner *ServiceRunner) Start() {
250259
} else {
251260
svcrunner.UpdateState(events.StateFinished, "Service finished successfully")
252261
}
253-
254-
// PostFunc passes in the state so that we can take actions that depend on the outcome of the run
255-
state := svcrunner.GetState()
256-
257-
if err := svcrunner.service.PostFunc(svcrunner.runtime, state); err != nil {
258-
svcrunner.UpdateState(events.StateFailed, "Failed to run post stage: %v", err)
259-
260-
return
261-
}
262262
}
263263

264264
//nolint:gocyclo

0 commit comments

Comments
 (0)