Skip to content

Commit

Permalink
[GOBBLIN-2182] Cleanup workdir in Gobblin-on-Temporal execution (#4085)
Browse files Browse the repository at this point in the history
* added cleanup for got controlled with a config
  • Loading branch information
Blazer-007 authored Jan 20, 2025
1 parent a0cef28 commit e584e5b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public interface GobblinTemporalConfigurationKeys {

String GOBBLIN_TEMPORAL_JOB_LAUNCHER_ARG_PREFIX = GOBBLIN_TEMPORAL_JOB_LAUNCHER_PREFIX + "arg.";
String GOBBLIN_TEMPORAL_JOB_LAUNCHER_CONFIG_OVERRIDES = GOBBLIN_TEMPORAL_JOB_LAUNCHER_PREFIX + "config.overrides";
String GOBBLIN_TEMPORAL_WORK_DIR_CLEANUP_ENABLED = PREFIX + "work.dir.cleanup.enabled";
String DEFAULT_GOBBLIN_TEMPORAL_WORK_DIR_CLEANUP_ENABLED = "true";

/**
* Suffix for metrics emitted by GobblinTemporalJobLauncher for preventing collisions with prod jobs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
import org.apache.gobblin.source.workunit.WorkUnit;
import org.apache.gobblin.util.ConfigUtils;
import org.apache.gobblin.util.ParallelRunner;
import org.apache.gobblin.temporal.ddm.util.JobStateUtils;
import org.apache.gobblin.temporal.GobblinTemporalConfigurationKeys;

/**
* An implementation of {@link JobLauncher} that launches a Gobblin job using the Temporal task framework.
Expand Down Expand Up @@ -134,7 +136,11 @@ public void close() throws IOException {
try {
executeCancellation();
} finally {
super.close();
try {
cleanupWorkingDirectory();
} finally {
super.close();
}
}
}

Expand Down Expand Up @@ -277,6 +283,13 @@ protected void cleanupWorkingDirectory() throws IOException {
GobblinClusterUtils.getJobStateFilePath(false, this.appWorkDir, this.jobContext.getJobId());
this.fs.delete(jobStateFilePath, false);
}

if (Boolean.parseBoolean(this.jobProps.getProperty(GobblinTemporalConfigurationKeys.GOBBLIN_TEMPORAL_WORK_DIR_CLEANUP_ENABLED,
GobblinTemporalConfigurationKeys.DEFAULT_GOBBLIN_TEMPORAL_WORK_DIR_CLEANUP_ENABLED))) {
Path workDirRootPath = JobStateUtils.getWorkDirRoot(this.jobContext.getJobState());
log.info("Cleaning up work directory : {} for job : {}", workDirRootPath, this.jobContext.getJobId());
this.fs.delete(workDirRootPath, true);
}
}
}

0 comments on commit e584e5b

Please sign in to comment.