Skip to content

fix container can't be started when task status is created#4944

Open
ningmingxiao wants to merge 1 commit into
containerd:mainfrom
ningmingxiao:fix_start
Open

fix container can't be started when task status is created#4944
ningmingxiao wants to merge 1 commit into
containerd:mainfrom
ningmingxiao:fix_start

Conversation

@ningmingxiao
Copy link
Copy Markdown
Contributor

@ningmingxiao ningmingxiao commented May 29, 2026

nerdctl start container failed if get staus timeout

image

nerdctl can't start this container anymore.

reproduce

  1. nerdctl run -d busybox sleep 10
    c1a3a060f42feabdd2fd7440c05c5905a918ec1cad2ebf9e34e8ca1fa9921a80

  2. wait container exited
    and add some sleep here

func Start(ctx context.Context, container containerd.Container, isAttach bool, isInteractive bool, client *containerd.Client, detachKeys string, checkpointDir string, cfg *config.Config, nerdctlCmd string, nerdctlArgs []string) (err error) {
...
	task, err := taskutil.NewTask(ctx, client, container, taskutil.TaskOptions{
		AttachStreamOpt: attachStreamOpt,
		IsInteractive:   isInteractive,
		IsTerminal:      isTerminal,
		IsDetach:        true,
		Con:             con,
		LogURI:          logURI,
		DetachKeys:      detachKeys,
		Namespace:       namespace,
		DetachC:         detachC,
		CheckpointDir:   checkpointDir,
	})
	if err != nil {
		return err
	}
	time.Sleep(time.Second*1000)
	statusC, err := task.Wait(ctx)
	if err != nil {
		return err
	}

3 ./nerdctl start c1a and then kill "nerdctl start" (will find runc init is running)

  1. delete sleep and rebuild nerdctl
  2. ./nerdctl start c1a
    FATA[0000] 1 errors:
    task c1a3a060f42feabdd2fd7440c05c5905a918ec1cad2ebf9e34e8ca1fa9921a80: already exists

@AkihiroSuda

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't figured out how to add test cases yet.

Comment thread pkg/containerutil/containerutil.go
Comment thread pkg/containerutil/containerutil.go Outdated
}
if _, err := oldTask.Delete(ctx); err != nil {
log.G(ctx).WithError(err).Debug("failed to delete old task")
log.G(ctx).WithError(err).Errorf("failed to delete old task")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here if old task is not deleted, new task can't be created. and default log level is debug, I think we can use error level @AkihiroSuda

Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants