From 082174cf37a1bdf996bd227e634893a9b8cf3f5b Mon Sep 17 00:00:00 2001 From: Michael Dombrowski Date: Tue, 22 Aug 2023 17:35:32 -0400 Subject: [PATCH] fix(docker): do not fail docker image cleanup --- .../aws/greengrass/testing/features/DockerSteps.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/aws-greengrass-testing-features/aws-greengrass-testing-features-docker/src/main/java/com/aws/greengrass/testing/features/DockerSteps.java b/aws-greengrass-testing-features/aws-greengrass-testing-features-docker/src/main/java/com/aws/greengrass/testing/features/DockerSteps.java index 6fe60173..f41d087d 100644 --- a/aws-greengrass-testing-features/aws-greengrass-testing-features-docker/src/main/java/com/aws/greengrass/testing/features/DockerSteps.java +++ b/aws-greengrass-testing-features/aws-greengrass-testing-features-docker/src/main/java/com/aws/greengrass/testing/features/DockerSteps.java @@ -5,6 +5,7 @@ package com.aws.greengrass.testing.features; +import com.aws.greengrass.testing.api.device.exception.CommandExecutionException; import com.aws.greengrass.testing.api.device.model.CommandInput; import com.aws.greengrass.testing.platform.Platform; import io.cucumber.guice.ScenarioScoped; @@ -81,8 +82,17 @@ private void checkDockerImagePresence(String image, Predicate> valid } } + /** + * Cleanup after executing steps. + */ @After public void removeCreatedImages() { - createdImages.forEach(this::removeDockerImage); + for (String createdImage : createdImages) { + try { + removeDockerImage(createdImage); + } catch (CommandExecutionException e) { + LOGGER.debug("Could not remove docker image {}", createdImage, e); + } + } } }