rancher / rke2

https://docs.rke2.io/
Apache License 2.0
1.45k stars 258 forks source link

[Release-1.27] - Errors when uninstalling rke2 from windows agent #5959

Closed manuelbuil closed 1 month ago

manuelbuil commented 2 months ago

Backport fix for Errors when uninstalling rke2 from windows agent

mdrahman-suse commented 2 months ago

@manuelbuil Still seeing the issue and error with default option [Y] Yes on commit 84b52ee6

PS C:\Users\Administrator> C:\usr\local\bin\rke2.exe -v
rke2.exe version v1.27.14+dev.84b52ee6 (984587f8a3a153892a799b407254a298b17dc22e)
go version go1.21.9
PS C:\Users\Administrator> c:/usr/local/bin/rke2-uninstall.ps1
Beginning the uninstall process

    Directory: C:\var\lib\rancher\rke2\bin

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         5/30/2024   1:54 AM              0 rke2-uninstall.lock

Confirm
Are you sure you want to perform the Stop-Process operation on the following item: kubelet(4024)?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
docker.io/mbuilsuse/pstools:v0.2.0
docker.io/mbuilsuse/pstools@sha256:2f7abee3e5ecc3c672cb1054ac053dab4e149ad2e51ab3143c43106c9c6fe335
docker.io/phillipsj/pstools:v0.2.0
docker.io/phillipsj/pstools@sha256:2f7abee3e5ecc3c672cb1054ac053dab4e149ad2e51ab3143c43106c9c6fe335
docker.io/rancher/pause:3.6
docker.io/rancher/pause@sha256:036d575e82945c112ef84e4585caff3648322a2f9ed4c3a6ce409dd10abc4f34
docker.io/rancher/rke2-runtime:v1.27.14-dev.84b52ee6-windows-amd64
sha256:2a67292b6e8ba4e1c56ccccb591a5c75ed50daa015d16c13032110e718e1e520
sha256:6e79fa543017c14fed085e06536e456c8fdd93a5b8237500f1dcae0914a77206
sha256:9aa6faee59d33943b3a48966970f7e21382c511f705a714a7465a1bfa7f8d57f
time="2024-05-30T01:54:41Z" level=error msg="unable to delete k8s.io" error="namespace \"k8s.io\" must be empty, but it still has blobs, snapshots on \"windows\" snapshotter: failed precondition"
ctr: unable to delete k8s.io: namespace "k8s.io" must be empty, but it still has blobs, snapshots on "windows" snapshotter: failed precondition
time="2024-05-30T01:54:46Z" level=error msg="unable to delete k8s.io" error="namespace \"k8s.io\" must be empty, but it still has blobs, snapshots on \"windows\" snapshotter: failed precondition"
ctr: unable to delete k8s.io: namespace "k8s.io" must be empty, but it still has blobs, snapshots on "windows" snapshotter: failed precondition
time="2024-05-30T01:54:52Z" level=error msg="unable to delete k8s.io" error="namespace \"k8s.io\" must be empty, but it still has blobs, snapshots on \"windows\" snapshotter: failed precondition"
ctr: unable to delete k8s.io: namespace "k8s.io" must be empty, but it still has blobs, snapshots on "windows" snapshotter: failed precondition
time="2024-05-30T01:54:57Z" level=error msg="unable to delete k8s.io" error="namespace \"k8s.io\" must be empty, but it still has blobs, snapshots on \"windows\" snapshotter: failed precondition"
ctr: unable to delete k8s.io: namespace "k8s.io" must be empty, but it still has blobs, snapshots on "windows" snapshotter: failed precondition
time="2024-05-30T01:55:02Z" level=error msg="unable to delete k8s.io" error="namespace \"k8s.io\" must be empty, but it still has blobs, snapshots on \"windows\" snapshotter: failed precondition"
ctr: unable to delete k8s.io: namespace "k8s.io" must be empty, but it still has blobs, snapshots on "windows" snapshotter: failed precondition
time="2024-05-30T01:55:07Z" level=error msg="unable to delete k8s.io" error="namespace \"k8s.io\" must be empty, but it still has blobs, snapshots on \"windows\" snapshotter: failed precondition"
ctr: unable to delete k8s.io: namespace "k8s.io" must be empty, but it still has blobs, snapshots on "windows" snapshotter: failed precondition
Unable to remove all namespaces
INFO: Checking if rke2 process exists
INFO: rke2 process found, stopping now

