Skip to content

Comments

Fix/kubelet idempotency#2511

Open
Aman-Cool wants to merge 2 commits intoopenyurtio:masterfrom
Aman-Cool:fix/kubelet-idempotency
Open

Fix/kubelet idempotency#2511
Aman-Cool wants to merge 2 commits intoopenyurtio:masterfrom
Aman-Cool:fix/kubelet-idempotency

Conversation

@Aman-Cool
Copy link
Contributor

Make kubelet redirect/revert idempotent

Summary

Fixes unnecessary kubelet restarts during YurtHub convert/revert by making the operations truly idempotent.
Kubelet is now restarted only when configuration or environment actually changes.

Root Cause

Kubelet config helpers did not indicate whether they modified state, so convert/revert paths always restarted kubelet—even when the node was already correctly configured.

Fix

  • Return change status from kubelet config helpers
  • Restart kubelet only on real config/env changes
  • Add tests to verify no-op vs change behavior

Impact

  • Eliminates redundant kubelet restarts
  • Safe for reconciliation loops
  • Enables reliable label-driven YurtHub automation

Backward Compatibility

No breaking changes. Behavior is unchanged except redundant restarts are avoided.

When the NodeAutonomy condition status changes, LastTransitionTime
was never updated due to a copy-paste bug where LastHeartbeatTime
was set twice instead of setting LastTransitionTime on the second line.

This caused stale transition timestamps in the node condition, breaking
observability, alerting, and debugging for edge node autonomy state
changes.

Signed-off-by: Aman-Cool <aman017102007@gmail.com>
@Aman-Cool Aman-Cool requested a review from a team as a code owner February 1, 2026 10:41
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 1, 2026

@Aman-Cool
Copy link
Contributor Author

@vie-serendipity @zyjhtangtang ,Fixes repeated kubelet restarts by making redirect/revert idempotent. Kubelet restarts only on real config or env changes.

@codecov
Copy link

codecov bot commented Feb 1, 2026

Codecov Report

❌ Patch coverage is 17.50000% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.16%. Comparing base (ed4eb0a) to head (4ecfba0).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
pkg/node-servant/components/kubelet.go 15.38% 33 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2511      +/-   ##
==========================================
+ Coverage   44.09%   44.16%   +0.06%     
==========================================
  Files         399      399              
  Lines       26554    26585      +31     
==========================================
+ Hits        11710    11740      +30     
+ Misses      13782    13780       -2     
- Partials     1062     1065       +3     
Flag Coverage Δ
unittests 44.16% <17.50%> (+0.06%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@Aman-Cool
Copy link
Contributor Author

@zhangzhenyuyu ,quick ping — this PR is ready for review and CI is passing.
Please let me know if you’re the right person to review or if I should loop someone else in. Thanks!

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.

1 participant