Skip to content

fix(shim): reject task creation during shutdown - #280

Open
eginez wants to merge 1 commit into
containerd:mainfrom
eginez:fix/shim-create-during-shutdown
Open

fix(shim): reject task creation during shutdown#280
eginez wants to merge 1 commit into
containerd:mainfrom
eginez:fix/shim-create-during-shutdown

Conversation

@eginez

@eginez eginez commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Reject initial task Create with Unavailable after the shim begins retiring.
  • Serialize Create with terminal Delete and Shutdown so it cannot race old-VM teardown.
  • Return shutdown callback failures to the caller.

Testing

  • go test -count=1 ./api/... ./cmd/... ./internal/... ./pkg/... ./plugins/...
  • docker buildx bake validate

Copilot AI lite review requested due to automatic review settings August 26, 2026 18:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR tightens shim lifecycle behavior by preventing new initial-task creation once the shim begins retiring, serializing Create against terminal lifecycle transitions, and surfacing shutdown callback failures to callers.

Changes:

  • Reject Create with Unavailable once the shim is retiring.
  • Serialize Create with terminal Delete/Shutdown via a lifecycle mutex and retiring flag.
  • Add tests covering Create during shutdown and propagating shutdown stop errors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/shim/task/service_lifecycle_test.go Adds lifecycle regression tests plus test doubles for controlled shutdown and VM lifecycle.
internal/shim/task/service.go Introduces lifecycle serialization (lifecycleMu/retiring), blocks Create during shutdown, and returns shutdown callback errors.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/shim/task/service_lifecycle_test.go
Comment thread internal/shim/task/service.go Outdated

// Delete the initial process and container
func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (*taskAPI.DeleteResponse, error) {
if r.ExecID == "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need to handle this case here? Shutdown is the actual start of the teardown process and as-is, this is incompatible with #254 where deleting a container does not mean tearing down the VM.

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.

Addressed, thanks for pointing this out @Kern--

Copilot AI review requested due to automatic review settings August 26, 2026 21:03
@eginez
eginez force-pushed the fix/shim-create-during-shutdown branch from 5e51e20 to cd80bc6 Compare August 26, 2026 21:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread internal/shim/task/service.go
Comment thread internal/shim/task/service_lifecycle_test.go
Make the task service single-generation once shutdown begins, so replacement creation cannot race teardown of the old VM.
Propagate shutdown callback failures to the caller.

Signed-off-by: Esteban Ginez <esteban.ginez@docker.com>
Copilot AI review requested due to automatic review settings August 26, 2026 21:44
@eginez
eginez force-pushed the fix/shim-create-during-shutdown branch from cd80bc6 to bc4fad0 Compare August 26, 2026 21:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@eginez
eginez requested a review from Kern-- August 26, 2026 22:38

s.lifecycleMu.Lock()
s.retiring = true
s.lifecycleMu.Unlock()

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.

There is still a bit of conflict with #254 because Shutdown is not a terminal RPC in the shim protocol. This can land as-is in the current architecture, but #254 will need to account for it.

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.

@austinvazquez austinvazquez left a comment

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.

LGTM, just need to address that conflict with the 1:many feature.

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.

4 participants