fix(glue): make DeleteJob idempotent (#3866)

Match AWS DeleteJob behavior by tolerating deletion of a missing job definition and cover repeated deletion in the Glue service test.
This commit is contained in:
Chiara Forresi authored and GitHub committed 2026-09-21 11:16:07 -04:00
1 parent 0108b9653a
commit 992b80f8f7
3 files changed
+52 -3

No files matched your search

@@ -1714,9 +1714,6 @@ public class GlueService {
validateRequired(name, "JobName");
// Jobs and crawlers skip normalizeName because AWS preserves their case
String normalizedName = name;
if (jobStore.get(normalizedName).isEmpty()) {
throw new AwsException("EntityNotFoundException", "Job " + name + " not found.", 400);
}
jobStore.delete(normalizedName);
resourceGroupsTaggingService.deleteResources(List.of(jobArn(region, normalizedName)), region);
LOG.infov("Deleted Glue Job: {0}", name);
@@ -0,0 +1,49 @@
package io.github.hectorvent.floci.services.glue;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.UUID;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
class GlueDeleteJobIntegrationTest {
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
private static final String ROLE = "arn:aws:iam::000000000000:role/my-role";
private static final String JOB_NAME = "delete-job-" + UUID.randomUUID().toString().substring(0, 8);
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
void repeatedDeleteJobRequestsReturnSuccessfulResponses() {
given().contentType(CONTENT_TYPE)
.header("X-Amz-Target", "AWSGlue.CreateJob")
.body("""
{
"Name": "%s",
"Role": "%s",
"Command": {}
}
""".formatted(JOB_NAME, ROLE))
.when().post("/")
.then().statusCode(200);
for (int attempt = 0; attempt < 2; attempt++) {
given().contentType(CONTENT_TYPE)
.header("X-Amz-Target", "AWSGlue.DeleteJob")
.body("{ \"JobName\": \"" + JOB_NAME + "\" }")
.when().post("/")
.then()
.statusCode(200)
.body("JobName", equalTo(JOB_NAME));
}
}
}
@@ -1145,6 +1145,9 @@ class GlueServiceTest {
AwsException ex = assertThrows(AwsException.class, () -> glueService.getJob("my-job"));
assertEquals("EntityNotFoundException", ex.getErrorCode());
assertTrue(glueService.getJobs().isEmpty());
glueService.deleteJob("my-job", REGION);
assertTrue(glueService.getJobs().isEmpty());
}
@Test