carvel-dev / kapp

kapp is a simple deployment tool focused on the concept of "Kubernetes application" — a set of resources with the same label
https://carvel.dev/kapp
Apache License 2.0
907 stars 108 forks source link

filename reference in error output #561

Open universam1 opened 2 years ago

universam1 commented 2 years ago

What steps did you take:

Deploying a set of spec files where one of them has an error. No idea which one...

What happened:

There is no reference in the error message to the file or even line to be able to trace back the issue.

kapp: Error: Trying to apply empty set of resources will result in deletion of resources on cluster. Refusing to continue unless --dangerous-allow-empty-list-of-resources is specified.

or:

╰─➤  kapp app-group deploy -g all -n default --directory kappsvc -c
kapp: Error: error unmarshaling JSON: json: cannot unmarshal string into Go value of type map[string]interface {}

What did you expect:

like kubectl reference the filename and the line where this problem occurs

Environment:


Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible" 👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

praveenrewar commented 2 years ago

Hi @universam1! The error

kapp: Error: Trying to apply empty set of resources will result in deletion of resources on cluster. Refusing to continue unless --dangerous-allow-empty-list-of-resources is specified.

generally means that the file is empty or doesn't have a resource present in it. Would you be able to share the file(s) content that you are trying to apply for better understanding of the issue?

universam1 commented 2 years ago

@praveenrewar Thanks, you and Kapp, are right that there is an empty file, errorously generated through our helm templating. However we do not know which file, this information is missing in the error log. So this issue is only about enriching the error output with file name and line reference

cppforlife commented 2 years ago

i think it's saying that it was not given any resources in any of the files.

universam1 commented 2 years ago

i think it's saying that it was not given any resources in any of the files.

Ok, I'll check that, thanks

universam1 commented 2 years ago

Another instance where the filename is missing, leaving one puzzled:

╰─➤  kapp app-group deploy -g all -n default --directory kappsvc -c

--- deploying app 'all-services' (namespace: default) from kappsvc/services

kapp: Error: error unmarshaling JSON: json: cannot unmarshal string into Go value of type map[string]interface {}

Also running in --debug does not give any hint either

praveenrewar commented 2 years ago
kapp: Error: error unmarshaling JSON: json: cannot unmarshal string into Go value of type map[string]interface {}

Yeah, I agree that file source description should be added in this case. Thanks for pointing it out 😄 And feel free to create a PR for the same :)

(BTW, the error would typically mean that there is a doc in one of the files in kappsvc/services which isn't a valid yaml.)

praveenrewar commented 2 years ago

I think we can wrap this error to include the fileSrc.Description and the doc index. We might just have to see how the error looks in different scenarios (for example stdin source).

universam1 commented 2 years ago

@praveenrewar as another instance - would this error also be extended with the affected filename?

Target cluster 'https://xxxx.gr7.us-east-1.eks.amazonaws.com' (nodes: ip-172-16-4-11.ec2.internal, 2+)
error="error converting YAML to JSON: yaml: line 2: mapping values are not allowed in this context"
praveenrewar commented 2 years ago

Seems like it. Although I am wondering about error="error converting..., we usually have errors wrapped with kapp: Error: ... 🤔

universam1 commented 2 years ago

we usually have errors wrapped with kapp: Error: ... 🤔

😊 This is due to us using Kapp as module now https://github.com/vmware-tanzu/carvel-kapp/issues/564#issuecomment-1203639470

renuy commented 2 years ago

Marking this as an enhancement to the existing error message. @universam1 , Would be great if you could help us out by contributing to this issue. We will prioritise the review for this.

universam1 commented 2 years ago

@renuy Happy to contribute, I am currently in vacation please have a couple of weeks patience, thanks

webframp commented 1 year ago

Still interested in this as well, would be a nice improvement