Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kuberhealthy OwnerRefInvalidNamespace Bug #903

Closed
joshulyne opened this issue Apr 27, 2021 · 5 comments · Fixed by #973
Closed

Kuberhealthy OwnerRefInvalidNamespace Bug #903

joshulyne opened this issue Apr 27, 2021 · 5 comments · Fixed by #973
Assignees
Labels
bug Something isn't working
Milestone

Comments

@joshulyne
Copy link
Collaborator

joshulyne commented Apr 27, 2021

We set ownerRef for all our khcheck pods to the kuberhealthy pod (since the kuberhealthy pod provisions/manages all these khcheck pods). However, for khchecks outside the kuberhealthy namespace (or whichever namespace kuberhealthy is running), we run into this OwnerRefInvalidNamespace error for kubernetes 1.20+ and the khcheck pods get automatically deleted:

per k8s 1.20 release notes:

Resolves non-deterministic behavior of the garbage collection controller when ownerReferences with incorrect data are encountered. Events with a reason of OwnerRefInvalidNamespace are recorded when namespace mismatches between child and owner objects are detected. The kubectl-check-ownerreferences tool can be run prior to upgrading to locate existing objects with invalid ownerReferences.

  • A namespaced object with an ownerReference referencing a uid of a namespaced kind which does not exist in the same namespace is now consistently treated as though that owner does not exist, and the child object is deleted.
  • A cluster-scoped object with an ownerReference referencing a uid of a namespaced kind is now consistently treated as though that owner is not resolvable, and the child object is ignored by the garbage collector. (#92743, @liggitt) [SIG API Machinery, Apps and Testing]
@joshulyne joshulyne added the bug Something isn't working label Apr 27, 2021
@integrii integrii added this to the v2.6.0 milestone Jun 2, 2021
@integrii
Copy link
Collaborator

integrii commented Jun 2, 2021

It would be worth taking a look at the Kubernetes roadmap to see if cross-namespace checks are coming back in the future. For now, we probably have to drop owner references?

Cross-namespace owner references are disallowed by design.

@integrii integrii modified the milestones: v2.6.0, v2.7.0 Jun 23, 2021
@AshutoshNirkhe
Copy link
Contributor

AshutoshNirkhe commented Jun 30, 2021

Hi @joshulyne @integrii I am testing out k8s 1.20 upgrade in sandbox cluster and encountered exactly this. Was about to file a bug and saw this one :)
I tried setting 'KH_POD_NAMESPACE' in external check def to point to Kuberhealty namespace but that didn't really help as it simply overwrites it with the namespace set in metadata of checker pod.
Do you think there is any easy way out for this as of now other than running all checks in same namespace as that of Kuberhealthy ?
I see this marked for 2.6/2.7. If we don't support this early, issue is that we won't be able to allow our users to maintain/run their checks in their own namespaces. Thanks in advance!

@integrii
Copy link
Collaborator

It seems like we might need to quickly make a new build that drops owner references when the pod is being built in a different namespace. Unfortunately, it seems like owner references are not going to be supported by Kubernetes. I have raised this an existing issue in the kubernetes project (see reference above).

@integrii
Copy link
Collaborator

@deads2k wrote the documentation on this one in the Kubernetes project and mentioned that in any future implementation, it needs to be "double opt-in" by both namespace owners somehow.

@integrii
Copy link
Collaborator

Looks like we need to check if the checker pod is going into the same namespace as the kuberhealthy pod spawning it before adding the owner reference to it here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants