INNER CODE UNIT · Python
server_image
theonedev/onedev · server-product/helm/files/stop-servers.py:46
def server_image(spec):
return next(container["image"] for container in spec["containers"]
if container["name"] == "onedevserver")
existing = pods()
if (server_image(statefulset["spec"]["template"]["spec"]) == image
and all(server_image(pod["spec"]) == image for pod in existing)):
print("OneDev image is unchanged; no upgrade shutdown required", flush=True)
return
print("Stopping all OneDev servers before upgrading the shared database", flush=True)
api("PATCH", base + "/scale", {"spec": {"replicas": 0}})
deadline = time.monotonic() + timeout
deleting = set()
while True:
existing = pods()
current = api("GET", base)
if current["spec"]["replicas"] != 0: