utils_devops 0.1.139__py3-none-any.whl → 0.1.140__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- utils_devops/extras/docker_ops.py +52 -60
- {utils_devops-0.1.139.dist-info → utils_devops-0.1.140.dist-info}/METADATA +1 -1
- {utils_devops-0.1.139.dist-info → utils_devops-0.1.140.dist-info}/RECORD +5 -5
- {utils_devops-0.1.139.dist-info → utils_devops-0.1.140.dist-info}/WHEEL +0 -0
- {utils_devops-0.1.139.dist-info → utils_devops-0.1.140.dist-info}/entry_points.txt +0 -0
|
@@ -767,75 +767,67 @@ def check_service_health(compose_file: str, service: str,
|
|
|
767
767
|
logger.error(f"Error checking health for {service}: {e}")
|
|
768
768
|
return {"healthy": False, "error": str(e)}
|
|
769
769
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
770
|
+
import time
|
|
771
|
+
from collections import defaultdict
|
|
772
|
+
|
|
773
|
+
def wait_for_healthy(
|
|
774
|
+
compose_file: str,
|
|
775
|
+
services: List[str],
|
|
776
|
+
timeout: int,
|
|
777
|
+
interval: int,
|
|
778
|
+
logger: logger,
|
|
779
|
+
env_file: Optional[str] = None
|
|
780
|
+
) -> bool:
|
|
781
|
+
"""Wait for services to become healthy with detailed status logging."""
|
|
776
782
|
start_time = time.time()
|
|
777
|
-
|
|
783
|
+
attempt = 1
|
|
778
784
|
|
|
779
|
-
logger.info(f"🩺 Starting health checks for {len(services_to_check)} services: {services_to_check}")
|
|
780
|
-
logger.info(f"⏰ Timeout: {timeout}s, Check interval: {interval}s")
|
|
781
|
-
|
|
782
|
-
attempt = 0
|
|
783
785
|
while time.time() - start_time < timeout:
|
|
784
|
-
attempt += 1
|
|
785
786
|
elapsed = time.time() - start_time
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
#
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
healthy_services.append(service)
|
|
787
|
+
remaining = timeout - elapsed
|
|
788
|
+
logger.info(f"🔍 Health check attempt {attempt} ({elapsed:.1f}s elapsed, {remaining:.1f}s remaining):")
|
|
789
|
+
|
|
790
|
+
# Get detailed health status
|
|
791
|
+
detailed_health = _get_detailed_health_status(compose_file, services, logger)
|
|
792
|
+
|
|
793
|
+
# Group services by overall_status
|
|
794
|
+
status_groups = defaultdict(list)
|
|
795
|
+
for service, status in detailed_health.items():
|
|
796
|
+
overall = status['overall_status']
|
|
797
|
+
if overall == 'healthy':
|
|
798
|
+
status_groups[overall].append(service)
|
|
799
799
|
else:
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
# Log
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
800
|
+
detail = f"{service}: {status['status']} (health: {status['health']}) | Error: {status['error']}"
|
|
801
|
+
status_groups[overall].append(detail)
|
|
802
|
+
|
|
803
|
+
# Define order and emojis
|
|
804
|
+
statuses = ['healthy', 'starting', 'restarting', 'unhealthy', 'not found']
|
|
805
|
+
emojis = {'healthy': '✅', 'starting': '🚀', 'restarting': '🔄', 'unhealthy': '❌', 'not found': '❓'}
|
|
806
|
+
|
|
807
|
+
# Log groups if they have items
|
|
808
|
+
for status in statuses:
|
|
809
|
+
group = status_groups[status]
|
|
810
|
+
if group:
|
|
811
|
+
emoji = emojis[status]
|
|
812
|
+
logger.info(f" {emoji} {status.capitalize()} ({len(group)}):")
|
|
813
|
+
if status == 'healthy':
|
|
814
|
+
logger.info(f" {sorted(group)}")
|
|
815
|
+
else:
|
|
816
|
+
for detail in sorted(group):
|
|
817
|
+
logger.info(f" - {detail}")
|
|
815
818
|
|
|
816
|
-
if
|
|
817
|
-
|
|
818
|
-
logger.info(f"🎉 ALL SERVICES HEALTHY! Completed in {
|
|
819
|
+
# Check if all healthy
|
|
820
|
+
if len(status_groups['healthy']) == len(services):
|
|
821
|
+
logger.info(f"🎉 ALL SERVICES HEALTHY! Completed in {elapsed:.1f}s after {attempt} attempts")
|
|
819
822
|
return True
|
|
820
823
|
|
|
821
|
-
# Wait
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
else:
|
|
826
|
-
# Don't sleep if we're about to timeout
|
|
827
|
-
break
|
|
828
|
-
|
|
829
|
-
# Timeout reached
|
|
830
|
-
elapsed = time.time() - start_time
|
|
831
|
-
logger.error(f"⏰ HEALTH CHECK TIMEOUT after {elapsed:.1f}s and {attempt} attempts!")
|
|
832
|
-
logger.error(f"💔 Final status - Healthy: {len(healthy_services)}, Unhealthy: {len(unhealthy_services)}")
|
|
833
|
-
|
|
834
|
-
if unhealthy_services:
|
|
835
|
-
logger.error("📋 Unhealthy services details:")
|
|
836
|
-
for us in unhealthy_services:
|
|
837
|
-
logger.error(f" - {us['service']}: {us['status']} | {us['error']}")
|
|
824
|
+
# Wait for next attempt
|
|
825
|
+
logger.info(f"⏳ Waiting {interval}s before next health check...")
|
|
826
|
+
time.sleep(interval)
|
|
827
|
+
attempt += 1
|
|
838
828
|
|
|
829
|
+
# Timeout
|
|
830
|
+
logger.error(f"❌ Health check timeout after {time.time() - start_time:.1f}s")
|
|
839
831
|
return False
|
|
840
832
|
|
|
841
833
|
def health_check_docker_compose(compose_file: str) -> bool:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: utils_devops
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.140
|
|
4
4
|
Summary: Lightweight DevOps utilities for automation scripts: config editing (YAML/JSON/INI/.env), templating, diffing, and CLI tools
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: devops,automation,nginx,cli,jinja2,yaml,config,diff,templating,logging,docker,compose,file-ops
|
|
@@ -9,7 +9,7 @@ utils_devops/core/strings.py,sha256=8s0GSjcyTKwLjJjsJ_XfOJxPtyb549icDlU9SUxSvHI,
|
|
|
9
9
|
utils_devops/core/systems.py,sha256=wNbEFUAvbMPdqWN-iXvTzvj5iE9xaWfjZYYvD0EZAH0,47577
|
|
10
10
|
utils_devops/extras/__init__.py,sha256=ZXHeVLHO3_qiW9AY-UQ_YA9cQzmkLGv54a2UbyvtlM0,3571
|
|
11
11
|
utils_devops/extras/aws_ops.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
utils_devops/extras/docker_ops.py,sha256=
|
|
12
|
+
utils_devops/extras/docker_ops.py,sha256=gbO3fxXR22IG1ItgslK2BM4rPJAurOuP__1ZcSoNzdA,177946
|
|
13
13
|
utils_devops/extras/git_ops.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
utils_devops/extras/interaction_ops.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
utils_devops/extras/metrics_ops.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -19,7 +19,7 @@ utils_devops/extras/notification_ops.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
|
19
19
|
utils_devops/extras/performance_ops.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
utils_devops/extras/ssh_ops.py,sha256=8I_AF0q76CJOK2qp68w1oro2SVOZ_v7b8OvgDYcE4tg,73741
|
|
21
21
|
utils_devops/extras/vault_ops.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
-
utils_devops-0.1.
|
|
23
|
-
utils_devops-0.1.
|
|
24
|
-
utils_devops-0.1.
|
|
25
|
-
utils_devops-0.1.
|
|
22
|
+
utils_devops-0.1.140.dist-info/METADATA,sha256=wqHTS8-GlHiKwSgGAnn3yyu1ZWuvkgSBQ17zWjGOt9A,1903
|
|
23
|
+
utils_devops-0.1.140.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
24
|
+
utils_devops-0.1.140.dist-info/entry_points.txt,sha256=ei3B6ZL5yu6dOq-U1r8wsBdkXeg63RAyV7m8_ADaE6k,53
|
|
25
|
+
utils_devops-0.1.140.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|