devfile / devworkspace-operator

Apache License 2.0
67 stars 55 forks source link

Endless reconcile loop when using inline configmap in a devworkspace #1275

Closed AObuchow closed 4 months ago

AObuchow commented 5 months ago

Description

If a devworkspace includes an inlined configmap component that is mounted via pod & container overrides, the devworkspace-controller-manager will enter an endless reconcile loop. From my current investigation, it seems that the basicDiffFunc() is returning false when comparing the workspace's deployment on the cluster compared to the expected deployment spec. It seems we might have a subtle bug in the deploymentDiffOpts we're using that's failing for this case.

How To Reproduce

  1. Apply the following devworkspace:
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
  name: plain-devworkspace-inline-cm
spec:
  started: true
  routingClass: 'basic'
  template:
    components:
      - name: cm-config-volume
        openshift:
          deployByDefault: true
          inlined: |
            apiVersion: v1
            kind: ConfigMap
            metadata:
              name: my-configmap
            data:
              demo-txt: |
                key1=value1
                key2=value2
      - name: web-terminal
        attributes:
          pod-overrides:
            spec:
              volumes:
              - name: demo-config-map
                configMap:
                  name: my-configmap
                  items:
                  - key: demo-txt
                    path: demo.txt
          container-overrides:
            volumeMounts:
            - mountPath: /projects/config-map
              name: demo-config-map
        container:
          image: quay.io/wto/web-terminal-tooling:next
          memoryRequest: 256Mi
          memoryLimit: 512Mi
          mountSources: true
          command:
           - "tail"
           - "-f"
           - "/dev/null"
  1. Notice that the workspace never progresses past the Starting: Waiting for workspace deployment phase, and the controller enters an endless reconcile loop until the workspace times out.

Expected behavior

The workspace should progress to the READY phase and the controller should not enter an endless reconcile loop.

Additional context

Upstream Che issue

AObuchow commented 4 months ago

It turned out that the configmap volume defined in the pod overrides of the devworkspace was missing the defaultMode field, which was then getting set to a default value on the cluster. When DWO was comparing the workspace deployments expected spec to the cluster spec, it saw the difference in the defaultMode field, leading to an endless reconcile loop.

Closing as this was caused by a misconfigured devworkspace object. See https://github.com/eclipse-che/che/issues/23011#issuecomment-2197418862