Commit 9f72e75
committed
kubernetes: clean up temporary provisioning scripts on the management server
The CKS action workers copy provisioning scripts (deploy-cloudstack-secret,
deploy-provider, deploy-csi-driver, delete-pv-reclaimpolicy-delete,
autoscale-kube-cluster and upgrade-kubernetes.sh) to the cluster nodes via
retrieveScriptFiles() + copyScripts()/copyScriptFile(). Each script is written
to a local temp file via File.createTempFile(), but that local copy is never
deleted after it has been SCP'd to the node.
As a result every cluster deploy, provider/CSI deploy, autoscale enable, PV
cleanup and Kubernetes upgrade leaks one *.sh file per script into the
management server's temp directory, growing without bound over the cluster
lifetime. On a long-running management server this accumulates to hundreds of
stale scripts in /tmp.
This adds cleanupScriptFiles()/deleteScriptFileQuietly() to the base action
worker and invokes it in a finally block around every copy site
(deployProvider, deployCsiDriver, autoscaleCluster, deletePVsWithReclaimPolicyDelete
and the upgrade worker), so the local temp copies are removed once they have
been transferred to the node. The upgrade worker additionally removes its
upgrade-kubernetes.sh temp file after the node loop completes.
No functional change to the provisioning itself: the scripts are still written,
copied and executed exactly as before; only the leftover local copies are
deleted.
Covered by new unit tests for cleanupScriptFiles()/deleteScriptFileQuietly()
(temp files deleted, null/missing files handled without throwing).1 parent a503a52 commit 9f72e75
4 files changed
Lines changed: 106 additions & 16 deletions
File tree
- plugins/integrations/kubernetes-service/src
- main/java/com/cloud/kubernetes/cluster/actionworkers
- test/java/com/cloud/kubernetes/cluster/actionworkers
Lines changed: 29 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
761 | 761 | | |
762 | 762 | | |
763 | 763 | | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
764 | 783 | | |
765 | 784 | | |
766 | 785 | | |
| |||
820 | 839 | | |
821 | 840 | | |
822 | 841 | | |
823 | | - | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
824 | 847 | | |
825 | 848 | | |
826 | 849 | | |
| |||
857 | 880 | | |
858 | 881 | | |
859 | 882 | | |
860 | | - | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
861 | 888 | | |
862 | 889 | | |
863 | 890 | | |
| |||
Lines changed: 21 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
951 | 951 | | |
952 | 952 | | |
953 | 953 | | |
954 | | - | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
955 | 959 | | |
956 | 960 | | |
957 | 961 | | |
| |||
1003 | 1007 | | |
1004 | 1008 | | |
1005 | 1009 | | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
1014 | 1024 | | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
| 1025 | + | |
| 1026 | + | |
1019 | 1027 | | |
1020 | 1028 | | |
1021 | 1029 | | |
| |||
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| |||
176 | 182 | | |
177 | 183 | | |
178 | 184 | | |
179 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
180 | 190 | | |
181 | 191 | | |
182 | 192 | | |
| |||
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
232 | 277 | | |
0 commit comments