From d305fca1c5f6277a8026136a267deb677421040a Mon Sep 17 00:00:00 2001 From: Carlos Mendes Date: Mon, 29 Jul 2024 19:08:45 -0300 Subject: [PATCH] recreate job --- .../io/resiliencebench/execution/ScenarioExecutor.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resilience-bench/operator/src/main/java/io/resiliencebench/execution/ScenarioExecutor.java b/resilience-bench/operator/src/main/java/io/resiliencebench/execution/ScenarioExecutor.java index c9d9bfb..86f7ed7 100644 --- a/resilience-bench/operator/src/main/java/io/resiliencebench/execution/ScenarioExecutor.java +++ b/resilience-bench/operator/src/main/java/io/resiliencebench/execution/ScenarioExecutor.java @@ -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()); } @@ -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)); }