Skip to content

Comments

Fix/yurthub uninstall idempotency#2514

Open
Aman-Cool wants to merge 4 commits intoopenyurtio:masterfrom
Aman-Cool:fix/yurthub-uninstall-idempotency
Open

Fix/yurthub uninstall idempotency#2514
Aman-Cool wants to merge 4 commits intoopenyurtio:masterfrom
Aman-Cool:fix/yurthub-uninstall-idempotency

Conversation

@Aman-Cool
Copy link
Contributor

Summary

Fixes a broken idempotency bug in UnInstall() where an early return skips YurtHub process shutdown and cache cleanup when the config directory is missing.

Problem

If /var/lib/yurthub does not exist (common after partial or interrupted uninstalls), UnInstall() returns success early and leaves /etc/kubernetes/cache/ intact. On reinstall, YurtHub reuses stale cached data.

Fix

Remove the early return.
Skip config deletion if missing, but always wait for YurtHub to exit and clean the cache directory.

Impact

  • Restores true idempotency
  • Ensures uninstall → install cycles converge to a clean state
  • Prevents stale cache reuse on edge nodes
  • Unblocks label-driven YurtHub automation

Small, safe change (~5 lines) with no behavior regression.

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 23:17
@Aman-Cool
Copy link
Contributor Author

Aman-Cool commented Feb 1, 2026

@vie-serendipity @zyjhtangtang ,Tiny edge-case fix: uninstall was exiting early if the config dir was already gone, silently leaving stale cache behind—this makes uninstall truly clean and idempotent.

@codecov
Copy link

codecov bot commented Feb 1, 2026

Codecov Report

❌ Patch coverage is 14.58333% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.27%. Comparing base (ed4eb0a) to head (5e4bfdf).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
pkg/node-servant/components/kubelet.go 15.38% 33 Missing ⚠️
pkg/node-servant/components/yurthub.go 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2514      +/-   ##
==========================================
+ Coverage   44.09%   44.27%   +0.17%     
==========================================
  Files         399      399              
  Lines       26554    26593      +39     
==========================================
+ Hits        11710    11775      +65     
+ Misses      13782    13752      -30     
- Partials     1062     1066       +4     
Flag Coverage Δ
unittests 44.27% <14.58%> (+0.17%) ⬆️

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.

@zyjhtangtang
Copy link

@Aman-Cool Please focus on the blocking issues in the code detection.

Add tests to improve coverage for kubelet.go and yurthub.go:

- Add TestUndoWriteYurthubKubeletConfig_FileNotExists/FileExists
  to cover the undo cleanup path in kubelet.go
- Add yurthub_test.go with tests for UnInstall cleanup logic:
  - TestGetYurthubYaml, TestGetYurthubConf, TestGetYurthubCacheDir
  - TestNewYurthubOperator
  - TestYurthubYamlCleanup_FileNotExists/FileExists
  - TestYurthubConfDirCleanup_DirNotExists/DirExists
  - TestCacheDirCleanup
@Aman-Cool Aman-Cool force-pushed the fix/yurthub-uninstall-idempotency branch from 1812483 to 5e4bfdf Compare February 4, 2026 15:07
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

@Aman-Cool
Copy link
Contributor Author

@zyjhtangtang ,CI is green now. Thanks for the feedback.
I’ve addressed the blocking coverage issues.

@Aman-Cool
Copy link
Contributor Author

Aman-Cool commented Feb 7, 2026

@zyjhtangtang Hi, just a gentle follow-up. I’ve addressed the coverage issues and CI is green now.
Whenever it’s convenient, I’d appreciate you taking another look. Thanks for your time.

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.

2 participants