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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Stamp command policy intent on hosted tenant install tokens
rcourtmanb0d6c95a9322
diff --git a/internal/api/cloud_agent_install_command.go b/internal/api/cloud_agent_install_command.goindex a1ccaa2c59..08cb33edfb 100644--- a/internal/api/cloud_agent_install_command.go+++ b/internal/api/cloud_agent_install_command.go@@ -8,6 +8,7 @@ import ("strings""time"+ "github.com/rcourtman/pulse-go-rewrite/internal/api/agenttokens""github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/monitoring""github.com/rs/zerolog/log"@@ -74,6 +75,11 @@ func GenerateHostedTenantAgentInstallCommand(opts HostedTenantAgentInstallCommanMetadata: map[string]string{"install_type": installType,"issued_via": "hosted_agent_install_command",+ // Hosted installs have no enableCommands toggle; commands follow the+ // install type like the self-hosted flow (pve on, pbs off). Without+ // this stamp, reconcileInstallTokenCommandPolicy skips the token and+ // a reinstall never clears a stale disabled policy (#1728).+ agenttokens.CommandPolicyIntentMetadataKey: agenttokens.CommandPolicyIntent(installType == proxmoxInstallTypePVE),},})if err != nil {diff --git a/internal/api/hosted_agent_install_command_test.go b/internal/api/hosted_agent_install_command_test.goindex 6a64c2bcdf..576272491f 100644--- a/internal/api/hosted_agent_install_command_test.go+++ b/internal/api/hosted_agent_install_command_test.go@@ -10,6 +10,7 @@ import ("testing""time"+ "github.com/rcourtman/pulse-go-rewrite/internal/api/agenttokens""github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/monitoring"agentshost "github.com/rcourtman/pulse-go-rewrite/pkg/agents/host"@@ -158,6 +159,50 @@ func TestGenerateHostedTenantAgentInstallCommandEnforcesHostedOrgBoundary(t *tesrequire.True(t, ok)}+func TestHostedTenantAgentInstallCommandCarriesCommandPolicyIntent(t *testing.T) {+ setMockModeForTest(t, true)++ dataDir := t.TempDir()+ cfg := &config.Config{+ DataPath: dataDir,+ PublicURL: "https://cloud.example.com",+ }+ persistence := config.NewConfigPersistence(dataDir)+ multiTenant := config.NewMultiTenantPersistence(dataDir)+ orgID := "acme"+ _, err := multiTenant.GetPersistence(orgID)+ require.NoError(t, err)++ for _, tc := range []struct {+ installType string+ wantIntent string+ }{+ {installType: "pve", wantIntent: agenttokens.CommandPolicyIntentEnabled},+ {installType: "pbs", wantIntent: agenttokens.CommandPolicyIntentDisabled},+ } {+ result, err := GenerateHostedTenantAgentInstallCommand(HostedTenantAgentInstallCommandOptions{+ Config: cfg,+ Persistence: persistence,+ MultiTenant: multiTenant,+ HostedMode: true,+ OrgID: orgID,+ InstallType: tc.installType,+ BaseURL: "https://acme.cloud.example.com",+ })+ require.NoError(t, err)++ var record *config.APITokenRecord+ for index := range cfg.APITokens {+ if cfg.APITokens[index].ID == result.TokenID {+ record = &cfg.APITokens[index]+ break+ }+ }+ require.NotNil(t, record, "minted token record not found for %s", tc.installType)+ require.Equal(t, tc.wantIntent, record.Metadata[agenttokens.CommandPolicyIntentMetadataKey], "install type %s", tc.installType)+ }+}+func TestHostedTenantAgentInstallTokenCannotReportToOtherTenant(t *testing.T) {defer SetMultiTenantEnabled(false)SetMultiTenantEnabled(true)