diff --git a/charts/substrate/templates/rustfs.yaml b/charts/substrate/templates/rustfs.yaml index ab04cb1a20..fd7443877b 100644 --- a/charts/substrate/templates/rustfs.yaml +++ b/charts/substrate/templates/rustfs.yaml @@ -108,6 +108,9 @@ kind: Job metadata: name: {{ include "substrate.fullname" (list "rustfs-bucket-init" .) }} namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": post-install,post-upgrade + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded spec: backoffLimit: 10 template: diff --git a/charts/substrate/tests/control_plane_test.yaml b/charts/substrate/tests/control_plane_test.yaml index 44c6938fa5..be9d2b76ad 100644 --- a/charts/substrate/tests/control_plane_test.yaml +++ b/charts/substrate/tests/control_plane_test.yaml @@ -161,3 +161,15 @@ tests: value: - protocol: TCP port: api +- it: removes the bucket initialization job after it succeeds + template: rustfs.yaml + documentSelector: + path: kind + value: Job + asserts: + - equal: + path: metadata.annotations["helm.sh/hook"] + value: post-install,post-upgrade + - equal: + path: metadata.annotations["helm.sh/hook-delete-policy"] + value: before-hook-creation,hook-succeeded diff --git a/hack/install-microvm-deps.sh b/hack/install-microvm-deps.sh index e37fd313ad..cc4516952e 100755 --- a/hack/install-microvm-deps.sh +++ b/hack/install-microvm-deps.sh @@ -208,7 +208,6 @@ fi # in-cluster rustfs (S3 API) on kind, or the GCS bucket on GKE. if [[ "${ATE_INSTALL_KIND}" == "true" ]]; then log "Staging assets to in-cluster rustfs bucket ${BUCKET_NAME} (kata-assets/)..." - run_kubectl wait --for=condition=complete job/rustfs-bucket-init -n ate-system --timeout=120s OUT="${OUT}" BUCKET="${BUCKET_NAME}" KUBECTL_CONTEXT="${KUBECTL_CONTEXT}" hack/microvm-assets/stage-to-rustfs.sh else log "Uploading assets to gs://${BUCKET_NAME}/kata-assets/ ..." diff --git a/hack/microvm-assets/stage-to-rustfs.sh b/hack/microvm-assets/stage-to-rustfs.sh index 2f8c66f7b2..43d17aeae5 100755 --- a/hack/microvm-assets/stage-to-rustfs.sh +++ b/hack/microvm-assets/stage-to-rustfs.sh @@ -72,7 +72,11 @@ done # rustfs must be serving and the bucket must exist before anything is uploaded. echo ">> Waiting for rustfs in namespace ${NAMESPACE}..." run_kubectl rollout status deploy/rustfs --timeout=300s -run_kubectl wait --for=condition=Complete job/rustfs-bucket-init --timeout=300s +# Helm removes the initialization Job after its hook succeeds, while plain +# kubectl installs retain it. Wait for the Job only when it is still present. +if run_kubectl get job/rustfs-bucket-init >/dev/null 2>&1; then + run_kubectl wait --for=condition=Complete job/rustfs-bucket-init --timeout=300s +fi NODE="$("${ROOT}/hack/kind.sh" get nodes --name "${KIND_CLUSTER_NAME}" | head -n1)" if [[ -z "${NODE}" ]]; then diff --git a/manifests/ate-install/rustfs.yaml b/manifests/ate-install/rustfs.yaml index 0256197359..dafd6ec6d9 100644 --- a/manifests/ate-install/rustfs.yaml +++ b/manifests/ate-install/rustfs.yaml @@ -139,6 +139,9 @@ kind: Job metadata: name: rustfs-bucket-init namespace: ate-system + annotations: + "helm.sh/hook": post-install,post-upgrade + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded spec: backoffLimit: 10 template: