Skip to content

AppController: error calculating server side diff with 2.10-rc1 #16840

Closed
argoproj/gitops-engine
#562
@prune998

Description

@prune998

Describe the bug

When enabling the server side diff in the Application, the app stays out-of-sync with an error:

Failed to compare desired state to live state: failed to calculate diff: error calculating server side diff: serverSideDiff error: error converting json string to unstructured: unmarshal error: invalid character 'c' looking for beginning of value

The Application is synced fine when setting the option back to false:

kind: Application
metadata:
  annotations:
    argocd.argoproj.io/compare-options: ServerSideDiff=false,IncludeMutationWebhook=true

To Reproduce

  • install ArgoCD 2.10-rc1
  • create an application enabling ServerSideDiff:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    argocd.argoproj.io/compare-options: ServerSideDiff=true,IncludeMutationWebhook=true
  name: devops-cicd-argocd-infrastructure-addons
  namespace: argocd
spec:
  destination:
    name: central-cluster
    namespace: argocd-infrastructure-addons
  ignoreDifferences:
  - group: apps
    jqPathExpressions:
    - .spec.template.spec.containers[].env[].valueFrom.resourceFieldRef.divisor
    - .spec.template.spec.initContainers[].env[].valueFrom.resourceFieldRef.divisor
    kind: Deployment
  project: infrastructure
  source:
    path: deployments/k8s/overlays/qa/central-cluster
    repoURL: https://gitlab/devops/cicd/argocd-infrastructure-addons.git
    targetRevision: deployment
  syncPolicy:
    automated:
      allowEmpty: true
      prune: true
      selfHeal: true
    syncOptions:
    - CreateNamespace=true
    - ServerSideApply=true

The repo contains a kustomized application that use the Helm Inflator:

---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

helmCharts:
  - name: crossplane
    repo: https://charts.crossplane.io/stable
    releaseName: crossplane
    namespace: crossplane
    # version: 0.1.0 # use latest
    includeCRDs: false #no CRD in the chart, they are created by crossplane Operator
    valuesFile: ../../../base/crossplane/values.yaml
    valuesMerge: override
    valuesInline:
      args: 
        - --debug
      serviceAccount:
        customAnnotations: 
          iam.gke.io/gcp-service-account: [email protected]
    

resources:
  - ../../../base/configmaps #this creates a test configmap
  - ../../../base/crossplane # this creates the namespace and providers

Note:

  • setting IncludeMutationWebhook=false but keeping ServerSideDiff=true shows the same behaviour so it's not linked to the Weebhook.

  • commenting out the helm chart from the kustomization.yaml file resolved the issue. But the helm chart is working fine without the server-side diff option...

    ---
    apiVersion: kustomize.config.k8s.io/v1beta1
    kind: Kustomization
    
    resources:
      - ../../../base/configmaps #this creates a test configmap
      - ../../../base/crossplane # this creates the namespace and providers
    
  • using the minecraft chart shows no problem.
    The Crossplane chart does generates sync errors because of the divisor added by K8s that is not part of the chart, so the ignoreDifferences is added in the App. The server-side sync issue is the same with or without this ignoreDifferences option. In fact, I was expecting that the server-side diff would solve this diff issue even without the ignoreDifferences.

Expected behavior

The App should deploy just fine, which it does with the same Application when setting the option ServerSideDiff=false

Version

v2.10.0-rc1+9ad5cd6.dirty (This is a custom build 2.10-rc1 from release-2.10 branch)

kubectl  version
Client Version: v1.29.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.7-gke.1056000
kustomize version
v5.3.0

Logs

Failed to compare desired state to live state: failed to calculate diff: error calculating server side diff: serverSideDiff error: error converting json string to unstructured: unmarshal error: invalid character 'c' looking for beginning of value

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions