carp84 commented on a change in pull request #10768: [FLINK-15012][checkpoint] Introduce shutdown to CheckpointStorageCoordinatorView to clean up checkpoint directory. URL: https://github.com/apache/flink/pull/10768#discussion_r386013013
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/state/filesystem/FsCheckpointStorage.java ########## @@ -134,6 +149,37 @@ public CheckpointStorageLocation initializeLocationForCheckpoint(long checkpoint writeBufferSize); } + @Override + public void shutDown(JobStatus jobStatus) throws IOException { + if (checkpointProperties != null) { + boolean discardCheckpointFolders = false; + switch (jobStatus) { + case FAILED: + discardCheckpointFolders = checkpointProperties.discardOnJobFailed(); + break; + case CANCELED: + discardCheckpointFolders = checkpointProperties.discardOnJobCancelled(); + break; + case FINISHED: + discardCheckpointFolders = checkpointProperties.discardOnJobFinished(); + break; + case SUSPENDED: + discardCheckpointFolders = checkpointProperties.discardOnJobSuspended(); + break; + } + if (discardCheckpointFolders) { + fileSystem.delete(taskOwnedStateDirectory, true); + fileSystem.delete(sharedStateDirectory, true); + fileSystem.delete(checkpointsDirectory, true); + } Review comment: ```suggestion if (jobStatus == JobStatus.FINISHED && checkpointProperties.discardOnJobFinished() || jobStatus == JobStatus.CANCELED && checkpointProperties.discardOnJobCancelled() || jobStatus == JobStatus.FAILED && checkpointProperties.discardOnJobFailed() || jobStatus == JobStatus.SUSPENDED && checkpointProperties.discardOnJobSuspended()) { doDiscard(); } ``` Simplify the logic referring to `CompletedCheckpoint#discardOnShutdown` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services