Skip to content

adaptation: fix splitting Synchronize messages. - #367

Open
klihub wants to merge 1 commit into
containerd:mainfrom
klihub:fixes/split-synchronize-panic
Open

klihub wants to merge 1 commit into
containerd:mainfrom
klihub:fixes/split-synchronize-panic

Conversation

@klihub

@klihub klihub commented Nov 27, 2026

Copy link
Copy Markdown
Member

This PR combines ideas and test cases from #356 and #364, reworks the tests to live in the adaptation_test package, adds a few necessary extra fixes, and test cases. Credits go largely to @alex-chenc and @pandaWall and they are marked as co-authors.

In particular this PR fixes handling oversized Synchronize messages to

  • not attempt to access outside of slice bounds and panic
  • always reduce the number of objects sent after an oversized message
  • split a state of fewer than eight objects instead of giving up
  • never send an empty message unless we have no pods and containers
  • give up if we can't send a single object

Move the synchronization tests to adaptation_suite_test.go, with cases for a state which never fits a message and one which splits down to a single object per message.

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.

🟢 Approval recommended

No active review issues are recorded for the synchronization-batching change.

No open issues 🎉

What changed in this PR

Fixes oversized plugin synchronization requests by safely splitting runtime state into smaller messages, addressing the slice-bound panics and retry failures described in #356 and #364.

Changes:

  • Uses one object limit and derives safe pod and container slice bounds from the remaining state.
  • Ensures oversized retries shrink, supports batches below eight objects, and stops when a single object cannot fit.
  • Adds transport-level and builtin-plugin regression tests for uneven snapshots, small batches, and states that never fit.
File Description
pkg/​adaptation/​plugin.go Reworks synchronization batching and oversized-message retry limits.
pkg/​adaptation/​adaptation_suite_test.go Adds regression tests for safe splitting, retry progress, and terminal failure.

Review effort: Balanced

@klihub
klihub requested a review from mikebrow November 27, 2026 16:19
@klihub
klihub force-pushed the fixes/split-synchronize-panic branch from 76fde90 to cc615ad Compare November 27, 2026 16:25
@klihub
klihub requested a balanced review from Copilot November 27, 2026 16:29

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.

🟢 Approval recommended

No active review issues are reported for the synchronization request batching changes.

No open issues 🎉

Review effort: Balanced

@klihub
klihub requested a review from chrishenzie November 27, 2026 16:37
@mikebrow

Copy link
Copy Markdown
Member

there's a typo in the commit header.. panadaWall vs pandaWall

@mikebrow

Copy link
Copy Markdown
Member

A follow-up is needed to document the split-message protocol. A plugin author would not know that a plugin may receive several Synchronize messages, or that it must reply with More set to match the request and return no updates until the last message. Maybe document it for the more field in api.proto.

@pandaWall

Copy link
Copy Markdown
Contributor

there's a typo in the commit header.. panadaWall vs pandaWall

Thank you very much for the detailed review. My ID is pandaWall。
Thank you again, @mikebrow @klihub @alex-chenc

Fix handling oversized Synchronize messages to
- not attempt to access outside of slice bounds and panic
- always reduce the number of objects sent after an oversized message
- split a state of fewer than eight objects instead of giving up
- never send an empty message unless we have no pods and containers
- give up if we can't send a single object

Move the synchronization tests to adaptation_suite_test.go, with cases
for a state which never fits a message and one which splits down to a
single object per message.

Co-developed-by: chenchen <424509874@qq.com>
Co-developed-by: pandaWall <mangosteen922@126.com>
Assisted-by: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
@klihub
klihub force-pushed the fixes/split-synchronize-panic branch from cc615ad to 1fedccc Compare November 28, 2026 07:09
@klihub

klihub commented Nov 28, 2026 •

Copy link
Copy Markdown
Member Author

A follow-up is needed to document the split-message protocol. A plugin author would not know that a plugin may receive several Synchronize messages, or that it must reply with More set to match the request and return no updates until the last message. Maybe document it for the more field in api.proto.

@mikebrow There is no protocol change introduced here, and the mechanism is hidden from plugin authors. The stub collects split messages, combines them to a single one and delivers it to the plugin as a single event. This just fixes a potential panic and a few other problems in the existing message splitting logic.

@klihub

klihub commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

there's a typo in the commit header.. panadaWall vs pandaWall

Thank you very much for the detailed review. My ID is pandaWall。 Thank you again, @mikebrow @klihub @alex-chenc

Sorry. Fixed it in this PR. But did you notice that in your tree all your signoffs use panadaWall, not pandaWall. That is where this mistake came from. Also in your other repo/tree. For instance

$ git log -1 172a0c016138b1dcd058660140b59e46db7cf2a0 | grep Wall
Author: panadaWall <mangosteen922@126.com>
    Signed-off-by: panadaWall <mangosteen922@126.com>

@pandaWall

Copy link
Copy Markdown
Contributor

there's a typo in the commit header.. panadaWall vs pandaWall

Thank you very much for the detailed review. My ID is pandaWall。 Thank you again, @mikebrow @klihub @alex-chenc

Sorry. Fixed it in this PR. But did you notice that in your tree all your signoffs use panadaWall, not pandaWall. That is where this mistake came from. Also in your other repo/tree. For instance

$ git log -1 172a0c016138b1dcd058660140b59e46db7cf2a0 | grep Wall
Author: panadaWall <mangosteen922@126.com>
    Signed-off-by: panadaWall <mangosteen922@126.com>

Thank you for the fix and for thoroughly investigating the issue in the codebase rather than just patching that single line of code. And yes — that extra a was 100% mine, not a rebase artifact.

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.

5 participants