Argo-cd: Failed to unmarshal manifest if it doesn't have Kubernetes api definition (api, kind, metadata)

Created on 28 Oct 2020  路  3Comments  路  Source: argoproj/argo-cd

Checklist:

  • [x] I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • [x] I've included steps to reproduce the bug.
  • [x] I've pasted the output of argocd version.

Describe the bug

I have argo application with two files in directory. One of them is a valid kubernetes manifest (eg. ingress), another one is helm values.yaml file (which is not the kubernetes manifest). The problem appears when argo tries to sync the application. It goes to Unknown state while doing the comparison, because my non-valid yaml file doesn't have the api definition inside of it.

The possible solution would be that we will just skip files with no definition inside and would not do a diff on them.

To Reproduce

Create the application which is pointed to a folder with yaml file (which is not the kubernetes manifest).

Expected behavior

Non-kubernetes yaml files are ignored and only valid manifests are compared to in-cluster objects.

Screenshots

Screenshot

Version
Appears on 1.7.0 and higher (with the new diff functionality).

My version is 1.7.6

Logs

time="2020-10-28T15:16:41Z" level=warning msg="finished unary call with code FailedPrecondition" error="rpc error: code = FailedPrecondition desc = Failed to unmarshal \"test.yaml\": failed to unmarshal manifest: error unmarshaling JSON: while decoding JSON: Object 'Kind' is missing in '{\"chart\":\"nginx-ingress\",\"name\":\"external-ingress\",\"namespace\":\"infra-ingress\",\"repository\":\"https://kubernetes-charts.storage.googleapis.com\",\"values\":[\"values.yaml\"],\"version\":\"1.37.0\"}'" grpc.code=FailedPrecondition grpc.method=GenerateManifest grpc.request.deadline="2020-10-28T15:17:39Z" grpc.service=repository.RepoServerService grpc.start_time="2020-10-28T15:16:39Z" grpc.time_ms=1255.701 span.kind=server system=grpc
bug

Most helpful comment

We discussed this and we agree that if we encounter a object that "looks like" a K8s object, and by "look like" it has fields: kind, 'apiVersion, 'metadata, and that object fails to unmarshal, then we will error. Otherwise we will ignore the file.

All 3 comments

This behavior is expected. We don't yet have an exclusion feature to ignore non-kubernetes manifests. #4432 will address the ability to exclude/ignore other yaml files.

Duplicate of #4432

@jessesuen If I understand it correctly then #4432 is mainly about dot files. The goal of this one would be to have an option to ignore yaml files which are not Kubernetes manifests.

A simple way would be to check for apiVersion and kind fields and only treat yaml files, which contain both as Kubernetes manifests.

It's kind of blocking us from upgrading to newer Argo CD version as we have quite some applications, which work with older Argo CD versions as they ignore those yaml files.

Adding the exclusion field as proposed in #4432 would still require to find all yaml files, which are not Kubernetes manifests and to ignore them, while a flag which allows to ignore non kubernetes yaml files would be a single line change.

We discussed this and we agree that if we encounter a object that "looks like" a K8s object, and by "look like" it has fields: kind, 'apiVersion, 'metadata, and that object fails to unmarshal, then we will error. Otherwise we will ignore the file.

Was this page helpful?
0 / 5 - 0 ratings