Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Preserve image healthcheck failures in Docker Compose

pulse-triage[bot]a6fb6e4090c6
diff --git a/docker-compose.yml b/docker-compose.yml
index e1c1e708f2..5151d1d0b8 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -19,7 +19,8 @@ services:
- TZ=${TZ:-UTC}
- PULSE_DEPLOYMENT_METHOD=docker_compose
healthcheck:
- test: ["CMD-SHELL", "[ -x /docker-healthcheck.sh ] && /docker-healthcheck.sh || wget --quiet --tries=1 --spider http://localhost:7655/api/health"]
+ # A failed image probe must stay failed, not retry over a different protocol.
+ test: ["CMD-SHELL", "if [ -x /docker-healthcheck.sh ]; then exec /docker-healthcheck.sh; else exec wget --quiet --tries=1 --spider http://localhost:7655/api/health; fi"]
interval: 30s
timeout: 10s
retries: 3
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 7d28e7bb20..956a8af873 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -16,6 +16,24 @@
## Purpose
+### Compose preserves the image healthcheck verdict
+
+The bundled Compose configuration and first-install generator select the
+image's executable `/docker-healthcheck.sh` when available. Its exit status
+and diagnostic are final: a failed HTTPS-aware or custom image probe must not
+trigger an HTTP retry that can turn failure into success. The existing HTTP
+probe remains a compatibility fallback only when that script is not executable.
+Probe intervals, deadlines, retry counts, image pins, credentials, volumes and
+existing-deployment admission remain unchanged. This is container-local health
+reporting, not external TLS verification or installed/customer recovery.
+
+`TestDockerComposeHealthcheckPreservesImageProbe` executes the actual commands
+from both parsed Compose producers with the shipped probe and an inert `wget`.
+It covers HTTP/HTTPS/`1`/unset selection, unsuccessful HTTPS alongside successful
+HTTP, legacy absent/non-executable helpers, and a custom image's exit/diagnostic.
+No live endpoint, Docker daemon, service restart or release qualification is
+performed by these registered installer tests.
+
### Removal refusals distinguish retained files from running services
A missing saved URL with collector credentials refuses before stopping or
diff --git a/scripts/install-docker.sh b/scripts/install-docker.sh
index a9c313ab79..5ee27ad7f4 100755
--- a/scripts/install-docker.sh
+++ b/scripts/install-docker.sh
@@ -119,7 +119,8 @@ services:
environment:
- TZ=\${TZ:-UTC}
healthcheck:
- test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:7655/api/health"]
+ # Use the image's HTTPS-aware probe; HTTP is only for images without it.
+ test: ["CMD-SHELL", "if [ -x /docker-healthcheck.sh ]; then exec /docker-healthcheck.sh; else exec wget --quiet --tries=1 --spider http://localhost:7655/api/health; fi"]
interval: 30s
timeout: 10s
retries: 3
diff --git a/scripts/installtests/install_docker_sh_test.go b/scripts/installtests/install_docker_sh_test.go
index 8a5d2a1621..42738f231a 100644
--- a/scripts/installtests/install_docker_sh_test.go
+++ b/scripts/installtests/install_docker_sh_test.go
@@ -8,6 +8,8 @@ import (
"strconv"
"strings"
"testing"
+
+ "gopkg.in/yaml.v3"
)
func currentReleaseVersion(t *testing.T) string {
@@ -386,6 +388,120 @@ func TestInstallDockerScriptPrefersExplicitPulseImage(t *testing.T) {
}
}
+// Execute the commands from both real Compose producers. Only the fixed
+// image-local script path is relocated; the shipped probe runs unchanged with
+// an inert wget double. These fixtures need neither Docker nor a live endpoint.
+func TestDockerComposeHealthcheckPreservesImageProbe(t *testing.T) {
+ generatedDir := t.TempDir()
+ runInstallDockerScript(t, generatedDir)
+ for name, composePath := range map[string]string{
+ "bundled": repoFile("docker-compose.yml"),
+ "generated": filepath.Join(generatedDir, "docker-compose.yml"),
+ } {
+ t.Run(name, func(t *testing.T) {
+ content, err := os.ReadFile(composePath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var compose struct {
+ Services map[string]struct {
+ Healthcheck struct {
+ Test []string `yaml:"test"`
+ } `yaml:"healthcheck"`
+ } `yaml:"services"`
+ }
+ if err := yaml.Unmarshal(content, &compose); err != nil {
+ t.Fatalf("parse Compose healthcheck: %v", err)
+ }
+ command := compose.Services["pulse"].Healthcheck.Test
+ if len(command) != 2 || command[0] != "CMD-SHELL" {
+ t.Fatalf("expected a shell image-probe selector, got %q", command)
+ }
+ if strings.Count(command[1], "/docker-healthcheck.sh") != 2 {
+ t.Fatal("image-probe path boundary changed; update the explicit fixture")
+ }
+ for _, tc := range []struct {
+ name, helper, https string
+ httpExit, httpsExit int
+ wantExit int
+ wantProbes string
+ }{
+ {"http healthy", "shipped", "false", 0, 1, 0, "http\n"},
+ {"http unhealthy", "shipped", "false", 1, 0, 1, "http\n"},
+ {"https healthy", "shipped", "true", 1, 0, 0, "https\n"},
+ {"https numeric healthy", "shipped", "1", 1, 0, 0, "https\n"},
+ {"https unhealthy with healthy http", "shipped", "true", 0, 1, 1, "https\n"},
+ {"https numeric unhealthy with healthy http", "shipped", "1", 0, 1, 1, "https\n"},
+ {"unset uses http", "shipped", "", 0, 1, 0, "http\n"},
+ {"legacy healthy", "absent", "", 0, 1, 0, "http\n"},
+ {"legacy unhealthy", "absent", "", 1, 0, 1, "http\n"},
+ {"nonexecutable legacy helper", "nonexecutable", "", 0, 1, 0, "http\n"},
+ {"custom image failure", "custom", "", 0, 0, 17, ""},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ dir := t.TempDir()
+ helperPath := filepath.Join(dir, "docker-healthcheck.sh")
+ if tc.helper != "absent" {
+ helper, err := os.ReadFile(repoFile("docker-healthcheck.sh"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ mode := os.FileMode(0o700)
+ if tc.helper == "nonexecutable" {
+ mode = 0o600
+ }
+ if tc.helper == "custom" {
+ helper = []byte("#!/bin/sh\necho 'image probe refused' >&2\nexit 17\n")
+ }
+ if err := os.WriteFile(helperPath, helper, mode); err != nil {
+ t.Fatal(err)
+ }
+ }
+ writeTestStub(t, filepath.Join(dir, "wget"), `#!/bin/sh
+case "$*" in
+ *https://localhost:7655/api/health*) protocol=https; result="$HTTPS_RESULT";;
+ *http://localhost:7655/api/health*) protocol=http; result="$HTTP_RESULT";;
+ *) echo 'unexpected probe target' >&2; exit 93;;
+esac
+printf '%s\n' "$protocol" >> "$PROBE_LOG"
+exit "$result"
+`)
+ probeLog := filepath.Join(dir, "probes")
+ cmd := exec.Command("sh", "-c", strings.ReplaceAll(command[1], "/docker-healthcheck.sh", `"`+helperPath+`"`))
+ cmd.Env = []string{
+ "PATH=" + dir,
+ "HTTP_RESULT=" + strconv.Itoa(tc.httpExit),
+ "HTTPS_RESULT=" + strconv.Itoa(tc.httpsExit),
+ "PROBE_LOG=" + probeLog,
+ }
+ if tc.https != "" {
+ cmd.Env = append(cmd.Env, "HTTPS_ENABLED="+tc.https)
+ }
+ output, err := cmd.CombinedOutput()
+ exitCode := 0
+ if err != nil {
+ if exitErr, ok := err.(*exec.ExitError); ok {
+ exitCode = exitErr.ExitCode()
+ } else {
+ t.Fatalf("run healthcheck: %v", err)
+ }
+ }
+ probes, readErr := os.ReadFile(probeLog)
+ if readErr != nil && !os.IsNotExist(readErr) {
+ t.Fatal(readErr)
+ }
+ if exitCode != tc.wantExit || string(probes) != tc.wantProbes {
+ t.Fatalf("exit=%d probes=%q; want exit=%d probes=%q\n%s", exitCode, probes, tc.wantExit, tc.wantProbes, output)
+ }
+ if tc.helper == "custom" && !strings.Contains(string(output), "image probe refused") {
+ t.Fatalf("image probe diagnostic was lost: %s", output)
+ }
+ })
+ }
+ })
+ }
+}
+
func TestRepoDockerComposeDefaultPinsCurrentVersion(t *testing.T) {
version := currentReleaseVersion(t)
content, err := os.ReadFile(repoFile("docker-compose.yml"))