New error message for task deletion (#14008)

* New error message

* Add unit test
This commit is contained in:
George Shiqi Wu 2023-04-03 17:26:09 -04:00 committed by GitHub
parent 217b0f6832
commit 4560b9d8aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -133,7 +133,7 @@ public class DruidKubernetesPeonClient implements KubernetesPeonClient
if (result) {
log.info("Cleaned up k8s task: %s", taskId);
} else {
log.info("Failed to cleanup task: %s", taskId);
log.info("K8s task does not exist: %s", taskId);
}
return result;
} else {

View File

@ -140,6 +140,26 @@ public class DruidKubernetesPeonClientTest
Assertions.assertEquals(killThisOne, Iterables.getOnlyElement(toDelete)); // should only cleanup one job
}
@Test
void testCleanupReturnValue() throws KubernetesResourceNotFoundException
{
DruidKubernetesPeonClient peonClient = new DruidKubernetesPeonClient(new TestKubernetesClient(this.client), "test",
false
);
Assertions.assertFalse(peonClient.cleanUpJob(new K8sTaskId("sometask")));
Job job = new JobBuilder()
.withNewMetadata()
.withName("sometask")
.addToLabels(DruidK8sConstants.LABEL_KEY, "true")
.endMetadata()
.withNewSpec()
.withTemplate(new PodTemplateSpec(new ObjectMeta(), K8sTestUtils.getDummyPodSpec()))
.endSpec().build();
client.batch().v1().jobs().inNamespace("test").create(job);
Assertions.assertTrue(peonClient.cleanUpJob(new K8sTaskId("sometask")));
}
@Test
void watchingALogThatDoesntExist()
{