diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7c0d5fd..0f0d7aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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). diff --git a/dockstat.py b/dockstat.py index 940cc10..e5a3628 100644 --- a/dockstat.py +++ b/dockstat.py @@ -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']