Skip to content

Commit

Permalink
fix: attempt to clean up tasks in containerd runner
Browse files Browse the repository at this point in the history
I was not able to reproduce the issue fully, but community bug report
contained the following log lines:

```
192.168.81.122: [talos] service[kubelet](Waiting): Error running Containerd(kubelet), going to restart forever: failed to create task: "kubelet": task kubelet already exists: unknown
```

This fix should clean up any leftover tasks before attempting to create
a new one.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Oct 14, 2021
1 parent 8cf442d commit c0fda64
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (c *containerdRunner) Close() error {

// Run implements runner.Runner interface
//
//nolint:gocyclo
//nolint:gocyclo,cyclop
func (c *containerdRunner) Run(eventSink events.Recorder) error {
defer close(c.stopped)

Expand All @@ -135,6 +135,14 @@ func (c *containerdRunner) Run(eventSink events.Recorder) error {
err error
)

// attempt to clean up a task if it already exists
task, err = c.container.Task(c.ctx, nil)
if err == nil {
if _, err = task.Delete(c.ctx); err != nil {
return fmt.Errorf("failed to clean up task %q: %w", c.args.ID, err)
}
}

logW, err = c.opts.LoggingManager.ServiceLog(c.args.ID).Writer()
if err != nil {
return fmt.Errorf("error creating log: %w", err)
Expand Down

0 comments on commit c0fda64

Please sign in to comment.