You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Refactoring for error messages and security fix for path echoing
* Added dev_no_sleep, dev_no_metrics, dev_no_build
* Added healthcheck
* Normalization and extra error check
* Tests; Improved test speed by 6x
* Forcing no_build = False
* Healthcheck now handles lists conformant and more strict on health status string
* Test-Fix
* Test-Fix
raiseRuntimeError(f"Healthcheck starts with {health_string_command}. Please use 'CMD' or 'CMD-SHELL' when supplying as list. For disabling do not use 'NONE' but the disable argument.")
# TODO: Check health status instead if `healthcheck` is enabled (https://github.com/green-coding-berlin/green-metrics-tool/issues/423)
850
-
# This waiting loop is actually a pre-work for the upcoming health check. For the check if the container is "running", as implemented here, the waiting loop is not needed.
stderr=subprocess.STDOUT, # put both in one stream
910
+
encoding='UTF-8'
911
+
)
912
+
health=ps.stdout.strip()
913
+
ifps.returncode!=0orhealth=='<nil>':
914
+
raiseRuntimeError(f"Health check for dependent_container '{dependent_container}' was requested, but container has no healthcheck implemented! (Output was: {health})")
915
+
ifhealth=='unhealthy':
916
+
raiseRuntimeError('ontainer healthcheck failed terminally with status "unhealthy")')
917
+
print(f"Health of container '{dependent_container}': {health}")
918
+
elifcondition=='service_started':
919
+
pass
920
+
else:
921
+
raiseRuntimeError(f"Unsupported condition in healthcheck for service '{service_name}': {condition}")
922
+
923
+
ifstate=='running'andhealth=='healthy':
860
924
break
861
925
862
-
print(f"State of container '{dependent_container}': {state}. Waiting for 1 second")
863
-
self.custom_sleep(1)
926
+
print('Waiting for 1 second')
927
+
time.sleep(1)
864
928
time_waited+=1
865
929
866
-
ifstate!="running":
867
-
raiseRuntimeError(f"Dependent container '{dependent_container}' of '{container_name}' is not running after waiting for {time_waited} sec! Consider checking your service configuration, the entrypoint of the container or the logs of the container.")
930
+
ifstate!='running':
931
+
raiseRuntimeError(f"Dependent container '{dependent_container}' of '{container_name}' is not running but {state} after waiting for {time_waited} sec! Consider checking your service configuration, the entrypoint of the container or the logs of the container.")
932
+
ifhealth!='healthy':
933
+
raiseRuntimeError(f"Dependent container '{dependent_container}' of '{container_name}' is not healthy but '{health}' after waiting for {time_waited} sec! Consider checking your service configuration, the entrypoint of the container or the logs of the container.")
parser.add_argument('--full-docker-prune', action='store_true', help='Stop and remove all containers, build caches, volumes and images on the system')
1456
1528
parser.add_argument('--docker-prune', action='store_true', help='Prune all unassociated build caches, networks volumes and stopped containers on the system')
1457
-
parser.add_argument('--dry-run', action='store_true', help='Removes all sleeps. Resulting measurement data will be skewed.')
1458
-
parser.add_argument('--dev-repeat-run', action='store_true', help='Checks if a docker image is already in the local cache and will then not build it. Also doesn\'t clear the images after a run')
1529
+
parser.add_argument('--dev-no-metrics', action='store_true', help='Skips loading the metric providers. Runs will be faster, but you will have no metric')
1530
+
parser.add_argument('--dev-no-sleeps', action='store_true', help='Removes all sleeps. Resulting measurement data will be skewed.')
1531
+
parser.add_argument('--dev-no-build', action='store_true', help='Checks if a container images are already in the local cache and will then not build it. Also doesn\'t clear the images after a run. Please note that skipping builds only works the second time you make a run.')
1459
1532
parser.add_argument('--print-logs', action='store_true', help='Prints the container and process logs to stdout')
1460
1533
1461
1534
args=parser.parse_args()
@@ -1470,9 +1543,9 @@ def run(self):
1470
1543
error_helpers.log_error('--allow-unsafe and skip--unsafe in conjuction is not possible')
0 commit comments