INNER CODE UNIT · Python

stop_servers

theonedev/onedev · server-product/helm/files/stop-servers.py:12

def stop_servers(api, namespace, name, image, timeout):
    base = f"/apis/apps/v1/namespaces/{namespace}/statefulsets/{name}"
    try:
        statefulset = api("GET", base)
    except urllib.error.HTTPError as error:
        if error.code == 404:
            raise RuntimeError(
                f"Refusing to upgrade: StatefulSet {namespace}/{name} was not found; "
                "cannot verify that existing OneDev servers are stopped. Keep the existing "
                "StatefulSet name when upgrading (check global.nameOverride and "
                "global.fullnameOverride).") from error
        raise
    retention = statefulset["spec"].get("persistentVolumeClaimRetentionPolicy", {})
    if retention.get("whenScaled") == "Delete":
        raise RuntimeError(
            "Refusing to upgrade: persistentVolumeClaimRetentionPolicy.whenScaled is Delete; "
            "scaling down could delete OneDev data. Set whenScaled to Retain on the existing "
            "StatefulSet before retrying.")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…