namespace-configuration-operator icon indicating copy to clipboard operation
namespace-configuration-operator copied to clipboard

Update Status Error on CR

Open cnuland opened this issue 3 years ago • 0 comments

When using a GroupConfig template with a Namespace resource definition I've noticed it causes the operator to throw an error. I've seen the same error also while deleting resources, like a Group, while the GroupConfig exists. The changes are applied though and all it seems to be causing is an issue with is the status of the CR and causing noise in the logs.

The error in the console of the Namespace Configuration Operator pod

2021-06-23T23:02:38.474-0400    ERROR   enforcing-reconciler    unable to update status for     {"object": {"kind":"GroupConfig","apiVersion":"redhatcop.redhat.io/v1alpha1","metadata":{"name":"team-onboarding","selfLink":"/apis/redhatcop.redhat.io/v1alpha1/groupconfigs/team-onboarding","uid":"bc68810f-18e6-4538-9594-c347f9fc0809","resourceVersion":"95560349","generation":4,"creationTimestamp":"2021-06-24T02:53:59Z","annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"redhatcop.redhat.io/v1alpha1\",\"kind\":\"GroupConfig\",\"metadata\":{\"annotations\":{},\"name\":\"team-onboarding\"},\"spec\":{\"labelSelector\":{\"matchLabels\":{\"type\":\"devteam\"}},\"templates\":[{\"objectTemplate\":\"apiVersion: v1\\nkind: Namespace\\nmetadata:\\n  name: {{ .Name }}-build\\n  annotations:\\n      test2: test2\\n\"},{\"objectTemplate\":\"apiVersion: rbac.authorization.k8s.io/v1\\nkind: RoleBinding\\nmetadata:\\n  name: {{ .Name }}-build\\n  namespace: {{ .Name }}-build\\nroleRef:\\n  apiGroup: rbac.authorization.k8s.io\\n  kind: ClusterRole\\n  name: admin\\n\"}]}}\n"},"finalizers":["groupconfig-controller"],"managedFields":[{"manager":"kubectl-client-side-apply","operation":"Update","apiVersion":"redhatcop.redhat.io/v1alpha1","time":"2021-06-24T02:54:50Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:kubectl.kubernetes.io/last-applied-configuration":{}}},"f:spec":{".":{},"f:labelSelector":{".":{},"f:matchLabels":{".":{},"f:type":{}}}}}},{"manager":"main","operation":"Update","apiVersion":"redhatcop.redhat.io/v1alpha1","time":"2021-06-24T03:02:38Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:finalizers":{".":{},"v:\"groupconfig-controller\"":{}}},"f:spec":{"f:annotationSelector":{},"f:templates":{}},"f:status":{".":{},"f:conditions":{".":{},"k:{\"type\":\"ReconcileSuccess\"}":{".":{},"f:lastTransitionTime":{},"f:message":{},"f:observedGeneration":{},"f:reason":{},"f:status":{},"f:type":{}}},"f:lockedResourceStatuses":{".":{},"f:rbac.authorization.k8s.io/v1/RoleBinding/test-group-build/test-group-build":{},"f:v1/Namespace//test-group-build":{}}}}}]},"spec":{"labelSelector":{"matchLabels":{"type":"devteam"}},"annotationSelector":{},"templates":[{"objectTemplate":"apiVersion: v1\nkind: Namespace\nmetadata:\n  name: {{ .Name }}-build\n  annotations:\n      test2: test2\n","excludedPaths":[".metadata",".status",".spec.replicas"]},{"objectTemplate":"apiVersion: rbac.authorization.k8s.io/v1\nkind: RoleBinding\nmetadata:\n  name: {{ .Name }}-build\n  namespace: {{ .Name }}-build\nroleRef:\n  apiGroup: rbac.authorization.k8s.io\n  kind: ClusterRole\n  name: admin\n","excludedPaths":[".metadata",".status",".spec.replicas"]}]},"status":{"conditions":[{"type":"ReconcileSuccess","status":"True","observedGeneration":4,"lastTransitionTime":"2021-06-24T03:02:38Z","reason":"LastReconcileCycleSucceded","message":""}],"lockedResourceStatuses":{"rbac.authorization.k8s.io/v1/RoleBinding/test-group-build/test-group-build":[{"type":"Initializing","status":"True","lastTransitionTime":"2021-06-24T03:02:38Z","reason":"ReconcilerManagerRestarting","message":""},{"type":"ReconcileSuccess","status":"True","lastTransitionTime":"2021-06-24T03:02:38Z","reason":"LastReconcileCycleSucceded","message":""}],"v1/Namespace//test-group-build":[{"type":"Initializing","status":"True","lastTransitionTime":"2021-06-24T03:02:38Z","reason":"ReconcilerManagerRestarting","message":""},{"type":"ReconcileSuccess","status":"True","lastTransitionTime":"2021-06-24T03:02:38Z","reason":"LastReconcileCycleSucceded","message":""}]}}}, "error": "Operation cannot be fulfilled on groupconfigs.redhatcop.redhat.io \"team-onboarding\": the object has been modified; please apply your changes to the latest version and try again"}
github.com/go-logr/zapr.(*zapLogger).Error
        /home/cnuland/go/pkg/mod/github.com/go-logr/[email protected]/zapr.go:132
