-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve rke2-uninstall.ps1 script #5779
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, do you think we should add a blurb in the docs calling out the need to drain the node before running this script?
4f9b86b
to
6622d4a
Compare
6622d4a
to
0075531
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5779 +/- ##
=======================================
Coverage 26.46% 26.46%
=======================================
Files 30 30
Lines 2649 2649
=======================================
Hits 701 701
Misses 1903 1903
Partials 45 45
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
0e6961a
to
6324be7
Compare
bundle/bin/rke2-uninstall.ps1
Outdated
New-Item -ItemType File -Path $lockFilePath -Force | ||
} else { | ||
# ctr should exist at this point but just in case we add this log | ||
Write-Host "Command ctr not found. Aumatica uninstallation might fail" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit on spelling/grammar:
Write-Host "Command ctr not found. Aumatica uninstallation might fail" | |
Write-Host "ctr.exe not found, container cleanup and RKE2 uninstallation is unlikely to succeed." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh! Thanks, I missed that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with warning nit
6324be7
to
e04c655
Compare
bundle/bin/rke2-uninstall.ps1
Outdated
if ($command) { | ||
$executablePath = $command.Source | ||
$dataBinDirDirectory = Split-Path -Parent $executablePath | ||
$lockFilePath = Join-Path -Path $directory -ChildPath "rke2-uninstall.lock" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking back over this with the new changes, I don't see $directory
being set anywhere, looks like it should be $dataBinDirDirectory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch! Let me retest this carefully again
Signed-off-by: Manuel Buil <[email protected]>
e04c655
to
d58842e
Compare
restested and works :) |
Proposed Changes
This PR tries to fix the current implementation of the rke2-uninstall.ps1 script. Often this script fails to remove everything from the node because by the time it tries to remove the containerd namespace, there are still resources in that namespace. As a consequence, we end up with files in /var/lib/rancher/agent/ which are impossible to remove because according to Windows, they are locked. To remove them, a restart normally works but not always.
This PR does two things:
1 - The rke2-uninstall.ps1 would create a lock file in the dataDir. Then it will kill kubelet. In the pebinary code, we won't restart kubelet if that lock file exists
2 - It retries removing the namespace for a few times, in case the previous trial failed. There might be situations where the script can't succeed (e.g. user forgot to drain). For those cases, it gives up after 30 seconds and continues deleting other stuff, as it does today
Types of Changes
Bugfix
Verification
Install rke2 on linux and windows. Deploy a pod in windows. Run the rke2-uninstall.ps1 script. Without this PR, half of the time the script will fail and it will be impossible to remove the directory /var/lib/rancher.
With this PR, the script works and /var/lib/rancher does not exist anymore
Testing
Linked Issues
#5778
rancher/rancher#45016
User-Facing Change
Further Comments