Score:0

How to check if there is a broken ownerRef in my Kubernetes cluster?

cn flag

We had an issue with clusterctl move (cluster api).

clusterctl -n org-foo move --to-kubeconfig=.kubeconfigs/.foo-1-kubeconfig
Performing move...
Discovering Cluster API objects
Error: failed to get object graph: failed to check for provisioned infrastructure: action failed after 9 attempts: error reading Cluster /: an empty namespace may not be set when a resource name is provided
make: *** [Makefile:167: create-cluster-from-cluster-yaml] Error 1

The reason was a outdated ownerRef.

Is there a way to check all objects in my cluster and report all broken ownerRefs?

Kranthiveer Dontineni avatar
qa flag
This **[official document](https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/)** explains the relation between owner and dependent objects in kubernetes. It also explains the cases which makes an ownerRef invalid and steps to be taken for finding invalid ownerRefences, go through this for more information.
guettli avatar
cn flag
@KranthiveerDontineni thank you for the link. `kubectl get events -A --field-selector=reason=OwnerRefInvalidNamespace` is only about "invalid namespace". There could be other invalid references, like not existing UUIDs.
Kranthiveer Dontineni avatar
qa flag
[Garbage collectors](https://kubernetes.io/docs/concepts/architecture/garbage-collection) in kubernetes will contain the information about orphaned objects, I think this might help you in finding the invalid owner UUID or deleted owner details. I will try to check if I can find more information on the same.
Kranthiveer Dontineni avatar
qa flag
Hi \`gurttli\` are your queries addressed if you are still having some queries revert back here..
guettli avatar
cn flag
@KranthiveerDontineni thank you for asking. I want to write a Go programm to analyze all resource in my small cluster. At the moment focused on conditions, but ownerRef checking is something which I will look at after that. https://github.com/guettli/check-conditions
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.