From 19e3689f76cea99e637abeba4a9c0d354ce1d251 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Mon, 2 Nov 2026 13:47:33 -0600 Subject: [PATCH] Allow first platform install scheduling preflight --- scripts/scheduling-preflight.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/scripts/scheduling-preflight.py b/scripts/scheduling-preflight.py index 6e836d2..9ead249 100644 --- a/scripts/scheduling-preflight.py +++ b/scripts/scheduling-preflight.py @@ -560,16 +560,39 @@ def manifests_from_plan(args, plan, kubectl): def operator_workload(document, controllers): - """Preserve the Operator's existing sidecars and volume claims on upgrades. + """Estimate an Operator-managed workload without blocking first installs. - First installs cannot be predicted without the operator's Pod defaults. - Refuse those rather than claiming that an unrendered Pod fits. + On upgrades, preserve the live Operator sidecars and volume claims. On a + first install the StatefulSet does not exist yet, so use the CR's primary + container resources as a conservative lower-bound estimate and defer + generated sidecars/PVC readiness to the post-apply checks. """ kind, namespace, name = identity(document) stateful_name = ("prometheus-" if kind == "Prometheus" else "alertmanager-") + name live = controllers.get(("StatefulSet", namespace, stateful_name)) if not live: - raise CannotCheck(f"{kind} {namespace}/{name}: operator Pod template is not available yet; bootstrap the operator workload separately before checking its scheduling") + spec = document.get("spec") or {} + primary = "prometheus" if kind == "Prometheus" else "alertmanager" + pod_spec = { + "containers": [{"name": primary, "resources": copy.deepcopy(spec.get("resources") or {})}], + "initContainers": [], + } + for field in ("nodeSelector", "affinity", "tolerations", "topologySpreadConstraints", "priorityClassName"): + if field in spec: + pod_spec[field] = copy.deepcopy(spec[field]) + print( + f" NOTICE {kind}/{namespace}/{name}: operator Pod template is not available yet; " + "estimating primary resources and deferring generated sidecars/PVCs to readiness checks" + ) + return { + "kind": "StatefulSet", + "metadata": {"namespace": namespace, "name": stateful_name}, + "spec": { + "replicas": spec.get("replicas", 1), + "template": {"spec": pod_spec}, + }, + "_preflight_noop": document.get("_preflight_noop", False), + } result = copy.deepcopy(live) spec = document["spec"] result["spec"]["replicas"] = spec.get("replicas", 1)