redhat-cop / namespace-configuration-operator

The namespace-configuration-operator helps keeping configurations related to Users, Groups and Namespaces aligned with one of more policies specified as a CRs
Apache License 2.0
204 stars 55 forks source link

resourceVersion should not be set problem (kube 1.11) #41

Closed seb54000 closed 4 years ago

seb54000 commented 4 years ago

Dear all (thanks for your work on this operator) I manage namespaceConfigs with netpol, rolebinding, limitrange and resourcequotas spec. If I manually delete a netpol created by the operator in the target namespace, the operator is then unable to recreate it. In logs I have : {"level":"error","ts":1588750393.6752868,"logger":"util","msg":"unable to create object","object":{"apiVersion":"networking.k8s.io/v1","kind":"NetworkPolicy","metadata":{"creationTimestamp":"2020-05-05T14:09:41Z","generation":1,"labels":{"managed-by":"nsconfig-operator","namespace-config-operator.redhat-cop.io_owner":"ocp-namespace-configuration-operator-crs-seb-sub1"},"name":"allow-from-default-namespace","namespace":"seb-sub1","resourceVersion":"8725156","selfLink":"/apis/networking.k8s.io/v1/namespaces/seb-sub1/networkpolicies/allow-from-default-namespace","uid":"104791d5-8eda-11ea-8490-fa163e2dfe9b"},"spec":{"ingress":[{"from":[{"namespaceSelector":{"matchLabels":{"name":"default"}}}]}],"podSelector":{},"policyTypes":["Ingress"]}},"error":"resourceVersion should not be set on objects to be created","stacktrace":"github.com/go-logr/zapr.(*zapLogger)

I found related issue and PR on this repo : https://github.com/redhat-cop/namespace-configuration-operator/pull/11 and https://github.com/redhat-cop/namespace-configuration-operator/pull/10 but it seems not working for me

I tried with this image/tag : v0.1.0 and latest from quay.io registry (I didn't try to build an image locally) v0.1.0 do not work (I mean print the unable to create object error) latest is not working as I cannot deploy the CRD

I run the operator on OCP 3.11

When I want to deploy this CRD for instance : https://github.com/redhat-cop/namespace-configuration-operator/blob/master/deploy/crds/redhatcop.redhat.io_namespaceconfigs_crd.yaml, I have errors (I cut the logs as they are really long) : `The CustomResourceDefinition "namespaceconfigs.redhatcop.redhat.io" is invalid:

Thanks for your help

raffaelespazzoli commented 4 years ago

@seb54000 we just released a new version v0.2.0, could you try if it fixes your issue?

seb54000 commented 4 years ago

Thanks @raffaelespazzoli for your quick reply. I didn't see the new version, so I've just test it but it doesn't work, here are the details :

#  subresources :
#    status: {} 

The CRDs are well installed :

$ oc get crd | grep redhat
groupconfigs.redhatcop.redhat.io          2020-05-08T14:29:58Z
namespaceconfigs.redhatcop.redhat.io      2020-05-08T14:29:57Z
userconfigs.redhatcop.redhat.io           2020-05-08T13:06:09Z
raffaelespazzoli commented 4 years ago

@seb54000 modifying the CRDs will definitely break the operator. It might be that the new CRDs don't work in 3.11, I haven't tested although I can't imagine why. Maybe you could work with the local red hat team (if there is one) to set up a troubleshooting session.

seb54000 commented 4 years ago

Hi, we'll definitely try to set up this troubleshooting session. After further research, on 3.11, it seems that we need to upgrade in 3.11.200 to make the new CRD work. https://bugzilla.redhat.com/show_bug.cgi?id=1803163

seb54000 commented 4 years ago

Hi @raffaelespazzoli , just to let you know we manage with help of local redHat to reproduce the bug in v0.1.0 on a 3.11.200 cluster. The good news is the "resourceVersion should not be set bug" is effectively corrected in v0.2.0 with a 3.11.200 OCP cluster.

Thanks again for your work and help