forked from wangbo/easyai
fix(deploy): 修复组件版本解析和安装升级验收流程
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check legacy stable aliases AFTER pull, before any container is recreated."""
|
||||
import argparse
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--sudo', action='store_true')
|
||||
parser.add_argument('--services', nargs='*', default=[])
|
||||
args = parser.parse_args()
|
||||
configuration = json.load(sys.stdin)
|
||||
docker = ['sudo','docker'] if args.sudo else ['docker']
|
||||
keys = {'easyai-server':'SERVER_STABLE_DIGEST','easyai-web':'WEB_STABLE_DIGEST','ws-gateway':'WS_GATEWAY_STABLE_DIGEST'}
|
||||
for service, key in keys.items():
|
||||
if args.services and service not in args.services:
|
||||
continue
|
||||
settings = configuration['services'].get(service)
|
||||
if not settings:
|
||||
continue
|
||||
digest = configuration.get('x-easyai-release', {}).get(service)
|
||||
if not digest:
|
||||
continue
|
||||
reference = settings['image']
|
||||
repository = reference.rsplit(':', 1)[0]
|
||||
result = subprocess.run(docker + ['image','inspect',reference],capture_output=True,text=True)
|
||||
try:
|
||||
images = json.loads(result.stdout)
|
||||
matches = result.returncode == 0 and repository+'@'+digest in images[0].get('RepoDigests', [])
|
||||
except (ValueError, IndexError, KeyError):
|
||||
matches = False
|
||||
if not matches:
|
||||
print(f'❌ {service} 拉取后的稳定镜像与目标清单不一致;未重建服务,请重新检查正式发布',file=sys.stderr)
|
||||
sys.exit(1)
|
||||
print('✅ 拉取后的稳定镜像与目标发布一致')
|
||||
Reference in New Issue
Block a user