diff --git a/.github/workflows/pmm-ha-pr-checks.yaml b/.github/workflows/pmm-ha-pr-checks.yaml index ad9b06941..2302de164 100644 --- a/.github/workflows/pmm-ha-pr-checks.yaml +++ b/.github/workflows/pmm-ha-pr-checks.yaml @@ -138,11 +138,11 @@ jobs: fi } - # HA peer list and HAProxy backends must use the StatefulSet name, not Release.Name. + # The HA peer list must use the StatefulSet name, not Release.Name. + # HAProxy has no per-pod names to check: it discovers backends through the + # headless service via server-template, with no init script (PMM-15394). assert_has "value: \"pmm-2-pmm-ha-0.monitoring-service.${NS}.svc.cluster.local" "PMM_HA_PEERS" - assert_has "pmm_host=\"pmm-2-pmm-ha-\$i.monitoring-service.${NS}.svc.cluster.local\"" "haproxy init script" assert_lacks "pmm-2-0.monitoring-service" "PMM_HA_PEERS uses Release.Name" - assert_lacks "pmm_host=\"pmm-2-\$i." "haproxy init script uses Release.Name" # ClickHouse/Keeper scrape jobs match the chi/chk pod label, which carries Release.Name. assert_has "regex: 'pmm-2'" "clickhouse scrape job selector" diff --git a/charts/pmm-ha-dependencies/README.md b/charts/pmm-ha-dependencies/README.md index 83b15a4b6..0d954edca 100644 --- a/charts/pmm-ha-dependencies/README.md +++ b/charts/pmm-ha-dependencies/README.md @@ -136,8 +136,8 @@ of that rule matter: 1. **A separate namespace per instance.** Several of the chart's namespaced objects have fixed names that do *not* include the release name — `pmm-ha-haproxy`, - `pmm-ha-haproxy-init-script`, `monitoring-service`, `pmm-service-account`, - `haproxy-tls-secret` and `postgresql-init-extensions`. A second instance in the **same** + `monitoring-service`, `pmm-service-account`, `haproxy-tls-secret` and + `postgresql-init-extensions`. A second instance in the **same** namespace collides on those no matter what it is called: the install either aborts on an existing resource, or — on an adopt/`--force` path — silently repoints the first instance's HAProxy at the second instance's pods. diff --git a/charts/pmm-ha/Chart.yaml b/charts/pmm-ha/Chart.yaml index 8994e3dfb..3fa9ced49 100644 --- a/charts/pmm-ha/Chart.yaml +++ b/charts/pmm-ha/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: pmm-ha description: A Helm chart for Percona Monitoring and Management (PMM) type: application -version: 1.6.1 +version: 1.6.2 appVersion: "3.9.1" home: https://github.com/percona/pmm maintainers: diff --git a/charts/pmm-ha/templates/haproxy-init-configmap.yaml b/charts/pmm-ha/templates/haproxy-init-configmap.yaml deleted file mode 100644 index f5a869a6d..000000000 --- a/charts/pmm-ha/templates/haproxy-init-configmap.yaml +++ /dev/null @@ -1,75 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: pmm-ha-haproxy-init-script - namespace: {{ .Release.Namespace }} -data: - wait-for-pmm.sh: | - #!/bin/sh - set -euo pipefail - - echo "HAProxy init: Waiting for PMM instances to be ready..." - echo "Current namespace: {{ .Release.Namespace }}" - echo "Expected PMM replicas: {{ .Values.replicas }}" - - # Install curl if not available - if ! command -v curl >/dev/null 2>&1; then - echo "Installing curl..." - apk add --no-cache curl > /dev/null 2>&1 - fi - - # Check if PMM instance is ready - check_pmm_ready() { - local pmm_host="$1" - local pmm_port="$2" - local timeout="${3:-10}" - - echo "Checking PMM instance: $pmm_host:$pmm_port" - - local https_code=$(curl -sL --max-time "$timeout" -k -o /dev/null -w "%{http_code}" "https://$pmm_host:$pmm_port/") - if [ "$https_code" = "200" ]; then - echo "✅ HTTPS connection check passed for $pmm_host:$pmm_port (status: $https_code)" - return 0 - else - echo "❌ Connection check failed for $pmm_host:$pmm_port (HTTPS status: $https_code)" - return 1 - fi - } - - # Main loop - max_attempts=60 - attempt=1 - - while [ $attempt -le $max_attempts ]; do - echo "Attempt $attempt/$max_attempts: Checking PMM instances..." - - all_ready=true - ready_count=0 - - for i in $(seq 0 $(({{ .Values.replicas }} - 1))); do - pmm_host="{{ include "pmm.fullname" . }}-$i.{{ .Values.service.name | default "monitoring-service" }}.{{ .Release.Namespace }}.svc.cluster.local" - - if check_pmm_ready "$pmm_host" "8443" 5; then - ready_count=$((ready_count + 1)) - echo "✅ Instance $i is ready ($ready_count/{{ .Values.replicas }})" - else - echo "❌ Instance $i is not ready yet" - all_ready=false - fi - done - - echo "Ready instances: $ready_count/{{ .Values.replicas }}" - - if [ "$all_ready" = true ]; then - echo "🎉 All PMM instances are ready! HAProxy can now start." - exit 0 - fi - - echo "⏳ Not all PMM instances are ready yet. Waiting 5 seconds..." - sleep 5 - attempt=$((attempt + 1)) - done - - echo "❌ Timeout: PMM instances did not become ready within 5 minutes" - echo "This may indicate an issue with PMM deployment" - exit 1 diff --git a/charts/pmm-ha/values.yaml b/charts/pmm-ha/values.yaml index 9687e6f6d..2c860f9d0 100644 --- a/charts/pmm-ha/values.yaml +++ b/charts/pmm-ha/values.yaml @@ -641,31 +641,12 @@ haproxy: labelSelector: matchLabels: app.kubernetes.io/name: haproxy - # Init container to wait for PMM instances to be ready - initContainers: - - name: wait-for-pmm-ready - image: "alpine:latest" - command: - - /bin/sh - - /scripts/wait-for-pmm.sh - volumeMounts: - - name: init-script - mountPath: /scripts - readOnly: true - resources: - requests: - cpu: 50m - memory: 32Mi - limits: - cpu: 100m - memory: 64Mi - - # Additional volumes for init container - extraVolumes: - - name: init-script - configMap: - name: pmm-ha-haproxy-init-script - defaultMode: 0755 + # No init container. HAProxy starts immediately and discovers PMM itself: + # server-template carries "init-addr last,libc,none", so a backend whose DNS name does + # not resolve yet is held with no address rather than aborting startup, and the + # /v1/server/leaderHealthCheck check brings it UP only once it is genuinely serving. + # Waiting for every replica first turned "HAProxy up, no backends yet" into "no HAProxy + # at all" - see PMM-15394. # Disable default ConfigMap creation - we create our own configMap: enabled: false