nikolauseppinger opened a new pull request, #13592:
URL: https://github.com/apache/cloudstack/pull/13592

   ### Description
   
   The CKS action workers copy provisioning scripts to the cluster nodes via
   `retrieveScriptFiles()` + `copyScripts()` / `copyScriptFile()`. Each script 
is
   written to a local temp file with `File.createTempFile(filename, ".sh")` in
   `retrieveScriptFile()`, but that local copy on the management server 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:
   
   ```
   -rw-r--r--. 1 cloud cloud 3230 ... 
autoscale-kube-cluster10402639792822688389.sh
   -rw-r--r--. 1 cloud cloud 7197 ... 
delete-pv-reclaimpolicy-delete10664788910304997694.sh
   -rw-r--r--. 1 cloud cloud 2303 ... 
deploy-cloudstack-secret10522058804386657778.sh
   -rw-r--r--. 1 cloud cloud 1811 ... deploy-csi-driver1118819744193036791.sh
   -rw-r--r--. 1 cloud cloud 1472 ... deploy-provider10072339396849174814.sh
   -rw-r--r--. 1 cloud cloud 4971 ... 
upgrade-kubernetes.sh10982436999748062804.sh
   ... (dozens more, one set per CKS action)
   ```
   
   This PR adds `cleanupScriptFiles()` / `deleteScriptFileQuietly()` to the base
   `KubernetesClusterActionWorker` and invokes it in a `finally` block around
   every copy site:
   
   - `KubernetesClusterActionWorker.deployProvider()`
   - `KubernetesClusterActionWorker.deployCsiDriver()`
   - `KubernetesClusterResourceModifierActionWorker.autoscaleCluster()`
   - 
`KubernetesClusterResourceModifierActionWorker.deletePVsWithReclaimPolicyDelete()`
   - `KubernetesClusterUpgradeWorker` (overrides `cleanupScriptFiles()` to also 
remove
     its `upgrade-kubernetes.sh` temp file, cleaned up after the per-node 
upgrade loop
     completes since the same file is reused across nodes)
   
   There is no functional change to the provisioning itself: the scripts are 
still
   written, copied and executed exactly as before; only the leftover local 
copies
   on the management server are removed once they have been transferred.
   
   ### Types of changes
   - [x] Bug fix (non-breaking change which fixes an issue)
   
   ### Feature/Enhancement Scale
   - [x] Community
   
   ### Bug Severity
   - [x] Minor
   
   ### How Has This Been Tested?
   
   - New unit tests in `KubernetesClusterActionWorkerTest` covering
     `cleanupScriptFiles()` and `deleteScriptFileQuietly()` (temp files are 
deleted;
     `null` and missing files are handled without throwing).
   - `mvn -pl plugins/integrations/kubernetes-service test` is green:
     `Tests run: 131, Failures: 0, Errors: 0, Skipped: 0` (14 in
     `KubernetesClusterActionWorkerTest`, including the 3 new ones).
   - Full reactor build up to the kubernetes-service module builds successfully
     (`mvn -pl plugins/integrations/kubernetes-service -am install 
-DskipTests`).
   
   Observed on a CloudStack 4.x management server running CKS clusters; the code
   path is unchanged on `main`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to