fix(qdrant): scrape TLS metrics over HTTPS

TLS-enabled Qdrant rejects the ServiceMonitor's HTTP requests. The
vendored chart exposes no scheme or CA value, so patch its endpoint
through the existing HelmRelease post-renderer mechanism. Trust the
issued CA and use a certificate SAN without disabling verification.

Tested the app-to-system chart render through Kustomize for explicit
TLS, external default TLS and explicit opt-out; the TLS cases fail
without the patch.

Fixes: cdb03a9929 ("feat(qdrant): implement TLS in Helm templates")
Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
(cherry picked from commit d009a1e737)
Signed-off-by: cozystack-ci[bot] <274107086+cozystack-ci[bot]@users.noreply.github.com>
This commit is contained in:
Yan Bondarenko authored and Myasnikov Daniil committed 2026-11-25 09:58:12 +00:00
1 parent 68d63dbbee
commit e509806cbf
2 files changed
+71

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bats
load test_helper
setup() {
strict_setup
REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/.." && pwd)"
export KUBECONFIG=/dev/null
}
render_monitor() {
helm template test-qdrant "$REPO_ROOT/packages/apps/qdrant" \
--namespace tenant-test --set _namespace.host=tenant.example.test "$@" > "$BATS_TEST_TMPDIR/app.yaml"
yq 'select(.kind == "HelmRelease") | .spec.values' "$BATS_TEST_TMPDIR/app.yaml" > "$BATS_TEST_TMPDIR/values.yaml"
helm template test-qdrant-system "$REPO_ROOT/packages/system/qdrant" \
--namespace tenant-test --values "$BATS_TEST_TMPDIR/values.yaml" > "$BATS_TEST_TMPDIR/system.yaml"
yq 'select(.kind == "HelmRelease") | {
"apiVersion": "kustomize.config.k8s.io/v1beta1",
"kind": "Kustomization",
"resources": ["system.yaml"],
"patches": (.spec.postRenderers[0].kustomize.patches // [])
}' "$BATS_TEST_TMPDIR/app.yaml" > "$BATS_TEST_TMPDIR/kustomization.yaml"
kubectl kustomize "$BATS_TEST_TMPDIR" > "$BATS_TEST_TMPDIR/rendered.yaml"
yq 'select(.kind == "ServiceMonitor") | .spec.endpoints[0]' "$BATS_TEST_TMPDIR/rendered.yaml" > "$BATS_TEST_TMPDIR/endpoint.yaml"
[ "$(yq '.authorization.credentials.name' "$BATS_TEST_TMPDIR/endpoint.yaml")" = test-qdrant-apikey ]
[ "$(yq '.authorization.credentials.key' "$BATS_TEST_TMPDIR/endpoint.yaml")" = api-key ]
[ "$(yq '.port' "$BATS_TEST_TMPDIR/endpoint.yaml")" = http ]
}
@test "TLS monitoring uses the issued CA and a certificate SAN" {
render_monitor --set tls.enabled=true --set _cluster.cluster-domain=cluster.test
[ "$(yq '.scheme' "$BATS_TEST_TMPDIR/endpoint.yaml")" = https ]
[ "$(yq '.tlsConfig.ca.secret.name' "$BATS_TEST_TMPDIR/endpoint.yaml")" = test-qdrant-tls ]
[ "$(yq '.tlsConfig.ca.secret.key' "$BATS_TEST_TMPDIR/endpoint.yaml")" = ca.crt ]
[ "$(yq '.tlsConfig.insecureSkipVerify // false' "$BATS_TEST_TMPDIR/endpoint.yaml")" = false ]
server_name="$(yq '.tlsConfig.serverName' "$BATS_TEST_TMPDIR/endpoint.yaml")"
SERVER_NAME="$server_name" yq --exit-status 'select(.kind == "Certificate" and .metadata.name == "test-qdrant-tls") | .spec.dnsNames | contains([strenv(SERVER_NAME)])' "$BATS_TEST_TMPDIR/app.yaml"
}
@test "external Qdrant enables HTTPS monitoring by default" {
render_monitor --set external=true
[ "$(yq '.scheme' "$BATS_TEST_TMPDIR/endpoint.yaml")" = https ]
}
@test "disabled TLS keeps HTTP monitoring without TLS configuration" {
render_monitor --set external=true --set tls.enabled=false
[ "$(yq '.scheme' "$BATS_TEST_TMPDIR/endpoint.yaml")" = http ]
[ "$(yq 'has("tlsConfig")' "$BATS_TEST_TMPDIR/endpoint.yaml")" = false ]
}