Confirm
Are you sure you want to perform the Stop-Process operation on the following item: rke2(5824)?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
INFO: Checking if kube-proxy process exists
INFO: kube-proxy process found, stopping now

Confirm
Are you sure you want to perform the Stop-Process operation on the following item: kube-proxy(5308)?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
INFO: Checking if kubelet process exists
INFO: Checking if containerd process exists
INFO: containerd process found, stopping now

Confirm
Are you sure you want to perform the Stop-Process operation on the following item: containerd(4612)?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
INFO: Checking if wins process exists
INFO: Checking if calico-node process exists
INFO: Checking if flanneld process exists
INFO: Checking if rke2 service exists
INFO: rke2 service found, stopping now
INFO: rke2 service has stopped. Removing the rke2 service ...
[SC] DeleteService SUCCESS
INFO: Checking if wins service exists
INFO: Cleaning c:/usr...
INFO: Cleaning c:/etc...
INFO: Cleaning c:/run...
INFO: c:/run is empty, moving on
INFO: Cleaning c:/var...
ForEach-Object : Exception calling "Delete" with "0" argument(s): "Access to the path 'Public' is denied."
At C:\usr\local\bin\rke2-uninstall.ps1:183 char:78
+ ... ir -Recurse -Attributes ReparsePoint | ForEach-Object { $_.Delete() }
+                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ForEach-Object], MethodInvocationException
    + FullyQualifiedErrorId : IOException,Microsoft.PowerShell.Commands.ForEachObjectCommand

FYI, I dont see it if I use [A] Yes to All option

mdrahman-suse commented 1 month ago

Validated on release-1.27 with commit c852d3c7

Testing

Steps: https://github.com/rancher/rke2/issues/5778#issuecomment-2155672939

Validation

PS C:\Users\Administrator> C:\usr\local\bin\rke2.exe -v
rke2.exe version v1.27.14+dev.c852d3c7 (c852d3c71b5fdd741a7df7513836ef719087e282)
go version go1.21.9
PS C:\Users\Administrator> c:/usr/local/bin/rke2-uninstall.ps1
Beginning the uninstall process

    Directory: C:\var\lib\rancher\rke2\bin

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        6/11/2024   4:33 PM              0 rke2-uninstall.lock

Confirm
Are you sure you want to perform the Stop-Process operation on the following item: kubelet(3844)?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
time="2024-06-11T16:33:07Z" level=warning msg="task 5840d9b4baad0acb5d312d88245d4068c2c1330145c55ea118ea1493cf85dbbc exit with non-zero exit code 1067"
...
Tasks, containers, images and snapshots are being deleted. This may take a while (timeout 180s)
k8s.io
All containerd resources have been deleted
INFO: Checking if rke2 process exists
INFO: rke2 process found, stopping now

Confirm
Are you sure you want to perform the Stop-Process operation on the following item: rke2(4028)?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
INFO: Checking if kube-proxy process exists
INFO: kube-proxy process found, stopping now

Confirm
Are you sure you want to perform the Stop-Process operation on the following item: kube-proxy(3504)?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
INFO: Checking if kubelet process exists
INFO: Checking if containerd process exists
INFO: containerd process found, stopping now

Confirm
Are you sure you want to perform the Stop-Process operation on the following item: containerd(1456)?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
INFO: Checking if wins process exists
INFO: Checking if calico-node process exists
INFO: Checking if flanneld process exists
INFO: Checking if rke2 service exists
INFO: rke2 service found, stopping now
INFO: rke2 service has stopped. Removing the rke2 service ...
[SC] DeleteService SUCCESS
INFO: Checking if wins service exists
INFO: Cleaning c:/usr...
INFO: Cleaning c:/etc...
INFO: Cleaning c:/run...
INFO: Cleaning c:/var...
INFO: Cleaning ...
INFO: Cleaning ...
INFO: Cleaning ...
INFO: Cleaning Temp Install Directory...
INFO: Cleaning RKE2 Environment Variables
INFO: Cleaning RKE2 Machine Environment Variables
INFO: Cleaning CATTLE_AGENT_BIN_PREFIX
INFO: HNS will be cleaned next, temporary network disruption may occur. HNS cleanup is the final step.
INFO: Cleaning up HnsNetwork nat ...
INFO: Cleaning up HnsNetwork flannel.4096 ...