Damans227 commented on code in PR #13592:
URL: https://github.com/apache/cloudstack/pull/13592#discussion_r3624820154


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterActionWorker.java:
##########
@@ -761,6 +761,25 @@ protected void copyScriptFile(String nodeAddress, final 
int sshPort, File file,
         }
     }
 
+    /**
+     * Deletes the local temporary copies of the scripts created by {@link 
#retrieveScriptFiles()}
+     * once they have been copied to the cluster node(s). Without this, every 
deploy/autoscale/PV-cleanup
+     * action leaks a *.sh file in the management server's tmp directory.
+     */
+    protected void cleanupScriptFiles() {
+        deleteScriptFileQuietly(deploySecretsScriptFile);
+        deleteScriptFileQuietly(deployProviderScriptFile);
+        deleteScriptFileQuietly(deployCsiDriverScriptFile);
+        deleteScriptFileQuietly(deletePvScriptFile);
+        deleteScriptFileQuietly(autoscaleScriptFile);
+    }
+
+    protected void deleteScriptFileQuietly(File file) {
+        if (file != null && file.exists() && !file.delete()) {
+            logger.debug("Failed to delete temporary Kubernetes cluster script 
file: {}", file.getAbsolutePath());

Review Comment:
   Nit: this represents a leaked temp file on disk, feels like it should log at 
`warn` rather than `debug`.



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterActionWorker.java:
##########
@@ -761,6 +761,25 @@ protected void copyScriptFile(String nodeAddress, final 
int sshPort, File file,
         }
     }
 
+    /**
+     * Deletes the local temporary copies of the scripts created by {@link 
#retrieveScriptFiles()}

Review Comment:
   Nit: fairly detailed javadoc for a small private helper that just fans out 
to `deleteScriptFileQuietly` calls, could be trimmed.



-- 
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