Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(minikube): read per-deployment readiness metadata

Alfredo Lopez5b17324a73f0
diff --git a/scripts/minikube/t2-common.sh b/scripts/minikube/t2-common.sh
index e4a77ac28..5fdc7e33e 100755
--- a/scripts/minikube/t2-common.sh
+++ b/scripts/minikube/t2-common.sh
@@ -238,7 +238,7 @@ t2_profile_scope() {
t2_context_check() {
local context_name
- context_name="$(kubectl config get-contexts -o name 2>/dev/null | awk -v target="$T2_CONTEXT" '$0 == target {print; exit}')"
+ context_name="$(kubectl --context="$T2_CONTEXT" config get-contexts -o name 2>/dev/null | awk -v target="$T2_CONTEXT" '$0 == target {print; exit}')"
if [ "$context_name" != "$T2_CONTEXT" ]; then
T2_NEXT_COMMAND='select the explicit Kubernetes context generated with the profile'
t2_fail DEVELOPMENT_SCOPE_REQUIRED "Kubernetes context is unavailable: $T2_CONTEXT"
@@ -573,6 +573,10 @@ for (namespace, name), item in required_refs.items():
if item is None:
bad.append(f"{namespace}/{name} missing")
continue
+ # The first loop leaves `metadata` bound to the last inventory item. Read
+ # metadata from the deployment being evaluated so each resource is
+ # compared with its own observed generation.
+ metadata = item.get("metadata") or {}
spec = item.get("spec") or {}
status = item.get("status") or {}
def integer(value, field):
diff --git a/scripts/tests/test-minikube-t2-scenarios.sh b/scripts/tests/test-minikube-t2-scenarios.sh
index 2d3d7e32d..3a7bf5e1e 100755
--- a/scripts/tests/test-minikube-t2-scenarios.sh
+++ b/scripts/tests/test-minikube-t2-scenarios.sh
@@ -99,6 +99,10 @@ cat >"$fake_bin/kubectl" <<'EOF'
#!/usr/bin/env bash
case "$*" in
*"config get-contexts -o name"*)
+ if [ -n "${FAKE_CONTEXT:-}" ]; then
+ printf '%s' "${FAKE_CONTEXT}"
+ exit 0
+ fi
for arg in "$@"; do
case "$arg" in
--context=*) printf '%s' "${arg#--context=}"; exit 0 ;;
@@ -282,6 +286,12 @@ esac
ready_json='{"items":[{"metadata":{"namespace":"gfs","name":"gfsc-reader","generation":7},"spec":{"replicas":1},"status":{"observedGeneration":7,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}}]}'
env "${repo_env[@]}" READY_JSON="$ready_json" \
bash -c 'source "$1"; T2_PLAN_MODE=false; T2_BOOTSTRAP_REQUIRED=false; t2_kc(){ printf "%s" "$READY_JSON"; }; t2_deployment_check' bash "$COMMON"
+# Each required deployment must use its own metadata generation. Keep an
+# unrelated item last so a stale loop variable cannot make healthy resources
+# appear unready.
+multi_ready_json='{"items":[{"metadata":{"namespace":"gfs","name":"gfsc-reader","generation":7},"spec":{"replicas":1},"status":{"observedGeneration":7,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"gfs","name":"gfsc-writer","generation":11},"spec":{"replicas":1},"status":{"observedGeneration":11,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"control-plane","name":"unrelated","generation":3},"spec":{"replicas":1},"status":{"observedGeneration":3,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}}]}'
+env "${repo_env[@]}" T2_REQUIRED_DEPLOYMENTS='gfs/gfsc-reader gfs/gfsc-writer' MULTI_READY_JSON="$multi_ready_json" \
+ bash -c 'source "$1"; T2_PLAN_MODE=false; T2_BOOTSTRAP_REQUIRED=false; t2_kc(){ printf "%s" "$MULTI_READY_JSON"; }; t2_deployment_check' bash "$COMMON"
stale_generation_json='{"items":[{"metadata":{"namespace":"gfs","name":"gfsc-reader","generation":8},"spec":{"replicas":1},"status":{"observedGeneration":7,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}}]}'
expect_code PROFILE_UNHEALTHY stale-generation stale-generation \
env "${repo_env[@]}" INVALID_INVENTORY="$stale_generation_json" \