Skip to content

Commit

Permalink
recreate job
Browse files Browse the repository at this point in the history
  • Loading branch information
cmendesce committed Jul 29, 2024
1 parent cd4fd7d commit d305fca
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ private Job createLoadGenerationJob(Scenario scenario, ExecutionQueue executionQ

private void runJob(Job job) {
var jobsClient = kubernetesClient.batch().v1().jobs();
job = jobsClient.resource(job).create();
var createdJob =
jobsClient.inNamespace(job.getMetadata().getNamespace()).withName(job.getMetadata().getName()).get();
if (createdJob != null) {
jobsClient.resource(createdJob).delete();
}
jobsClient.resource(job).create();
jobsClient.resource(job).watch(this);
logger.info("Job created: {}", job.getMetadata().getName());
}
Expand All @@ -106,7 +111,6 @@ private void runScenario(String namespace, String scenarioName, ExecutionQueue e
runPreparationSteps(scenario.get(), executionQueue);
var job = createLoadGenerationJob(scenario.get(), executionQueue);
runJob(job);
logger.info("Job created: {}", job.getMetadata().getName());
} else {
throw new RuntimeException(format("Scenario not found: %s.%s", namespace, scenarioName));
}
Expand Down

0 comments on commit d305fca

Please sign in to comment.