github.com/redhat-cop/operator-utils/pkg/util/lockedresourcecontroller.(*EnforcingReconciler).ManageSuccess
        /home/cnuland/go/pkg/mod/github.com/redhat-cop/[email protected]/pkg/util/lockedresourcecontroller/enforcing-reconciler.go:196
github.com/redhat-cop/namespace-configuration-operator/controllers.(*GroupConfigReconciler).Reconcile
        /home/cnuland/okd4/namespace-configuration-operator/controllers/groupconfig_controller.go:127
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
        /home/cnuland/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:263
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
        /home/cnuland/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:235
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1.1
        /home/cnuland/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:198
k8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext.func1
        /home/cnuland/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:185
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1
        /home/cnuland/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:155
k8s.io/apimachinery/pkg/util/wait.BackoffUntil
        /home/cnuland/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:156
k8s.io/apimachinery/pkg/util/wait.JitterUntil
        /home/cnuland/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:133
k8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext
        /home/cnuland/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:185
k8s.io/apimachinery/pkg/util/wait.UntilWithContext
        /home/cnuland/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:99
2021-06-23T23:02:38.474-0400    ERROR   controller-runtime.manager.controller.groupconfig       Reconciler error        {"reconciler group": "redhatcop.redhat.io", "reconciler kind": "GroupConfig", "name": "team-onboarding", "namespace": "", "error": "Operation cannot be fulfilled on groupconfigs.redhatcop.redhat.io \"team-onboarding\": the object has been modified; please apply your changes to the latest version and try again"}
github.com/go-logr/zapr.(*zapLogger).Error

My tests group-config.yaml

apiVersion: redhatcop.redhat.io/v1alpha1
kind: GroupConfig
metadata:
  name: team-onboarding
spec:
  labelSelector:
    matchLabels:
      type: devteam
  templates:
    - objectTemplate: |
        apiVersion: v1
        kind: Namespace
        metadata:
          name: {{ .Name }}-build
          annotations:
              test2: test2
    - objectTemplate: |
        apiVersion: rbac.authorization.k8s.io/v1
        kind: RoleBinding
        metadata:
          name: {{ .Name }}-build
          namespace: {{ .Name }}-build
        roleRef:
          apiGroup: rbac.authorization.k8s.io
          kind: ClusterRole
          name: admin

group.yaml

kind: Group
apiVersion: user.openshift.io/v1
metadata:
  name: test-group
  labels:
    type: devteam
users:
  - user1
  - user3

cnuland avatar Jun 24 '21 03:06 cnuland