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.

Allow TrueNAS CORE 12 legacy REST negotiation

pulse-triage[bot]9d1deb2a0a53
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index ecfaee934d..91e217b41b 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -934,9 +934,15 @@ cleanup so readers cannot retain orphaned runtime or alert projections.
deprecated REST bridge. Only an unsupported-endpoint WebSocket handshake
may trigger a REST `/system/info` version probe, and REST may then be
selected only for recognized SCALE releases before 25.04 or TrueNAS
- CORE/FreeNAS. Unknown or current versions fail closed. The decision and
- persistent socket belong to one configured client, so reconnects or
- legacy negotiation for one appliance cannot alter another appliance.
+ CORE/FreeNAS. The legacy probe recognizes the `TrueNAS-12.` and
+ `TrueNAS-13` prefixes, versions carrying an explicit `CORE` marker, and
+ the `FreeNAS-` prefix; this includes CORE 12 maintenance releases such as
+ `TrueNAS-12.0-U5` without admitting an unknown numeric family. Unknown or
+ current versions fail closed. The decision and persistent socket belong
+ to one configured client, so reconnects or legacy negotiation for one
+ appliance cannot alter another appliance. Regression coverage for the
+ exact CORE 12 and CORE 13 HTTPS redirect/version paths lives in
+ `internal/truenas/transport_test.go`.
On a connection already configured as HTTPS, an `/api/current` handshake
that redirects to the same appliance's HTTPS web UI is unsupported-endpoint
evidence, not successful JSON-RPC negotiation. It may open only the bounded
diff --git a/internal/truenas/transport.go b/internal/truenas/transport.go
index 92879bb5a7..9c79cfc069 100644
--- a/internal/truenas/transport.go
+++ b/internal/truenas/transport.go
@@ -507,8 +507,11 @@ func supportsLegacyREST(version string) bool {
major, minor, ok := trueNASYearRelease(normalized)
return ok && (major < 25 || (major == 25 && minor < 4))
}
- // TrueNAS CORE 13 does not expose the versioned JSON-RPC 2.0 endpoint.
- return strings.Contains(normalized, "CORE") || strings.HasPrefix(normalized, "TRUENAS-13") || strings.HasPrefix(normalized, "FREENAS-")
+ // TrueNAS CORE 12 and 13 do not expose the versioned JSON-RPC 2.0 endpoint.
+ return strings.Contains(normalized, "CORE") ||
+ strings.HasPrefix(normalized, "TRUENAS-12.") ||
+ strings.HasPrefix(normalized, "TRUENAS-13") ||
+ strings.HasPrefix(normalized, "FREENAS-")
}
func trueNASYearRelease(version string) (int, int, bool) {
diff --git a/internal/truenas/transport_test.go b/internal/truenas/transport_test.go
index c421e1358d..e068861e88 100644
--- a/internal/truenas/transport_test.go
+++ b/internal/truenas/transport_test.go
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"errors"
+ "fmt"
"net/http"
"net/http/httptest"
"net/url"
@@ -331,39 +332,47 @@ func TestTransportNegotiationAllowsOnlyRecognizedLegacyREST(t *testing.T) {
}
})
- t.Run("legacy core https redirect", func(t *testing.T) {
- var poolRESTCalls atomic.Int32
- server := httptest.NewTLSServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
- switch request.URL.Path {
- case "/api/current":
- http.Redirect(writer, request, "/ui/", http.StatusFound)
- case "/api/v2.0/system/info":
- _, _ = writer.Write([]byte(`{"hostname":"core","version":"TrueNAS-13.0-U6.4","uptime_seconds":1}`))
- case "/api/v2.0/pool":
- poolRESTCalls.Add(1)
- _, _ = writer.Write([]byte(`[{"id":1,"name":"core-tank","status":"ONLINE"}]`))
- default:
- http.NotFound(writer, request)
- }
- }))
- t.Cleanup(server.Close)
+ for _, test := range []struct {
+ name string
+ version string
+ }{
+ {name: "legacy core 12 https redirect", version: "TrueNAS-12.0-U5"},
+ {name: "legacy core 13 https redirect", version: "TrueNAS-13.0-U6.4"},
+ } {
+ t.Run(test.name, func(t *testing.T) {
+ var poolRESTCalls atomic.Int32
+ server := httptest.NewTLSServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
+ switch request.URL.Path {
+ case "/api/current":
+ http.Redirect(writer, request, "/ui/", http.StatusFound)
+ case "/api/v2.0/system/info":
+ _, _ = fmt.Fprintf(writer, `{"hostname":"core","version":%q,"uptime_seconds":1}`, test.version)
+ case "/api/v2.0/pool":
+ poolRESTCalls.Add(1)
+ _, _ = writer.Write([]byte(`[{"id":1,"name":"core-tank","status":"ONLINE"}]`))
+ default:
+ http.NotFound(writer, request)
+ }
+ }))
+ t.Cleanup(server.Close)
- client := protocolFixtureClient(t, server.URL, ClientConfig{APIKey: "legacy-core-key"})
- pools, err := client.GetPools(context.Background())
- if err != nil {
- t.Fatalf("GetPools() redirected CORE error = %v", err)
- }
- if len(pools) != 1 || pools[0].Name != "core-tank" {
- t.Fatalf("unexpected redirected CORE pools: %+v", pools)
- }
- if poolRESTCalls.Load() != 1 {
- t.Fatalf("redirected CORE pool REST calls = %d, want 1", poolRESTCalls.Load())
- }
- if status := client.TransportStatus(); status.Mode != TransportLegacyREST ||
- status.ApplianceVersion != "TrueNAS-13.0-U6.4" {
- t.Fatalf("unexpected redirected CORE status: %+v", status)
- }
- })
+ client := protocolFixtureClient(t, server.URL, ClientConfig{APIKey: "legacy-core-key"})
+ pools, err := client.GetPools(context.Background())
+ if err != nil {
+ t.Fatalf("GetPools() redirected CORE error = %v", err)
+ }
+ if len(pools) != 1 || pools[0].Name != "core-tank" {
+ t.Fatalf("unexpected redirected CORE pools: %+v", pools)
+ }
+ if poolRESTCalls.Load() != 1 {
+ t.Fatalf("redirected CORE pool REST calls = %d, want 1", poolRESTCalls.Load())
+ }
+ if status := client.TransportStatus(); status.Mode != TransportLegacyREST ||
+ status.ApplianceVersion != test.version {
+ t.Fatalf("unexpected redirected CORE status: %+v", status)
+ }
+ })
+ }
t.Run("current scale fail closed", func(t *testing.T) {
var poolRESTCalls atomic.Int32