Skip to content

fix(kubernetes): fail sandbox after main container restart - #1482

Open
ruirui6946 wants to merge 13 commits into
opensandbox-group:mainfrom
ruirui6946:fix/batchsandbox-restart-status-1450
Open

ruirui6946 wants to merge 13 commits into
opensandbox-group:mainfrom
ruirui6946:fix/batchsandbox-restart-status-1450

Conversation

@ruirui6946

@ruirui6946 ruirui6946 commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • mark a succeeded BatchSandbox as failed when its main sandbox container terminates or restarts after the corresponding endpoint is published
  • persist a compact, BatchSandbox-UID-bound restart snapshot on each Pod before endpoint publication, preserving detection across scaling and transient Pending states without changing Ready condition semantics
  • refresh snapshots while endpoints are unpublished, fail closed after publication, and distinguish replacement Pods by Pod UID so pre-allocation/pre-publication restart history remains ignored
  • watch allocated pooled Pods and map their status changes back to the active BatchSandbox; supporting sidecar restarts remain ignored
  • migrate legacy aggregate baselines while keeping endpoint annotation readers backward compatible

Testing

  • go test -v ./internal/controller -run '^(TestBuildRuntimeView|TestGetPodFailureReasonAndMessage|TestPersistRuntimeView|TestFindBatchSandboxesForPooledPod)' -count=1
  • go test ./internal/controller -run '^Test[^C]' -count=1
  • Tencent Cloud Linux: make test ENVTEST_K8S_VERSION=1.33.0 (manifests, generate, fmt, vet, and all non-E2E packages with envtest; controller coverage 79.7%)
  • generated output comparison after make test (no content drift)
  • git diff --check

Fixes #1450

Copilot AI lite review requested due to automatic review settings August 12, 2026 09:40
@github-actions github-actions Bot added component/k8s For kubernetes runtime size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 12, 2026
@ruirui6946
ruirui6946 force-pushed the fix/batchsandbox-restart-status-1450 branch from c592784 to eaa4329 Compare August 12, 2026 09:42

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

Updates the Kubernetes BatchSandbox status controller so a sandbox that previously reached Succeed is transitioned to Failed if the main (first) container restarts after the sandbox became ready, preventing “Succeeded” from masking a reset runtime (e.g., OOM + restart) as described in #1450.

Changes:

  • Extend pod failure detection to treat a post-ready main-container restart as a failure signal (while ignoring sidecar restarts).
  • Introduce a restart-detection baseline keyed off the existing Ready transition time plus stable generation/replica count and stable endpoint membership.
  • Add focused unit tests covering post-ready restarts, pre-ready restart history, sidecar restarts, and baseline resets when pod membership changes.

Reviewed changes

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

File Description
kubernetes/internal/controller/batchsandbox_status.go Adds restart detection logic and a baseline mechanism, and wires it into steady-state runtime phase evaluation.
kubernetes/internal/controller/batchsandbox_pause_resume_test.go Adds new test cases validating the new restart-based failure behavior and baseline reset behavior.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c592784c5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated
@ruirui6946
ruirui6946 force-pushed the fix/batchsandbox-restart-status-1450 branch 2 times, most recently from 10a2c94 to 02f162f Compare August 12, 2026 09:48
@ruirui6946

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@ruirui6946
ruirui6946 force-pushed the fix/batchsandbox-restart-status-1450 branch from 02f162f to 4141987 Compare August 12, 2026 09:51

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41419870f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated
@github-actions github-actions Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 12, 2026
Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d3aa4ab7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated
Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated
@Pangjiping Pangjiping self-assigned this Aug 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcc16e9b6b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b44c4452c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a087245bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ace0ef4de3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated
Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 49da87fa7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated
Comment thread kubernetes/internal/controller/batchsandbox_status.go Outdated
@ruirui6946

Copy link
Copy Markdown
Contributor Author

Addressed all five remaining review threads in 48b0388 and synced the branch with current main at 51c0b2c. The full Kubernetes make test suite now passes on Tencent Cloud Linux with Kubernetes 1.33 envtest assets (controller coverage 79.7%), including manifests, generation, formatting, vet, and all non-E2E packages. All review threads are resolved. The new external-fork workflow runs are currently action_required; please approve them when convenient. Ready for re-review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/k8s For kubernetes runtime size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggest Features: 优化BatchSandbox状态维护机制

5 participants