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

Outdated static pkg/utils/kube/scheme/parser.go causing field not declared in schema errors in ArgoCD #558

Closed
r0bobo opened this issue Dec 4, 2023 · 12 comments

Comments

@r0bobo
Copy link

r0bobo commented Dec 4, 2023

I've had two cases of sync errors in ArgoCD:

For CSIDriver:

Failed to compare desired state to live state: failed to perform pre-diff normalization: error building typed results: error creating typedLive: .spec.seLinuxMount: field not declared in schema

For Pod with native sidecar containers and the field .spec.initContainers.restartPolicy:

Failed to compare desired state to live state: failed to perform pre-diff normalization: error building typed results: error creating typedConfig: errors: .spec.template.spec.initContainers[name="helper"].restart: field not declared in schema .spec.template.spec.initContainers[name="podman"].restart: field not declared in schema

After digging around in the code I think the problem might be that the static inlined schema here is outdated and is missing those fields.

Here is a related ArgoCD issue for the CSIDriver problem.

Kubernetes version: v1.28.4 with the SidecarContainers feature gate enabled
ArgoCD version: v2.9.3

@r0bobo r0bobo changed the title Outdated static pkg/utils/kube/scheme/parser.go causing field not declared in schema errors Outdated static pkg/utils/kube/scheme/parser.go causing field not declared in schema errors in ArgoCD Dec 4, 2023
@adberger
Copy link

adberger commented Jan 8, 2024

Any updates on this?

seLinuxMount is in the spec since kubernetes v1.25!

see:

@wpi86
Copy link

wpi86 commented Feb 19, 2024

Hi, have similar issue, but with Jobs
"error building typed results: error creating typedLive: errors: .spec.podReplacementPolicy: field not declared in schema."
JobPodReplacementPolicy featuregate now in beta and enabled by default.
eks 1.29 + argo v2.10.0+2175939

@Typositoire
Copy link

I'm also currently hitting this with Kyverno latest chart and multiple fields, the only way to make the chart compute without having Failed to compare desired state to live state: failed to calculate diff: error calculating structured merge diff: error building typed value from live resource: XYZ: field not declared in schema is to ignore them like so.

ignoreDifferences:
  - group: kyverno.io
    kind: ClusterPolicy
    jqPathExpressions:
      - .status.validatingadmissionpolicy
      - .status.autogen
      - '.spec.rules[].skipBackgroundRequests'
      - .spec.admission

@kamelj
Copy link

kamelj commented May 8, 2024

Hello @wpi86
I have the same issue here, What did you do regarding your error "errors: .spec.podReplacementPolicy: field not declared in schema"?

Hi, have similar issue, but with Jobs "error building typed results: error creating typedLive: errors: .spec.podReplacementPolicy: field not declared in schema." JobPodReplacementPolicy featuregate now in beta and enabled by default. eks 1.29 + argo v2.10.0+2175939

@wpi86
Copy link

wpi86 commented May 9, 2024

Hello @wpi86 I have the same issue here, What did you do regarding your error "errors: .spec.podReplacementPolicy: field not declared in schema"?

Hi, have similar issue, but with Jobs "error building typed results: error creating typedLive: errors: .spec.podReplacementPolicy: field not declared in schema." JobPodReplacementPolicy featuregate now in beta and enabled by default. eks 1.29 + argo v2.10.0+2175939

Hi, currently we keep our jobs as argo hooks, in this case argo doesn't try to validate them on sync and it works

@martijnvdp
Copy link

martijnvdp commented Jun 3, 2024

think i got a similar issue with the latest gatekeeper release i got this error even the field is in the scheme k8s 1.28+

helm:

kind: ValidatingWebhookConfiguration
  {{- if ge (int .Capabilities.KubeVersion.Minor) 28 }}
  matchConditions: {{ toYaml .Values.validatingWebhookMatchConditions | nindent 4 }}
  {{- end }}

Failed to compare desired state to live state: failed to perform pre-diff normalization: error building typed results: error creating typedConfig: .webhooks[name="validation.gatekeeper.sh"].matchConditions: field not declared in schema

eks 1.28 argo v2.10.1+a79e0ea

update
could fix it by removing

    resource.customizations.ignoreDifferences.all: |
        managedFieldsManagers:
        - kube-controller-manager

from my argocd configmap

@ptr1120
Copy link

ptr1120 commented Jun 20, 2024

I also have a problem with a simple job that breaks the complete deployment.

Sync operation to 3a93a6cc5f459e30b53659ffcd0b8fc9e5df2acb failed: ComparisonError: Failed to compare desired state to live state: failed to perform pre-diff normalization: error building typed results: error creating typedLive: errors:
  .spec.podReplacementPolicy: field not declared in schema
  .status.terminating: field not declared in schema

I tried to fix it with

  ignoreDifferences:
    - kind: Job
      jqPathExpressions:
        - .spec.podReplacementPolicy
        - .status.terminating

without success.

Any idea?

@wpi86
Copy link

wpi86 commented Jun 21, 2024

I also have a problem with a simple job that breaks the complete deployment.

Sync operation to 3a93a6cc5f459e30b53659ffcd0b8fc9e5df2acb failed: ComparisonError: Failed to compare desired state to live state: failed to perform pre-diff normalization: error building typed results: error creating typedLive: errors:
  .spec.podReplacementPolicy: field not declared in schema
  .status.terminating: field not declared in schema

I tried to fix it with

  ignoreDifferences:
    - kind: Job
      jqPathExpressions:
        - .spec.podReplacementPolicy
        - .status.terminating

without success.

Any idea?

Argo has released a new version that knows this field, the update solved our problem

@ptr1120
Copy link

ptr1120 commented Jun 21, 2024

@wpi86 thank you, but updating argocd to v2.12.0-rc1 for me does not solve the problem with the job, maybe it's additionally due to using server-side-apply (argoproj/argo-cd#17358)

Failed to compare desired state to live state: failed to calculate diff: error calculating structured merge diff: error building typed value from live resource: .spec.podReplacementPolicy: field not declared in schema

@ptr1120
Copy link

ptr1120 commented Jun 21, 2024

The only difference I notice is ignoring field managers in argocd-cm produces 2 errors (spec.podReplacementPolicy, status.terminating):

Failed to compare desired state to live state: failed to perform pre-diff normalization: error building typed results: error creating typedLive: errors: .status.terminating: field not declared in schema .spec.podReplacementPolicy: field not declared in schema

Removing the filed managers ignore rules from argocd-cd produces 1 error (podReplacementPolicy):

Failed to compare desired state to live state: failed to calculate diff: error calculating structured merge diff: error building typed value from live resource: .spec.podReplacementPolicy: field not declared in schema

@stongo
Copy link

stongo commented Jun 26, 2024

I'm having the same problem with other fields.
Another workaround is to disable validation completely in the sync policy.

syncOptions:
- Validate=false

@crenshaw-dev
Copy link
Member

I've updated the static schema to 0.29. Please try Argo CD 2.12.0-rc3. #588

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

No branches or pull requests

9 participants