Skip to content

pkg/shim: Report bootstrap API mismatch on startup - #13910

Merged
mxpv merged 1 commit into
containerd:mainfrom
vvoland:shim-compat-warn
Aug 20, 2026
Merged

mxpv merged 1 commit into
containerd:mainfrom
vvoland:shim-compat-warn

Conversation

@vvoland

@vvoland vvoland commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

A pre-2.3 containerd daemon can start a newly installed shim through the deprecated CLI, environment, and stdin API.
The shim currently accepts that request but returns a protobuf bootstrap result, which the old daemon cannot parse.
It treats the protobuf bytes as a socket address and fails later with a cryptic error:

failed to create TTRPC connection: unsupported protocol: \b\x03\x12Yunix

This patch makes the shim reject the deprecated startup request before starting and tell the user that the containerd daemon may need to be restarted.
The 2.2 daemon includes the shim's stderr in its start error, so this message reaches the user directly.

This explicitly removes input-side support for the deprecated startup API, but it does not break a working standard containerd pairing. Pre-2.3 daemons already cannot consume the response from the new shim. After a package upgrade, a restarted daemon uses the new bootstrap API.

Custom callers that send the deprecated request format while supporting the new protobuf response will now also be rejected.

Improve error message when newer shim is invoked by older daemon using deprecated bootstrap API

@vvoland vvoland self-assigned this Aug 6, 2026
Copilot AI lite review requested due to automatic review settings August 6, 2026 19:31
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Aug 6, 2026
@vvoland vvoland added the cherry-pick/2.3.x Change to be cherry picked to release/2.3 label Aug 6, 2026

Copilot AI left a comment

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

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.

Pull request overview

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

Suppressed comments (1)

pkg/shim/compat.go:35

  • The error text says the shim "was built against the new API", which can be confusing/misleading for users (it’s really a caller/protocol mismatch). Consider rephrasing to focus on the deprecated shim start protocol and the actionable remediation (restart the containerd daemon after upgrade).
var errDeprecatedBootstrapAPI = errors.New("shim was started through the deprecated API but was built against the new API; if you upgraded containerd, you may need to restart the daemon")

Copilot AI review requested due to automatic review settings August 10, 2026 11:29

Copilot AI left a comment

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.

Pull request overview

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

Suppressed comments (2)

pkg/shim/compat.go:44

  • parseBootstrapParams discards the proto.Unmarshal error and always returns errDeprecatedBootstrapAPI, which can make malformed/partial bootstrap input look like a legacy-caller mismatch. Including the unmarshal failure as context would make startup failures easier to diagnose while still allowing errors.Is(err, errDeprecatedBootstrapAPI) checks.
		return nil, errDeprecatedBootstrapAPI
	}
	return params, nil

pkg/shim/compat.go:41

  • readBootstrapParamsFromDeprecatedFields is now unused (no references in pkg/shim), but remains in this file along with legacy-only imports. If this PR is explicitly removing input-side support for the deprecated startup API, consider deleting the dead helper and trimming compat.go so it only contains the new-protocol validation logic.

