Fix: send failure notifications for config init errors (#697)

* Register notification hooks first in init to allow sending .init() failure notifications

* Error from run_script is not consistently passed to deferred functions

---------

Co-authored-by: Frederik Ring <frederik.ring@gmail.com>
This commit is contained in:
Lennard
2025-12-22 19:41:19 +01:00
committed by GitHub
parent 16677e631e
commit 2938b6c1b0
3 changed files with 88 additions and 64 deletions

View File

@@ -63,11 +63,22 @@ func runScript(c *Config) (err error) {
}
if initErr := s.init(); initErr != nil {
if hookErr := s.runHooks(initErr); hookErr != nil {
err = errwrap.Wrap(
nil,
fmt.Sprintf(
"error %v instantiating script followed by %v calling the registered hooks",
initErr,
hookErr,
),
)
return
}
err = errwrap.Wrap(initErr, "error instantiating script")
return
}
return func() (err error) {
err = func() (err error) {
scriptErr := func() error {
if err := s.withLabeledCommands(lifecyclePhaseArchive, func() (err error) {
restartContainersAndServices, err := s.stopContainersAndServices()
@@ -121,4 +132,6 @@ func runScript(c *Config) (err error) {
}
return nil
}()
return
}