diff --git a/internal/monitoring/container_parsing.go b/internal/monitoring/container_parsing.go index ac231709e..708af50f9 100644 --- a/internal/monitoring/container_parsing.go +++ b/internal/monitoring/container_parsing.go @@ -492,15 +492,17 @@ func extractContainerOSType(config map[string]interface{}) string { } // parseProxmoxOnBoot extracts the onboot (autostart) setting from a Proxmox -// guest config map. Returns nil when the key is absent or unrecognised so -// callers can distinguish "explicitly off" from "unknown". +// guest config map. Returns nil only when the config is empty/unavailable or +// the value is unrecognised. When the onboot key is absent from a valid config, +// returns false because Proxmox's default is "do not start on boot". func parseProxmoxOnBoot(config map[string]interface{}) *bool { if len(config) == 0 { return nil } raw, ok := config["onboot"] if !ok || raw == nil { - return nil + v := false + return &v } s := strings.TrimSpace(fmt.Sprint(raw)) if s == "" { diff --git a/internal/monitoring/container_parsing_test.go b/internal/monitoring/container_parsing_test.go index d872f3820..40afe2ea7 100644 --- a/internal/monitoring/container_parsing_test.go +++ b/internal/monitoring/container_parsing_test.go @@ -1965,7 +1965,7 @@ func TestParseProxmoxOnBoot(t *testing.T) { }{ {name: "nil config", config: nil, wantNil: true}, {name: "empty config", config: map[string]interface{}{}, wantNil: true}, - {name: "missing key", config: map[string]interface{}{"ostype": "debian"}, wantNil: true}, + {name: "missing key", config: map[string]interface{}{"ostype": "debian"}, wantVal: false}, {name: "onboot 1 (string)", config: map[string]interface{}{"onboot": "1"}, wantVal: true}, {name: "onboot 0 (string)", config: map[string]interface{}{"onboot": "0"}, wantVal: false}, {name: "onboot true", config: map[string]interface{}{"onboot": "true"}, wantVal: true}, diff --git a/internal/monitoring/monitor_pve_guest_builders.go b/internal/monitoring/monitor_pve_guest_builders.go index b9c80c854..9a5edba28 100644 --- a/internal/monitoring/monitor_pve_guest_builders.go +++ b/internal/monitoring/monitor_pve_guest_builders.go @@ -397,9 +397,9 @@ func (m *Monitor) buildVMFromClusterResource( } // fetchVMOnBoot retrieves the onboot (autostart) setting for a stopped VM by -// fetching its config. Returns nil when the config is unavailable or the -// onboot key is absent, so callers can distinguish "explicitly off" from -// "unknown". Uses a type assertion because PVEClientInterface does not include +// fetching its config. Returns nil only when the config is unavailable or the +// value is unrecognised. When onboot is absent from a valid config, returns +// false because Proxmox's default is "do not start on boot". Uses a type assertion because PVEClientInterface does not include // GetVMConfig (it is only on the concrete client, matching the pattern in // guest_config.go). func (m *Monitor) fetchVMOnBoot(ctx context.Context, client PVEClientInterface, node string, vmid int) *bool {