Skip to content

Never ending reconciliation on a Deployment due to env expected to be '[]' vs null #289

@Manny2014

Description

@Manny2014

Description

I've created a simple ResourceGraph (below) and not thinking much about i set the spec.template.containers[0].env to equal to '[]' in the definition. The controller never reconciled b/c it kept finding and issue with the value of 'env' (desired '[]' vs. observed null).

apiVersion: kro.run/v1alpha1
kind: ResourceGraphDefinition
metadata:
...
spec:
  schema:
    apiVersion: v1alpha1
    kind: SimpleApp
    spec:
      # Basic types
      name: string | required=true description="Application name"
      replicas: integer | default=1 # minimum=1 maximum=100
      namespace: string | required=true
      image: string | required=true
      port: integer | default=8080
    status:
      # Status fields with auto-inferred types
      deploymentConditions: ${deployment.status.conditions}
      availableReplicas: ${deployment.status.availableReplicas}
      workloadKsa: ${ksa.metadata.name}
  resources:
  - id: ksa
    template:
      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: sv-${schema.spec.name}-ksa
        namespace: ${schema.spec.namespace}
 
  - id: deployment
    readyWhen:
      - ${deployment.spec.replicas == deployment.status.availableReplicas}
    template:
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: ${schema.spec.name}
        namespace: ${schema.spec.namespace}
        labels:
          app.kubernetes.io/name: ${schema.spec.name}
      spec:
        replicas: ${schema.spec.replicas}
        selector:
          matchLabels:
            app.kubernetes.io/name: ${schema.spec.name}
            app: ${schema.spec.name}
        template:
          metadata:
            labels:
              app.kubernetes.io/name: ${schema.spec.name}
              app: ${schema.spec.name}
          spec:
            serviceAccountName: ${ksa.metadata.name}
            containers:
            - name: main
              image: ${schema.spec.image}
              imagePullPolicy: Always
              ports:
              - containerPort: ${schema.spec.port}
              resources:
                requests:
                  memory: "64Mi"
                  cpu: "250m"
                limits:
                  memory: "1Gi"
                  cpu: "1"
              env: []
            restartPolicy: Always

Observed Behavior:
The controller never reconciled and the Instance never made it past IN_PROGRESS although all objects were created successfully.

Watching the object:

NAME                         STATE         SYNCED   AGE
simpleapp.kro.run/simple-1   IN_PROGRESS   False    2m58s

NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/simple-1   1/1     1            1           2m55s
[2]  + done       ~/local/google-cloud-sdk/bin/kubectl.1.30 get simpleapp,deploy -n rg-instance
[2] 30970
NAME                         STATE         SYNCED   AGE
simpleapp.kro.run/simple-1   IN_PROGRESS   False    3m1s

NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/simple-1   1/1     1            1           2m58s

After removing 'env: []' from ResourceGraph the Instance reconciled in seconds:

NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/simple-1 1/1 1 1 3s
[2] + done ~/local/google-cloud-sdk/bin/kubectl.1.30 get simpleapp,deploy -n rg-instance
[2] 34541
NAME STATE SYNCED AGE
simpleapp.kro.run/simple-1 ACTIVE True 9s

NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/simple-1 1/1 1 1 6s

Expected Behavior:
I did not expect that such a small thing would put the controller in this state.

Reproduction Steps (Please include ResourceGraphDefinition and Instances files):

Versions:

  • kro version: 0.2.1
  • Kubernetes Version (kubectl version):
    Client Version: v1.30.8
    Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
    Server Version: v1.30.6+k3s1

Involved Controllers:

  • Controller URLs and Versions (if applicable):

Error Logs (if applicable)**:

2025-02-11T03:36:58.790Z	DEBUG	controller.simpleapps	Found deltas for resource	{"namespace": "rg-instances", "name": "simple-1", "resourceID": "deployment", "delta": [{"path":"spec.template.spec.containers[0].env","desired":[],"observed":null}]}
2025-02-11T03:36:58.815Z	DEBUG	dynamic-controller	Finished syncing resourcegraphdefinition instance request	{"gvr": "kro.run/v1alpha1/simpleapps", "namespacedKey": "rg-instances/simple-1", "duration": "45.484577ms"}
  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Which option describes the most your issue?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions