codeant-ai-for-open-source[bot] commented on code in PR #41396:
URL: https://github.com/apache/superset/pull/41396#discussion_r3652228247


##########
helm/superset/tests/test-istio.sh:
##########
@@ -0,0 +1,183 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Renders the chart with `helm template` for several `init.istio.*` value
+# combinations and asserts that the relevant manifests contain (or omit)
+# the expected fields. Intended to be run from the chart directory or via
+# `bash helm/superset/tests/test-istio.sh` from the repo root.
+#
+# Covers the fix for:
+#   https://github.com/apache/superset/issues/25798
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+CHART_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
+
+pass=0
+fail=0
+
+assert_contains() {
+    local label="$1"
+    local needle="$2"
+    local haystack="$3"
+    if grep -qF -- "${needle}" <<<"${haystack}"; then
+        echo "  PASS: ${label}"
+        pass=$((pass + 1))
+    else
+        echo "  FAIL: ${label}"
+        echo "    expected to contain: ${needle}"
+        fail=$((fail + 1))
+    fi
+}
+
+assert_not_contains() {
+    local label="$1"
+    local needle="$2"
+    local haystack="$3"
+    if ! grep -qF -- "${needle}" <<<"${haystack}"; then
+        echo "  PASS: ${label}"
+        pass=$((pass + 1))
+    else
+        echo "  FAIL: ${label}"
+        echo "    expected NOT to contain: ${needle}"
+        fail=$((fail + 1))
+    fi
+}
+
+render() {
+    helm template release "${CHART_DIR}" "$@"
+}
+
+extract_init_job() {
+    awk '
+        /^# Source: superset\/templates\/init-job\.yaml/ { capture = 1 }
+        capture && /^---$/ { capture = 0 }
+        capture { print }
+    ' <<<"$1"
+}
+
+extract_config_secret() {
+    awk '
+        /^# Source: superset\/templates\/secret-superset-config\.yaml/ { 
capture = 1 }
+        capture && /^---$/ { capture = 0 }
+        capture { print }
+    ' <<<"$1"
+}
+
+echo "==> defaults: no istio mitigations applied"
+out_default="$(render)"
+init_job_default="$(extract_init_job "${out_default}")"
+config_default="$(extract_config_secret "${out_default}")"
+assert_not_contains "default does not set sidecar.istio.io/inject label" \
+    'sidecar.istio.io/inject' "${init_job_default}"
+assert_not_contains "default initscript does not register quitquitquit trap" \
+    'quitquitquit' "${config_default}"
+
+echo "==> init.istio.disableSidecarInjection=true"
+out_disable="$(render --set init.istio.disableSidecarInjection=true)"
+init_job_disable="$(extract_init_job "${out_disable}")"
+config_disable="$(extract_config_secret "${out_disable}")"
+assert_contains "init job sets sidecar.istio.io/inject: \"false\"" \
+    'sidecar.istio.io/inject: "false"' "${init_job_disable}"

Review Comment:
   **Suggestion:** The test requires `init.istio.disableSidecarInjection=true` 
to render the `sidecar.istio.io/inject: "false"` label, but the production 
changes shown only add the termination trap in `superset.initScript`; no 
updated init Job template consumes `disableSidecarInjection`. This case will 
fail and the advertised opt-out mitigation will not work until the init Job pod 
template renders the label. [possible bug]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Istio-injected init-db Jobs remain unable to opt out.
   - ❌ The init-db Job can continue hanging after Superset initialization.
   - ⚠️ The new Helm test fails when the option is enabled.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Run `bash helm/superset/tests/test-istio.sh`, which invokes `render()` at
   `helm/superset/tests/test-istio.sh:61-63` and executes `helm template` 
against the chart.
   
   2. The test renders the chart with `init.istio.disableSidecarInjection=true` 
at
   `helm/superset/tests/test-istio.sh:90-92`.
   
   3. `extract_init_job()` at `helm/superset/tests/test-istio.sh:65-71` 
extracts the manifest
   generated from `helm/superset/templates/init-job.yaml`.
   
   4. The assertion at `helm/superset/tests/test-istio.sh:94-95` expects
   `sidecar.istio.io/inject: "false"`. If 
`helm/superset/templates/init-job.yaml` does not
   consume this value, the label is absent, the assertion fails, and the 
opt-out mitigation
   is not applied to the init-db Job.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=4c084e124d974879b7c70b648424a690&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=4c084e124d974879b7c70b648424a690&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** helm/superset/tests/test-istio.sh
   **Line:** 90:95
   **Comment:**
        *Possible Bug: The test requires 
`init.istio.disableSidecarInjection=true` to render the 
`sidecar.istio.io/inject: "false"` label, but the production changes shown only 
add the termination trap in `superset.initScript`; no updated init Job template 
consumes `disableSidecarInjection`. This case will fail and the advertised 
opt-out mitigation will not work until the init Job pod template renders the 
label.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41396&comment_hash=5d2707d38c50c0ea4e98f27c96ff8f9530ce36cf1426cec5ea2b91ab53895268&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41396&comment_hash=5d2707d38c50c0ea4e98f27c96ff8f9530ce36cf1426cec5ea2b91ab53895268&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to