diff --git a/Dockerfile b/Dockerfile index 9aa27a7..eadf493 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ COPY . . ARG GIT_COMMIT=unknown RUN make build GIT_COMMIT=${GIT_COMMIT} -RUN chmod +x /build/bin/hyperfleet-e2e +RUN chmod +x /build/bin/hyperfleet-e2e FROM registry.ci.openshift.org/ci/hyperfleet-credential-provider:latest AS hyperfleet-credential-provider @@ -39,7 +39,19 @@ RUN curl -fsSL "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release # Install Helm RUN curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash -# Install Helm plugins - helm-git and helm-diff +# Set up Helm directories (cache and config writable, plugins read-only) +# OpenShift Prow runs with random UID in group 0, requiring group-writable dirs +RUN mkdir -p /tmp/helm-home/.cache/helm \ + /tmpl/helm-home/.config/helm \ + /usr/local//share/helm/plugins && \ + chown -R 0:0 /tmp/helm-home /usr/local/share/helm/plugins && \ + chmod -R g=u /tmp/helm-home /usr/local/share/helm/plugins + +ENV HELM_CACHE_HOME=/tmp/helm-home/.cache/helm \ + HELM_CONFIG_HOME=/tmp/helm-home/.config/helm \ + HELM_PLUGINS=/usr/local/share/helm/plugins + +# Install Helm plugins ARG HELM_GIT_VERSION=v1.5.2 ARG HELM_DIFF_VERSION=3.15.7 RUN helm plugin install https://github.com/aslafy-z/helm-git --version ${HELM_GIT_VERSION} && \ @@ -71,7 +83,6 @@ COPY --from=builder /build/env /e2e/env # Copy cleanup scripts COPY --from=builder /build/scripts /e2e/scripts - # Copy default config (fallback if ConfigMap is not mounted) COPY --from=builder /build/configs /e2e/configs diff --git a/scripts/cleanup-pubsub-resources.sh b/scripts/cleanup-pubsub-resources.sh index d1a6b3f..89ffe93 100755 --- a/scripts/cleanup-pubsub-resources.sh +++ b/scripts/cleanup-pubsub-resources.sh @@ -31,10 +31,6 @@ log_error() { echo "[ERROR] $*" >&2 } -log_verbose() { - echo "[VERBOSE] $*" -} - log_section() { echo "" echo "========================================" @@ -127,7 +123,7 @@ discover_pubsub_topics() { local namespace="$1" local project_id="${GCP_PROJECT_ID}" - log_verbose "Discovering Pub/Sub topics for namespace: ${namespace}" + log_info "Discovering Pub/Sub topics for namespace: ${namespace}" >&2 if [[ -z "${project_id}" ]]; then log_error "GCP_PROJECT_ID is not set" @@ -177,8 +173,8 @@ discover_pubsub_topics() { done <<< "${all_topics}" if [[ ${#topics[@]} -eq 0 ]]; then - log_verbose "No Pub/Sub topics found for namespace: ${namespace}" >&2 - return 1 + log_info "No Pub/Sub topics found for namespace: ${namespace}" >&2 + return 2 fi log_info "Found ${#topics[@]} Pub/Sub topic(s) for namespace ${namespace}:" >&2 @@ -194,7 +190,7 @@ discover_pubsub_subscriptions() { local namespace="$1" local project_id="${GCP_PROJECT_ID}" - log_verbose "Discovering Pub/Sub subscriptions for namespace: ${namespace}" + log_info "Discovering Pub/Sub subscriptions for namespace: ${namespace}" >&2 if [[ -z "${project_id}" ]]; then log_error "GCP_PROJECT_ID is not set" @@ -238,8 +234,8 @@ discover_pubsub_subscriptions() { done <<< "${all_subscriptions}" if [[ ${#subscriptions[@]} -eq 0 ]]; then - log_verbose "No Pub/Sub subscriptions found for namespace: ${namespace}" >&2 - return 1 + log_info "No Pub/Sub subscriptions found for namespace: ${namespace}" >&2 + return 2 fi log_info "Found ${#subscriptions[@]} Pub/Sub subscription(s) for namespace ${namespace}:" >&2 @@ -306,9 +302,15 @@ delete_all_pubsub_subscriptions() { # Discover subscriptions (stdout only contains resource names, stderr has logs) local subscriptions - if ! subscriptions=$(discover_pubsub_subscriptions "${namespace}"); then + local discovery_exit_code=0 + subscriptions=$(discover_pubsub_subscriptions "${namespace}") || discovery_exit_code=$? + + if [[ ${discovery_exit_code} -eq 2 ]]; then log_info "No Pub/Sub subscriptions to delete" return 0 + elif [[ ${discovery_exit_code} -ne 0 ]]; then + log_error "Failed to discover Pub/Sub subscriptions" + return 1 fi # Delete each subscription @@ -338,9 +340,15 @@ delete_all_pubsub_topics() { # Discover topics (stdout only contains resource names, stderr has logs) local topics - if ! topics=$(discover_pubsub_topics "${namespace}"); then + local discovery_exit_code=0 + topics=$(discover_pubsub_topics "${namespace}") || discovery_exit_code=$? + + if [[ ${discovery_exit_code} -eq 2 ]]; then log_info "No Pub/Sub topics to delete" return 0 + elif [[ ${discovery_exit_code} -ne 0 ]]; then + log_error "Failed to discover Pub/Sub topics" + return 1 fi # Delete each topic