This issue also appears on line 42 of the same file.

	params := &bootapi.BootstrapParams{}
	if len(input) == 0 || proto.Unmarshal(input, params) != nil {
		return nil, errDeprecatedBootstrapAPI
	}
	if params.InstanceID != cliID || params.Namespace != cliNamespace {

Copilot AI review requested due to automatic review settings August 10, 2026 11:34

Copilot AI left a comment

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.

Pull request overview

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

Suppressed comments (1)

pkg/shim/compat.go:35

  • parseBootstrapParams currently collapses all parsing/identity failures into errDeprecatedBootstrapAPI by discarding the proto.Unmarshal error. This can make debugging harder (e.g., corrupted/truncated stdin vs. truly deprecated startup) and provides no detail when stdin decodes but the identity doesn't match the CLI values. Consider wrapping errDeprecatedBootstrapAPI with additional context while preserving errors.Is semantics via %w.
var errDeprecatedBootstrapAPI = errors.New("shim was started through the deprecated API but was built against the new API; if you upgraded containerd, you may need to restart the daemon")

// parseBootstrapParams parses input from a caller using the bootstrap API.
// Legacy runtime options can unmarshal as BootstrapParams, so verify the
// identity against the command-line values.

@vvoland
vvoland requested review from dmcgowan and mxpv August 12, 2026 20:28
Comment thread pkg/shim/compat.go Resolved
@github-project-automation github-project-automation Bot moved this from Needs Triage to Needs Update in Pull Request Review Aug 13, 2026
Copilot AI review requested due to automatic review settings August 14, 2026 13:09
@kubernetes-prow kubernetes-prow Bot added size/L and removed size/M labels Aug 14, 2026

Copilot AI left a comment

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.

Pull request overview

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

Suppressed comments (1)

pkg/shim/shim.go:279

  • Using io.ReadAll(io.LimitReader(..., 10<<20)) caps memory, but it can also silently truncate inputs larger than the limit (ReadAll returns nil error). That would later surface as a misleading parse/deprecated-API error. Consider reading limit+1 and returning a clear "stdin too large" error when the payload exceeds the cap.
		// Read stdin into memory so the bootstrap payload can be validated.
		// Protect against unbounded memory consumption with a limit (e.g., 10MB).
		input, err := io.ReadAll(io.LimitReader(os.Stdin, 10<<20))
		if err != nil {
			return fmt.Errorf("failed to read stdin: %w", err)
		}

@vvoland
vvoland requested a review from cpuguy83 August 14, 2026 13:31
Comment thread pkg/shim/compat.go Resolved
A pre-2.3 containerd daemon can start a newly installed shim through the
deprecated CLI, environment, and stdin API.
The shim currently accepts that request but returns a protobuf bootstrap
result, which the old daemon cannot parse.
It treats the protobuf bytes as a socket address and fails later with a
cryptic error:

```
failed to create TTRPC connection: unsupported protocol: \b\x03\x12Yunix
```

This patch makes the shim reject the deprecated startup request before
starting and tell the user that the containerd daemon may need to be
restarted.
The 2.2 daemon includes the shim's stderr in its start error, so this
message reaches the user directly.

This explicitly removes input-side support for the deprecated startup
API, but it does not break a working standard containerd pairing.
Pre-2.3 daemons already cannot consume the response from the new shim.
After a package upgrade, a restarted daemon uses the new bootstrap API.

Custom callers that send the deprecated request format while supporting
the new protobuf response will now also be rejected.

Signed-off-by: Paweł Gronowski <[email protected]>
Copilot AI review requested due to automatic review settings August 17, 2026 13:01

Copilot AI left a comment

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.

Pull request overview

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

Suppressed comments (1)

pkg/shim/compat.go:47

  • When the bootstrap payload unmarshals successfully but the identity doesn’t match the CLI values, the returned error doesn’t include any of the mismatched values. Including the stdin vs CLI instance_id/namespace makes this failure mode actionable (and matches the test’s intent of having “details” for this case), while still wrapping errDeprecatedBootstrapAPI for errors.Is checks.
	if params.InstanceID != cliID || params.Namespace != cliNamespace {
		return nil, fmt.Errorf("bootstrap parameters do not match command-line arguments: %w", errDeprecatedBootstrapAPI)
	}

@github-project-automation github-project-automation Bot moved this from Needs Update to Review In Progress in Pull Request Review Aug 20, 2026
@mxpv
mxpv added this pull request to the merge queue Aug 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 20, 2026
@mxpv
mxpv added this pull request to the merge queue Aug 20, 2026
Merged via the queue into containerd:main with commit 0cdf551 Aug 20, 2026
51 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/runtime Runtime cherry-pick/2.3.x Change to be cherry picked to release/2.3 size/L

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

containerd 2.2 cannot parse the bootstrap response from a 2.3 runc shim

5 participants