Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/server/api_registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 9 additions & 1 deletion pkg/server/labeltmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down