Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions chart/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{{- if and (ne .Release.Namespace "kubeflex-system") (not (lookup "v1" "Namespace" "" "kubeflex-system")) }}
{{ define "NS" -}}
apiVersion: v1
kind: Namespace
metadata:
name: kubeflex-system
{{- end }}
{{ end -}}
{{ if ne .Release.Namespace "kubeflex-system" -}}
{{ with $kfns := (lookup "v1" "Namespace" "" "kubeflex-system") -}}
{{ if $kfns.metadata.annotations -}}
{{ if eq $.Release.Name
(index $kfns.metadata.annotations "meta.helm.sh/release-name") -}}
{{ template "NS" -}}
{{ end -}}
{{ end -}}
{{ else -}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using a with/else/end statement?
I was not aware that it was supported
Something does not seem to make sense to me

Copy link
Contributor Author

@MikeSpreitzer MikeSpreitzer Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is one of the forms defined in https://pkg.go.dev/text/[email protected]#hdr-Actions .

The thing that that doc does not quite say clearly enough for my taste is that the value of an assignment is the value on the RHS of the assignment. But I do think that this is true, and is why the initial helm upgrade --install creates the namespace.

{{ template "NS" -}}
{{ end -}}
{{end -}}
1 change: 1 addition & 0 deletions test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SRC_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
${SRC_DIR}/cleanup.sh
${SRC_DIR}/setup-kubeflex.sh
${SRC_DIR}/manage-type-k8s.sh
${SRC_DIR}/test-controller-image-update.sh
${SRC_DIR}/manage-type-vcluster.sh
${SRC_DIR}/manage-type-external.sh
${SRC_DIR}/manage-ctx.sh
Expand Down
31 changes: 16 additions & 15 deletions test/e2e/test-controller-image-update.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,15 @@ if ! kubectl rollout status deployment/kubeflex-controller-manager -n kubeflex-s
exit 1
fi

# Wait for all the old pods to go away
echo "7. Wait for old Pods to go away"
while ! kubectl get pods -n kubeflex-system -l control-plane=controller-manager | wc -l | grep -qw 2; do
echo Waiting for just one kubeflex-controller-manager Pod
sleep 10
done

# Get the new image
echo "7. Getting new controller manager image..."
echo "8. Getting new controller manager image..."
NEW_IMAGE=$(kubectl get deployment kubeflex-controller-manager -n kubeflex-system -o jsonpath='{.spec.template.spec.containers[?(@.name=="manager")].image}')
if [ -z "$NEW_IMAGE" ]; then
echo "ERROR: Could not get new image from deployment"
Expand All @@ -79,27 +86,21 @@ fi
echo "New image: $NEW_IMAGE"

# Get new pod names
echo "8. Getting new pod names..."
echo "9. Getting new pod names..."
NEW_PODS=$(kubectl get pods -n kubeflex-system -l control-plane=controller-manager -o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | sort | tr '\n' ' ')
echo "New pods (sorted): $NEW_PODS"

# Wait for deployment rollout to complete and all pods to be ready
echo "9. Waiting for deployment rollout to complete..."
if ! kubectl rollout status deployment/kubeflex-controller-manager -n kubeflex-system --timeout=300s; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same wait as is done in step 6; no need to repeat it.

echo "ERROR: Deployment rollout failed or timed out"
echo "Deployment status:"
kubectl describe deployment kubeflex-controller-manager -n kubeflex-system
exit 1
fi

# Wait for all pods to be ready
echo "10. Waiting for all pods to be ready..."
if ! kubectl wait --for=condition=Ready pods -l control-plane=controller-manager -n kubeflex-system --timeout=120s; then
echo "ERROR: Not all pods are ready within timeout"
echo "Pod status:"
kubectl get pods -n kubeflex-system -l control-plane=controller-manager
echo "Pod events:"
kubectl describe pods -n kubeflex-system -l control-plane=controller-manager
echo "Pods:"
kubectl get pods -n kubeflex-system -l control-plane=controller-manager --no-headers=true | while read ns name rest; do
echo
kubectl get pod -n $ns $name -o yaml
echo
kubectl events --namespace $ns --for pod/$name
done
exit 1
fi

Expand Down