Преглед изворни кода

Merge pull request #44400 from corhere/backport-22.06/fix-task-delete-on-failed-start

[22.06 backport] Fix containerd task deletion after failed start
Cory Snider пре 2 година
родитељ
комит
4b79d9078a
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      libcontainerd/remote/client.go

+ 3 - 1
libcontainerd/remote/client.go

@@ -245,7 +245,9 @@ func (c *client) Start(ctx context.Context, id, checkpointDir string, withStdin
 	close(stdinCloseSync)
 
 	if err := t.Start(ctx); err != nil {
-		if _, err := t.Delete(ctx); err != nil {
+		// Only Stopped tasks can be deleted. Created tasks have to be
+		// killed first, to transition them to Stopped.
+		if _, err := t.Delete(ctx, containerd.WithProcessKill); err != nil {
 			c.logger.WithError(err).WithField("container", id).
 				Error("failed to delete task after fail start")
 		}