Skip to content

Commit

Permalink
Merge pull request #176 from bluesliverx/main
Browse files Browse the repository at this point in the history
Handle container errors correctly
  • Loading branch information
bluesliverx authored Nov 21, 2024
2 parents a6d9d42 + f5a7497 commit 05d4e99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions buildrunner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import sys
import tarfile
import tempfile
import traceback
import types
from typing import List, Optional

Expand All @@ -35,6 +36,7 @@
from buildrunner.errors import (
BuildRunnerConfigurationError,
BuildRunnerProcessingError,
BuildRunnerError,
)
from buildrunner.steprunner import BuildStepRunner
from buildrunner.docker.multiplatform_image_builder import MultiplatformImageBuilder
Expand Down Expand Up @@ -471,12 +473,6 @@ def run(self): # pylint: disable=too-many-statements,too-many-branches,too-many
else:
self.log.write("\nPush not requested\n")

except BuildRunnerConfigurationError as brce:
exit_explanation = str(brce)
self.exit_code = os.EX_CONFIG
except BuildRunnerProcessingError as brpe:
exit_explanation = str(brpe)
self.exit_code = 1
except requests.exceptions.ConnectionError as rce:
print(str(rce))
exit_explanation = (
Expand All @@ -486,6 +482,17 @@ def run(self): # pylint: disable=too-many-statements,too-many-branches,too-many
"remote PyPi server information is set correctly."
)
self.exit_code = 1
except ImageNotFound as inf:
exit_explanation = f"Image not found: {inf.explanation}"
self.exit_code = os.EX_CONFIG
except BuildRunnerError as exc:
exit_explanation = str(exc)
self.exit_code = (
os.EX_CONFIG if isinstance(exc, BuildRunnerConfigurationError) else 1
)
except Exception as exc:
exit_explanation = f"Encountered unhandled exception ({type(exc).__name__}) {traceback.format_exc()}"
self.exit_code = 1

finally:
self._write_artifact_manifest()
Expand Down
2 changes: 1 addition & 1 deletion tests/test-files/test-docker-pull-failure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
steps:
use-bogus-image:
run:
image: user1/buildrunner-test-multi-platform:bogus
image: user1/buildrunner-bogus-image:bogus
cmd: echo "Hello World"

0 comments on commit 05d4e99

Please sign in to comment.