Skip to content

Commit 5baa002

Browse files
Orzeliussmira
authored andcommitted
fix: add owning inventory annotation to talos manifests
although the manifests were deployed via ssa the inventory annotation was never added previously Signed-off-by: Orzelius <33936483+Orzelius@users.noreply.github.com> Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent d3e793d commit 5baa002

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

internal/app/machined/pkg/controllers/k8s/manifest_apply.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,21 @@ func (ctrl *ManifestApplyController) apply(
311311
return fmt.Errorf("error checking resource existence: %w", err)
312312
}
313313

314+
// Set inventory annotation.
315+
annotations := obj.GetAnnotations()
316+
if annotations == nil {
317+
annotations = make(map[string]string)
318+
}
319+
320+
inventoryAnnotation, inventoryAnnotationSet := annotations["config.k8s.io/owning-inventory"]
321+
322+
if inventoryAnnotationSet && inventoryAnnotation != constants.KubernetesBootstrapManifestsInventoryName {
323+
return fmt.Errorf("unexpected foreign inventory annotation on %s ", objName)
324+
}
325+
326+
annotations["config.k8s.io/owning-inventory"] = constants.KubernetesBootstrapManifestsInventoryName
327+
obj.SetAnnotations(annotations)
328+
314329
_, err = dr.Apply(ctx, obj.GetName(), obj, metav1.ApplyOptions{
315330
FieldManager: constants.KubernetesFieldManagerName,
316331
})

0 commit comments

Comments
 (0)