Allow first platform install scheduling preflight
Homelab Main / validate (push) Waiting to run Details
Homelab Main / running-update (push) Blocked by required conditions Details
Homelab Main / debian-ops (push) Blocked by required conditions Details

This commit is contained in:
juvenal.diaz 2026-11-02 13:47:33 -06:00
parent 0a26ca03a4
commit 19e3689f76
1 changed files with 27 additions and 4 deletions

View File

@ -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)