diff --git a/pkg/server/api_registration_test.go b/pkg/server/api_registration_test.go index 650e6c505..a721d0049 100644 --- a/pkg/server/api_registration_test.go +++ b/pkg/server/api_registration_test.go @@ -379,6 +379,13 @@ func TestMergeInventoryAnnotations(t *testing.T) { false, map[string]string{"key1": "val1", "custom.prefix/key2": "val2"}, }, + { + []byte(`{"os.unmanaged":"true"}`), + nil, + "", + false, + map[string]string{"elemental.cattle.io/os.unmanaged": "true"}, + }, } for _, test := range testCase { diff --git a/pkg/server/labeltmpl.go b/pkg/server/labeltmpl.go index d12fbd60e..25aff0717 100644 --- a/pkg/server/labeltmpl.go +++ b/pkg/server/labeltmpl.go @@ -173,7 +173,15 @@ func mergeInventoryAnnotations(data []byte, mInventory *elementalv1.MachineInven mInventory.Annotations = map[string]string{} } for key, val := range annotations { - mInventory.Annotations[prefix+sanitizeUserInput(key)] = sanitizeUserInput(val) + // os.unmanaged is an operator-internal signal that the reset controller + // uses to decide unmanaged vs toolkit reset plan. It must always be stored + // under the well-known elemental.cattle.io/os.unmanaged key, regardless of + // the configured labelPrefix. + targetKey := prefix + sanitizeUserInput(key) + if key == "os.unmanaged" { + targetKey = elementalv1.MachineInventoryOSUnmanagedAnnotation + } + mInventory.Annotations[targetKey] = sanitizeUserInput(val) } return nil }