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.

Keep the Pro runtime switch off stable-channel prereleases

rcourtmanaf946205329b
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index f0fbfeb726..f5c6b0e851 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -2748,8 +2748,12 @@ payload shape change when the portal presents compact client rows.
whether a community build can switch to the Pulse Pro runtime as
`{available, reason?, currentVersion, version?, installInPlace, docker?}`,
where `reason` is the closed set `already_pro`, `not_activated`,
- `not_eligible`, `source_build`, `unsupported_deployment`, `older_release`
- and `unavailable`, and `docker` reuses the `DockerUpdateCommands` shape.
+ `not_eligible`, `source_build`, `unsupported_deployment`, `older_release`,
+ `prerelease_only` and `unavailable`, and `docker` reuses the
+ `DockerUpdateCommands` shape. `prerelease_only` means the broker's pinned
+ Pro release is a prerelease while the install follows the stable channel,
+ so the answer carries the pinned `version` but offers neither an in-place
+ switch nor Docker commands; rc-channel installs are still offered the pin.
`POST /api/updates/pro-runtime/apply` (admin plus `settings:write`) takes
no body, re-checks that an in-place switch is offered (otherwise a plain
conflict response, with the reason logged rather than returned), runs the
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index fe053f1883..1e7c547c61 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -3145,6 +3145,12 @@ artifact-selection behaviour.
entry keeps the normal rollback back to the community build. Docker
installs get the broker's digest-pinned Docker command block as
`ProRuntimeSwitch.docker` instead, never the community image.
+ The switch check applies the same stable-channel guard as the Pro update
+ check and apply (`stableChannelRefusesProPin` in `pro_update.go`): a
+ stable-channel install whose broker pin is a prerelease is answered
+ `prerelease_only` with the pinned version and is offered neither the
+ in-place switch nor the Docker command block, so a stable install is never
+ moved onto a preview Pro build; rc-channel installs are still offered it.
A Docker deployment of the compiled Pro binary is part of that same
boundary: the container cannot self-replace its binary and a Pro compose
file pins the previous image digest, so `internal/updates/pro_update.go`
diff --git a/internal/api/updates_test.go b/internal/api/updates_test.go
index 2de680aa75..5dead0eff8 100644
--- a/internal/api/updates_test.go
+++ b/internal/api/updates_test.go
@@ -1315,6 +1315,21 @@ func TestClassifyApplyUpdateStartError_ProActivation(t *testing.T) {
}
}
+// TestClassifyApplyUpdateStartError_ProStablePrerelease keeps the Pro broker's
+// stable-channel refusal (also reached by the Pro runtime switch) a 409 whose
+// explanation reaches the UI, not the generic 500 "Failed to start update".
+func TestClassifyApplyUpdateStartError_ProStablePrerelease(t *testing.T) {
+ err := errors.New("stable channel cannot install prerelease builds (the private Pulse Pro channel currently serves 6.1.0-rc.1)")
+
+ status, msg := classifyApplyUpdateStartError(err)
+ if status != http.StatusConflict {
+ t.Fatalf("expected 409 for the stable-channel prerelease refusal, got %d", status)
+ }
+ if !strings.Contains(msg, "6.1.0-rc.1") {
+ t.Fatalf("expected the refusal message to pass through, got %q", msg)
+ }
+}
+
func TestHandleCheckUpdatesFreshness(t *testing.T) {
for _, tc := range []struct {
query string
diff --git a/internal/updates/pro_runtime_switch.go b/internal/updates/pro_runtime_switch.go
index 6f032997c2..a69233760b 100644
--- a/internal/updates/pro_runtime_switch.go
+++ b/internal/updates/pro_runtime_switch.go
@@ -27,7 +27,10 @@ const (
ProRuntimeSwitchReasonSourceBuild = "source_build"
ProRuntimeSwitchReasonUnsupported = "unsupported_deployment"
ProRuntimeSwitchReasonOlderRelease = "older_release"
- ProRuntimeSwitchReasonUnavailable = "unavailable"
+ // The broker's Pro pin is a prerelease and this install follows the
+ // stable channel, which never installs prereleases.
+ ProRuntimeSwitchReasonPrereleaseOnly = "prerelease_only"
+ ProRuntimeSwitchReasonUnavailable = "unavailable"
)
const (
@@ -112,7 +115,8 @@ func (m *Manager) CheckProRuntimeSwitch(ctx context.Context, channel string) (*P
return result, nil
}
- manifest, err := m.fetchProDownloadManifest(ctx, creds, m.resolveChannel(channel, currentInfo))
+ channel = m.resolveChannel(channel, currentInfo)
+ manifest, err := m.fetchProDownloadManifest(ctx, creds, channel)
if err != nil {
if isProBrokerRefusal(err) {
result.Reason = ProRuntimeSwitchReasonNotEligible
@@ -127,6 +131,13 @@ func (m *Manager) CheckProRuntimeSwitch(ctx context.Context, channel string) (*P
result.Reason = ProRuntimeSwitchReasonOlderRelease
return result, nil
}
+ // Apply refuses a prerelease pin on the stable channel, so the check must
+ // not offer one: not as an in-place button that would fail, and not as
+ // Docker commands that would pin a stable install to a preview image.
+ if stableChannelRefusesProPin(channel, manifest) {
+ result.Reason = ProRuntimeSwitchReasonPrereleaseOnly
+ return result, nil
+ }
if mode == proRuntimeSwitchModeDocker {
result.Docker = proDockerUpdateCommands(manifest)
diff --git a/internal/updates/pro_runtime_switch_test.go b/internal/updates/pro_runtime_switch_test.go
index df6acc6d28..757d9273e2 100644
--- a/internal/updates/pro_runtime_switch_test.go
+++ b/internal/updates/pro_runtime_switch_test.go
@@ -123,6 +123,80 @@ func TestCheckProRuntimeSwitch(t *testing.T) {
})
}
+// TestCheckProRuntimeSwitchHonoursStableChannel pins the switch check to the
+// channel rule apply enforces: a stable-channel install is never offered a
+// prerelease Pro pin, because apply would refuse it (and Docker commands would
+// move a stable install onto a preview image).
+func TestCheckProRuntimeSwitchHonoursStableChannel(t *testing.T) {
+ check := func(t *testing.T, fixture *proBrokerFixture, channel string) *ProRuntimeSwitch {
+ t.Helper()
+ manager := NewManager(&config.Config{DataPath: t.TempDir()})
+ manager.SetProUpdateCredentialSource(fixture.credentialSource())
+ result, err := manager.CheckProRuntimeSwitch(context.Background(), channel)
+ if err != nil {
+ t.Fatalf("CheckProRuntimeSwitch: %v", err)
+ }
+ return result
+ }
+
+ for _, tc := range []struct {
+ name string
+ version string
+ prerelease bool
+ }{
+ {"broker flags the pin as a prerelease", "6.1.0-rc.1", true},
+ {"pin version is a prerelease without the flag", "6.1.0-rc.1", false},
+ {"same-version pin flagged prerelease", "6.0.5", true},
+ } {
+ t.Run("stable channel: "+tc.name, func(t *testing.T) {
+ setupProRuntimeSwitchTest(t, "6.0.5")
+ fixture := newProBrokerFixture(t, tc.version, tc.prerelease)
+ result := check(t, fixture, "stable")
+ if result.Available || result.InstallInPlace || result.Docker != nil {
+ t.Fatalf("a stable install must not be offered a prerelease Pro pin, got %+v", result)
+ }
+ if result.Reason != ProRuntimeSwitchReasonPrereleaseOnly || result.Version != tc.version {
+ t.Fatalf("expected prerelease_only with the pinned version, got %+v", result)
+ }
+ })
+ }
+
+ t.Run("configured stable channel applies when none is requested", func(t *testing.T) {
+ setupProRuntimeSwitchTest(t, "6.0.5")
+ fixture := newProBrokerFixture(t, "6.1.0-rc.1", true)
+ result := check(t, fixture, "")
+ if result.Available || result.Reason != ProRuntimeSwitchReasonPrereleaseOnly {
+ t.Fatalf("expected the default stable channel to refuse the prerelease pin, got %+v", result)
+ }
+ })
+
+ t.Run("rc channel is still offered the prerelease pin", func(t *testing.T) {
+ setupProRuntimeSwitchTest(t, "6.0.5")
+ fixture := newProBrokerFixture(t, "6.1.0-rc.1", true)
+ result := check(t, fixture, "rc")
+ if !result.Available || !result.InstallInPlace || result.Reason != "" || result.Version != "6.1.0-rc.1" {
+ t.Fatalf("expected an in-place switch on the rc channel, got %+v", result)
+ }
+ if got := fixture.channelQueries[len(fixture.channelQueries)-1]; got != "rc" {
+ t.Fatalf("expected the broker to be asked for the rc channel, got %q", got)
+ }
+ })
+
+ t.Run("apply refuses the same pin with the message the API maps to 409", func(t *testing.T) {
+ setupProRuntimeSwitchTest(t, "6.0.5")
+ fixture := newProBrokerFixture(t, "6.1.0-rc.1", true)
+ manager := NewManager(&config.Config{DataPath: t.TempDir()})
+ manager.SetProUpdateCredentialSource(fixture.credentialSource())
+ err := manager.ApplyProRuntimeSwitch(context.Background(), "stable", InitiatedByUser, InitiatedViaUI)
+ if err == nil || !strings.Contains(err.Error(), "stable channel cannot install prerelease builds") {
+ t.Fatalf("expected the stable-channel prerelease refusal, got: %v", err)
+ }
+ if fixture.tarballCalls != 0 {
+ t.Fatalf("a refused prerelease pin must not be downloaded, got %d downloads", fixture.tarballCalls)
+ }
+ })
+}
+
func TestProRuntimeSwitchMode(t *testing.T) {
t.Setenv("PULSE_ALLOW_DOCKER_UPDATES", "")
cases := []struct {
diff --git a/internal/updates/pro_update.go b/internal/updates/pro_update.go
index ff494b2066..deac3339e2 100644
--- a/internal/updates/pro_update.go
+++ b/internal/updates/pro_update.go
@@ -88,6 +88,24 @@ type proBrokerResponse struct {
Docker *proBrokerDocker `json:"docker"`
}
+// isPrerelease reports whether the broker's pinned release is a prerelease,
+// by the broker's flag or by its version string.
+func (r *proBrokerResponse) isPrerelease() bool {
+ if r.Release.Prerelease {
+ return true
+ }
+ version, err := ParseVersion(r.Release.Version)
+ return err == nil && version.IsPrerelease()
+}
+
+// stableChannelRefusesProPin reports whether a stable-channel install must not
+// install the broker's pinned release. The broker pins a single release, which
+// can be a prerelease; the update check, the runtime switch check and apply
+// all judge it by this one rule so a check never offers what apply refuses.
+func stableChannelRefusesProPin(channel string, manifest *proBrokerResponse) bool {
+ return channel == "stable" && manifest.isPrerelease()
+}
+
// proBrokerDocker mirrors the broker's docker block: the digest-pinned private
// Pro image plus ready-to-run login/compose commands. The broker deliberately
// never emits mutable-tag commands (a customer compose file pins the previous
@@ -340,12 +358,12 @@ func (m *Manager) checkProUpdates(ctx context.Context, channel string, currentIn
if err != nil {
return nil, fmt.Errorf("parse Pulse Pro release version %q: %w", manifest.Release.Version, err)
}
- isPrerelease := manifest.Release.Prerelease || latestVer.IsPrerelease()
+ isPrerelease := manifest.isPrerelease()
// The broker pins a single release. A stable-channel install must not be
// offered a prerelease pin; report "no update" with an explanatory warning
// instead of dangling an apply that the channel guard would refuse.
- if channel == "stable" && isPrerelease && latestVer.IsNewerThan(currentVer) {
+ if stableChannelRefusesProPin(channel, manifest) && latestVer.IsNewerThan(currentVer) {
return &UpdateInfo{
Available: false,
CurrentVersion: currentInfo.Version,
@@ -406,11 +424,10 @@ func (m *Manager) resolveProUpdateArtifact(ctx context.Context, channel string)
return resolvedUpdateArtifact{}, err
}
- latestVer, err := ParseVersion(manifest.Release.Version)
- if err != nil {
+ if _, err := ParseVersion(manifest.Release.Version); err != nil {
return resolvedUpdateArtifact{}, fmt.Errorf("parse Pulse Pro release version %q: %w", manifest.Release.Version, err)
}
- if channel == "stable" && (manifest.Release.Prerelease || latestVer.IsPrerelease()) {
+ if stableChannelRefusesProPin(channel, manifest) {
return resolvedUpdateArtifact{}, fmt.Errorf("stable channel cannot install prerelease builds (the private Pulse Pro channel currently serves %s)", manifest.Release.Version)
}