File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,18 @@ func (s *Service) UpgradePackages(ctx context.Context, names []string) (<-chan u
8383 defer s .lock .Unlock ()
8484 defer close (eventsCh )
8585
86+ // At the end of the upgrade, always try to restart the services (that need it).
87+ // This makes sure key services are restarted even if an error happens in the upgrade steps (for examples container images download).
88+ defer func () {
89+ eventsCh <- update .NewDataEvent (update .RestartEvent , "Upgrade completed. Restarting ..." )
90+
91+ err := restartServices (ctx )
92+ if err != nil {
93+ eventsCh <- update .NewErrorEvent (fmt .Errorf ("error restarting services after upgrade: %w" , err ))
94+ return
95+ }
96+ }()
97+
8698 eventsCh <- update .NewDataEvent (update .StartEvent , "Upgrade is starting" )
8799 stream := runUpgradeCommand (ctx , names )
88100 for line , err := range stream {
@@ -127,13 +139,6 @@ func (s *Service) UpgradePackages(ctx context.Context, names []string) (<-chan u
127139 }
128140 eventsCh <- update .NewDataEvent (update .UpgradeLineEvent , line )
129141 }
130- eventsCh <- update .NewDataEvent (update .RestartEvent , "Upgrade completed. Restarting ..." )
131-
132- err := restartServices (ctx )
133- if err != nil {
134- eventsCh <- update .NewErrorEvent (fmt .Errorf ("error restarting services after upgrade: %w" , err ))
135- return
136- }
137142 }()
138143
139144 return eventsCh , nil
You can’t perform that action at this time.
0 commit comments