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
This commit is contained in:
Cory Snider 2022-11-02 18:15:19 -04:00 committed by GitHub
commit 4b79d9078a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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")
}