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

OwnerReferences cannot be set to a custom resource #22958

Closed
travisn opened this issue May 29, 2019 · 7 comments
Closed

OwnerReferences cannot be set to a custom resource #22958

travisn opened this issue May 29, 2019 · 7 comments

Comments

@travisn
Copy link

travisn commented May 29, 2019

Description of the issue

OwnerReferences cannot be set to a CR as seen as recently in rook/rook#2944. The fix referenced in #18784 merged several versions ago, but it still is not working. What else is necessary in order for an operator to set the ownerReferences to a CR? Is there an example of this working somewhere?

This error is returned when Rook attempts to set the ownerReferences to the CR:

configmaps "rook-test-ownerref" is forbidden: cannot set blockOwnerDeletion in this case because cannot find RESTMapping for APIVersion v1 Kind CephCluster: no matches for kind "CephCluster" in version "v1"

Setting these ownerReferences works fine on upstream K8s. This only affects OpenShift.

Version

[provide output of the openshift version or oc version command]

oc version
==================
Client Version: version.Info{Major:"4", Minor:"1+", GitVersion:"v4.1.0-201905091432+4910781-dirty", GitCommit:"4910781", GitTreeState:"dirty", BuildDate:"2019-05-09T19:19:42Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"13+", GitVersion:"v1.13.4+8cd4e29", GitCommit:"8cd4e29", GitTreeState:"clean", BuildDate:"2019-05-09T19:20:33Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}
Steps To Reproduce
  1. Create a Rook cluster
  2. Rook is not able to set the ownerReference to a CR
Current Result

Look at the Rook operator log:

2019-04-08 11:31:44.687572 W | op-k8sutil: OwnerReferences will not be set on resources created by rook. failed to test that it can be set. 
configmaps "rook-test-ownerref" is forbidden: cannot set blockOwnerDeletion in this case because cannot find RESTMapping for APIVersion v1 Kind CephCluster: no matches for kind "CephCluster" in version "v1"

CephCluster is a CRD defined for Rook, and the operator needs to set the owner reference to this CR.

Expected Result

The operator should succeed setting the ownerReference to a CR.

Additional Information

[try to run $ oc adm diagnostics (or oadm diagnostics) command if possible]
[if you are reporting issue related to builds, provide build logs with BUILD_LOGLEVEL=5]
[consider attaching output of the $ oc get all -o json -n <namespace> command to the issue]
[visit https://docs.openshift.org/latest/welcome/index.html]

@obnoxxx
Copy link
Member

obnoxxx commented Jun 13, 2019

@childsb can you help us get some attention to this by the right people? :-)

@jsafrane
Copy link
Contributor

Objects can be owned by a CR, whole OpenShift depends on that. For example, on a random 4.2-ish cluster:

$ oc -n openshift-sdn get daemonset -o yaml | less
- apiVersion: extensions/v1beta1
  kind: DaemonSet
  metadata:
    [snip]
    ownerReferences:
    - apiVersion: operator.openshift.io/v1
      blockOwnerDeletion: true
      controller: true
      kind: Network
      name: cluster
      uid: 1d3c3203-91ac-11e9-bc17-02ab9d783ff6

So DaemonSet is owned by operator.openshift.io/v1 Network CR.

There is no magic involved, it should work out of the box.

no matches for kind "CephCluster" in version "v1"

Hmm, do you use correct apiVersion, something like rook.io/v1? (I am not sure how your API endpoint looks like, but it definitely should not be naked "v1", that's Kubernetes core API.)

@travisn
Copy link
Author

travisn commented Jun 24, 2019

Aha, thanks for the pointer! We are missing the full apiVersion as you mentioned rook.io/v1 instead of just v1.

@travisn travisn closed this as completed Jun 24, 2019
@nehaberry
Copy link

@travisn so what is the fix for this issue? Do we need to change the apiVersion in cluster.yaml ?

Current content

apiVersion: ceph.rook.io/v1
kind: CephCluster
metadata:
name: rook-ceph
namespace: rook-ceph

@travisn
Copy link
Author

travisn commented Jul 2, 2019

@nehaberry A fix was needed for the rook operator to generate the correct apiVersion. If you see apiVersion: ceph.rook.io/v1 in the ownerreferences for a resource, you've already picked up the fix. See rook/rook#3350 for more context.

@nehaberry
Copy link

@travisn thanks. It worked .

But strangely, the last edit in cluster.yaml in rook repo is 2 months old, so the apiVersion must already have been " ceph.rook.io/v1". Thus, why did we face this issue while testing in the 2019-05-24 .

Thanks.

@sjpotter
Copy link

for the record, we have the same issue on openshift 4.1, but not on 4.2

on 4.1 we see from our operator

{"level":"info","ts":1581301783.7108648,"logger":"controller_redisenterprisecluster","msg":"Failed to create service account: serviceaccounts "test" is forbidden: cannot set blockOwnerDeletion in this case because cannot find RESTMapping for APIVersion app.redislabs.com/v1alpha1 Kind RedisEnterpriseCluster: no matches for kind "RedisEnterpriseCluster" in version "app.redislabs.com/v1alpha1""}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants