Handle container not found exception
This commit is contained in:
parent
f6b9282dfc
commit
8d6eb6687f
|
@ -29,12 +29,12 @@ build-job: # This job runs in the build stage, which runs first.
|
|||
- docker push $CI_REGISTRY_IMAGE
|
||||
- echo "Build complete."
|
||||
|
||||
# unit-test-job: # This job runs in the test stage.
|
||||
# stage: test
|
||||
# script:
|
||||
# - echo "Running unit tests..."
|
||||
# - python3 -munittest discover
|
||||
# - echo "Testing complete"
|
||||
unit-test-job: # This job runs in the test stage.
|
||||
stage: test
|
||||
script:
|
||||
- echo "Running unit tests..."
|
||||
- python3 -munittest discover
|
||||
- echo "Testing complete"
|
||||
|
||||
lint-test-job: # This job also runs in the test stage.
|
||||
stage: test # It can run at the same time as unit-test-job (in parallel).
|
||||
|
|
|
@ -103,7 +103,11 @@ class HTTPHandler(MetricsHandler): # type: ignore[misc]
|
|||
)
|
||||
|
||||
for container in self.docker_client.containers.list(all=True):
|
||||
data = self.docker_api.inspect_container(container.id)
|
||||
try:
|
||||
data = self.docker_api.inspect_container(container.id)
|
||||
except docker.errors.NotFound:
|
||||
print(f'WARNING: Container {container.id} does not exist. Skipping.')
|
||||
continue
|
||||
|
||||
running = bool(data['State']['Running'])
|
||||
started_at = data['State']['StartedAt']
|
||||
|
|
Loading…
Reference in a new issue