Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-Side Diff with RespectIgnoreDifferences can fail diff due to missing required fields #17362

Open
llavaud opened this issue Feb 29, 2024 · 1 comment
Labels

Comments

@llavaud
Copy link

llavaud commented Feb 29, 2024

Describe the bug

An application that set an ignoreDifferences on a required field of a manifest spec will fail to diff if both RespectIgnoreDifferences and ServerSideDiff are enabled

To Reproduce

Create an application with the following spec:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    argocd.argoproj.io/compare-options: ServerSideDiff=true
...
spec:
  ignoreDifferences:
    - group: apps
      kind: Deployment
      name: foo
      jqPathExpressions:
        - '.spec.template.spec.containers[] | select(.name == "foo").image'
  syncPolicy:
    syncOptions:
    - CreateNamespace=true
    - ApplyOutOfSyncOnly=true
    - RespectIgnoreDifferences=true
    - ServerSideApply=true
    - Validate=false
...

Expected behavior

Diff app without errors

Version

argocd: v2.10.1+a79e0ea
  BuildDate: 2024-02-14T17:37:43Z
  GitCommit: a79e0eaca415461dc36615470cecc25d6d38cefb
  GitTreeState: clean
  GoVersion: go1.21.3
  Compiler: gc
  Platform: linux/amd64

Logs

Failed to compare desired state to live state: failed to calculate diff: error calculating server side diff: serverSideDiff error: error running server side apply in dryrun mode for resource Deployment/foo: Deployment.apps "foo" is invalid: spec.template.spec.containers[0].image: Required value
@llavaud llavaud added the bug Something isn't working label Feb 29, 2024
@llavaud
Copy link
Author

llavaud commented Mar 1, 2024

After some tests, I noticed that if I take the ownership on the spec.template.spec.containers.image field using the following command, Argo CD succeed to do the diff.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: foo
spec:
  template:
    spec:
      containers:
      - name: foo
        image: <my_image>
kubectl -f deployment.yaml --server-side --field-manager='myself'

I guess, if the image field is managed by another controller, it is added when doing the server-side diff otherwise if no one manage this field and as the respectIgnoreDifferences is active, the image field is not added and cause the invalid manifest error, so not sure it is a bug, seems more like the normal behavior of the server-side feature, don't know if Argo can manage this situation in some way...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants