Skip to content

refactor(sandbox): extract syncStatusFromPod as struct field with syncReadyCondition flag#672

Merged
furykerry merged 5 commits into
openkruise:masterfrom
zmberg:refactor/sync-status-from-pod
Jul 21, 2026
Merged

refactor(sandbox): extract syncStatusFromPod as struct field with syncReadyCondition flag#672
furykerry merged 5 commits into
openkruise:masterfrom
zmberg:refactor/sync-status-from-pod

Conversation

@zmberg

@zmberg zmberg commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

Refactor from a package-level function into a struct field on both and , enabling pluggable behavior for different control structs.

Key Changes

  • Extract as a func field on and , with as the default implementation assigned in constructors
  • Add parameter to control whether Ready condition sync is performed. The upgrade scenario passes (uses upgrade-specific conditions), while normal running/updated paths pass
  • Replace manual pod info sync in with , moved after the Pod Ready check for correctness
  • ** passes ** to for consistent behavior injection

Test Coverage

  • Package total: 95.2%
  • : 100%
  • : 87.8% (uncovered lines are pre-existing error paths unrelated to this change)

Files Changed

  • — struct field, constructor, function signature
  • — struct field, constructor, call site
  • — test construction updates
  • — test construction updates

…cReadyCondition flag

- Extract syncStatusFromPod as a func field on commonControl and UpgradeControl
  to enable pluggable behavior for different control structs
- Add syncReadyCondition bool parameter to control whether Ready condition
  sync is performed (upgrade scenario skips it, using upgrade-specific conditions)
- Replace manual pod info sync in performRecreateUpgrade with
  r.syncStatusFromPod(pod, newStatus, false), called after Pod Ready check
- NewCommonControl passes syncStatusFromPod to NewUpgradeControl for
  consistent behavior injection

Signed-off-by: liheng <liheng.zms@alibaba-inc.com>
Add +kubebuilder:validation:Enum=Recreate;CheckpointRestore to the Type
field and update the comment to list both supported values.

Signed-off-by: liheng <liheng.zms@alibaba-inc.com>
@kruise-bot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from zmberg by writing /assign @zmberg in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

…gyType

Add +kubebuilder:validation:Enum=Recreate;CheckpointRestore to the Type
field of SandboxUpdateOpsStrategy.

Signed-off-by: liheng <liheng.zms@alibaba-inc.com>
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.33%. Comparing base (489c727) to head (2043f41).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #672      +/-   ##
==========================================
- Coverage   80.34%   80.33%   -0.01%     
==========================================
  Files         231      231              
  Lines       18057    18057              
==========================================
- Hits        14507    14506       -1     
- Misses       2963     2964       +1     
  Partials      587      587              
Flag Coverage Δ
unittests 80.33% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

podControl *PodControl,
lifecycleHookFunc LifecycleHookFunc,
initializer SandboxInitializer,
syncStatusFromPod func(pod *corev1.Pod, newStatus *agentsv1alpha1.SandboxStatus, syncCondition bool),

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.

Issue: The struct field declares the func type with parameter name syncReadyCondition bool, but the NewUpgradeControl constructor parameter uses syncCondition bool:
Recommendation: Align the constructor parameter name to syncReadyCondition for consistency and documentation clarity

zmberg added 2 commits July 21, 2026 11:48
The refactoring in commit ee8148d moved PodInfo sync from before the
Pod Ready check to after it. This caused box.Status.PodInfo.PodIP to
remain stale when performRecreateUpgrade returns true and falls through
to PostUpgrade in the same reconcile cycle. GetRuntimeURL(box) would
then connect to an empty/wrong address, causing a 30s timeout.

Fix: create a DeepCopy of box with the latest newStatus before passing
it to executeUpgradeAction. This preserves the original box for
updateSandboxStatus DeepEqual comparison while ensuring the hook
receives the correct PodIP.

Signed-off-by: liheng <liheng.zms@alibaba-inc.com>
Address review feedback: the struct field declares the func type
parameter as syncReadyCondition but the NewUpgradeControl constructor
used syncCondition. Align for consistency and documentation clarity.

Signed-off-by: liheng <liheng.zms@alibaba-inc.com>
@furykerry
furykerry merged commit 2161144 into openkruise:master Jul 21, 2026
21 of 22 checks passed
@zmberg
zmberg deleted the refactor/sync-status-from-pod branch July 21, 2026 05:14
Liquorice-Ma pushed a commit to Liquorice-Ma/agents that referenced this pull request Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants