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.

Fix reviewed Proxmox setup convergence

rcourtmandf04b9b1ffa3
diff --git a/internal/api/config_handlers_setup_script_test.go b/internal/api/config_handlers_setup_script_test.go
index 960ba55b5b..67716bc244 100644
--- a/internal/api/config_handlers_setup_script_test.go
+++ b/internal/api/config_handlers_setup_script_test.go
@@ -150,6 +150,40 @@ func TestHandleSetupScriptUsesCanonicalShellDownloadHeaders(t *testing.T) {
}
}
+func TestPVESetupScriptQuotesTemperatureMonitoringAuthorizedKeyEntry(t *testing.T) {
+ tempDir := t.TempDir()
+ cfg := &config.Config{
+ DataPath: tempDir,
+ ConfigPath: tempDir,
+ }
+
+ handlers := newTestConfigHandlers(t, cfg)
+
+ req := httptest.NewRequest(
+ http.MethodGet,
+ "/api/setup-script?type=pve&host=https://node.example.internal:8006&pulse_url=https://pulse.example.com:7655",
+ nil,
+ )
+ rr := httptest.NewRecorder()
+
+ handlers.HandleSetupScript(rr, req)
+
+ if rr.Code != http.StatusOK {
+ t.Fatalf("expected 200 OK, got %d (%s)", rr.Code, rr.Body.String())
+ }
+
+ script := rr.Body.String()
+ if !containsString(
+ script,
+ `SSH_SENSORS_KEY_ENTRY="command=\"sensors -j\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty $SSH_SENSORS_PUBLIC_KEY # pulse-sensors"`,
+ ) {
+ t.Fatalf("expected temperature monitoring key entry to escape forced-command quotes, got:\n%s", truncate(script, 900))
+ }
+ if containsString(script, `SSH_SENSORS_KEY_ENTRY="command="sensors -j",`) {
+ t.Fatalf("unexpected unescaped temperature monitoring key entry in generated script:\n%s", truncate(script, 900))
+ }
+}
+
func TestHandleSetupScriptRejectsPBSBackupPerms(t *testing.T) {
tempDir := t.TempDir()
cfg := &config.Config{
diff --git a/internal/api/multi_tenant_setters_additional_test.go b/internal/api/multi_tenant_setters_additional_test.go
index b20e5a14f6..6469e7b777 100644
--- a/internal/api/multi_tenant_setters_additional_test.go
+++ b/internal/api/multi_tenant_setters_additional_test.go
@@ -22,6 +22,7 @@ func TestRouterSetMultiTenantMonitor(t *testing.T) {
router := &Router{
alertHandlers: &AlertHandlers{},
notificationHandlers: &NotificationHandlers{},
+ configHandlers: &ConfigHandlers{},
dockerAgentHandlers: &DockerAgentHandlers{},
unifiedAgentHandlers: &UnifiedAgentHandlers{},
kubernetesAgentHandlers: &KubernetesAgentHandlers{},
@@ -39,6 +40,43 @@ func TestRouterSetMultiTenantMonitor(t *testing.T) {
}
}
+func TestRouterSetMultiTenantMonitorRefreshesConfigHandlerMonitorSource(t *testing.T) {
+ oldMonitor, _, _ := newTestMonitor(t)
+ newMonitor, _, _ := newTestMonitor(t)
+
+ oldConfig := &config.Config{DataPath: t.TempDir(), ConfigPath: t.TempDir()}
+ newConfig := &config.Config{DataPath: t.TempDir(), ConfigPath: t.TempDir()}
+ setUnexportedField(t, oldMonitor, "config", oldConfig)
+ setUnexportedField(t, newMonitor, "config", newConfig)
+
+ oldMTM := &monitoring.MultiTenantMonitor{}
+ setUnexportedField(t, oldMTM, "monitors", map[string]*monitoring.Monitor{
+ "default": oldMonitor,
+ })
+ newMTM := &monitoring.MultiTenantMonitor{}
+ setUnexportedField(t, newMTM, "monitors", map[string]*monitoring.Monitor{
+ "default": newMonitor,
+ })
+
+ router := &Router{
+ configHandlers: &ConfigHandlers{},
+ }
+ router.configHandlers.SetMultiTenantMonitor(oldMTM)
+
+ if got := router.configHandlers.getMonitor(context.Background()); got != oldMonitor {
+ t.Fatalf("precondition monitor = %#v, want old monitor %#v", got, oldMonitor)
+ }
+
+ router.SetMultiTenantMonitor(newMTM)
+
+ if got := router.configHandlers.getMonitor(context.Background()); got != newMonitor {
+ t.Fatalf("config handler monitor = %#v, want reloaded monitor %#v", got, newMonitor)
+ }
+ if got := router.configHandlers.getConfig(context.Background()); got != newConfig {
+ t.Fatalf("config handler config = %#v, want reloaded config %#v", got, newConfig)
+ }
+}
+
func TestNewRouterWiresTenantResourceStateProvider(t *testing.T) {
cfg := &config.Config{
DataPath: t.TempDir(),
diff --git a/internal/api/router_helpers.go b/internal/api/router_helpers.go
index 3aaf8f86e3..a62dc48578 100644
--- a/internal/api/router_helpers.go
+++ b/internal/api/router_helpers.go
@@ -82,6 +82,9 @@ func (p *MultiTenantStateProvider) UnifiedResourceSnapshotForTenant(orgID string
// Used during reload.
func (r *Router) SetMultiTenantMonitor(mtm *monitoring.MultiTenantMonitor) {
r.mtMonitor = mtm
+ if r.configHandlers != nil {
+ r.configHandlers.SetMultiTenantMonitor(mtm)
+ }
if r.alertHandlers != nil {
r.alertHandlers.SetMultiTenantMonitor(mtm)
}
@@ -100,6 +103,12 @@ func (r *Router) SetMultiTenantMonitor(mtm *monitoring.MultiTenantMonitor) {
if r.systemSettingsHandler != nil {
r.systemSettingsHandler.SetMultiTenantMonitor(mtm)
}
+ if r.aiSettingsHandler != nil {
+ r.aiSettingsHandler.SetMultiTenantMonitor(mtm)
+ }
+ if r.aiHandler != nil {
+ r.aiHandler.SetMultiTenantMonitor(mtm)
+ }
if mtm != nil {
if m, err := mtm.GetMonitor("default"); err == nil {
r.monitor = m
diff --git a/internal/api/router_helpers_more_test.go b/internal/api/router_helpers_more_test.go
index bdeeb347df..d6d58eeb1a 100644
--- a/internal/api/router_helpers_more_test.go
+++ b/internal/api/router_helpers_more_test.go
@@ -150,10 +150,13 @@ func TestSetMultiTenantMonitor_WiresHandlers(t *testing.T) {
router := &Router{
alertHandlers: &AlertHandlers{},
notificationHandlers: &NotificationHandlers{},
+ configHandlers: &ConfigHandlers{},
dockerAgentHandlers: &DockerAgentHandlers{},
unifiedAgentHandlers: &UnifiedAgentHandlers{},
kubernetesAgentHandlers: &KubernetesAgentHandlers{},
systemSettingsHandler: &SystemSettingsHandler{},
+ aiSettingsHandler: &AISettingsHandler{},
+ aiHandler: &AIHandler{},
resourceHandlers: &ResourceHandlers{},
}
@@ -171,6 +174,9 @@ func TestSetMultiTenantMonitor_WiresHandlers(t *testing.T) {
if router.notificationHandlers.mtMonitor != mtm {
t.Fatalf("expected notificationHandlers mtMonitor to be set")
}
+ if router.configHandlers.mtMonitor != mtm {
+ t.Fatalf("expected configHandlers mtMonitor to be set")
+ }
if router.dockerAgentHandlers.mtMonitor != mtm {
t.Fatalf("expected dockerAgentHandlers mtMonitor to be set")
}
@@ -183,6 +189,12 @@ func TestSetMultiTenantMonitor_WiresHandlers(t *testing.T) {
if router.systemSettingsHandler.mtMonitor != mtm {
t.Fatalf("expected systemSettingsHandler mtMonitor to be set")
}
+ if router.aiSettingsHandler.mtMonitor != mtm {
+ t.Fatalf("expected aiSettingsHandler mtMonitor to be set")
+ }
+ if router.aiHandler.mtMonitor != mtm {
+ t.Fatalf("expected aiHandler mtMonitor to be set")
+ }
if router.resourceHandlers.tenantStateProvider == nil {
t.Fatalf("expected tenant state provider to be set")
}
diff --git a/internal/api/setup_script_render.go b/internal/api/setup_script_render.go
index af53559e7c..3a89dd597e 100644
--- a/internal/api/setup_script_render.go
+++ b/internal/api/setup_script_render.go
@@ -531,7 +531,7 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
echo ""
SSH_SENSORS_PUBLIC_KEY="%s"
-SSH_SENSORS_KEY_ENTRY="command="sensors -j",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty $SSH_SENSORS_PUBLIC_KEY # pulse-sensors"
+SSH_SENSORS_KEY_ENTRY="command=\"sensors -j\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty $SSH_SENSORS_PUBLIC_KEY # pulse-sensors"
TEMPERATURE_ENABLED=false
if [ -n "$SSH_SENSORS_PUBLIC_KEY" ]; then