Skip to content

Commit

Permalink
fix: prevent crash in machined on apid service stop
Browse files Browse the repository at this point in the history
On reboots, when `apid` is stopped, `PostFunc()` is called, but
`o.cancel` is only initialized for worker nodes, so it leads to `init`
panic on master nodes.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Feb 10, 2021
1 parent daea9d3 commit 1a32d55
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/app/machined/pkg/system/services/apid.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ func (o *APID) PreFunc(ctx context.Context, r runtime.Runtime) error {

// PostFunc implements the Service interface.
func (o *APID) PostFunc(r runtime.Runtime, state events.ServiceState) (err error) {
o.cancel()
if o.cancel != nil {
o.cancel()
}

o.wg.Wait()

return nil
Expand Down

0 comments on commit 1a32d55

Please sign in to comment.