Problems finding k8s schema file
boskisam opened this issue · 9 comments
Describe the bug
Wanted to give datree a try, installed helm plugin to check on my charts. Yaml validation is OK, Kubernetes schema validation cannot find file. Tried with example repo, no luck.
To Reproduce
Steps to reproduce the behavior:
helm plugin install https://github.com/datreeio/helm-datree
git clone https://github.com/datreeio/examples.git
helm datree test examples/helm-chart/nginx
Expected behavior
K8s schema is validated, starting policy check.
Desktop (please complete the following information):
- OS: Ubuntu 20.04
- kernel: 5.11.0-41-generic
- helm: version.BuildInfo{Version:"v3.7.0", GitCommit:"eeac83883cb4014fe60267ec6373570374ce770b", GitTreeState:"clean", GoVersion:"go1.16.8"} (installed by snap)
Datree plugin version (run helm datree verion
):
- Version: 0.14.49
Additional context
Same happens with passing values
helm datree test helm-charts/app/ -- --values compiled/DEV1/php.yml
@boskisam Thanks for opening the issue.
I couldn't reproduce it, can you check if the generated yaml file is created in your /tmp/ folder and whether it's accessible to the user that runs the command? it might be an issue with permissions to the tmp folder.
another good way to debug if it's permission or a plugin issue will be to run the following command:
helm template helm-chart/nginx | datree test -
if you will see that same error ("empty file") - it's a permission issue.
Hi,
sorry for my negligence.
The file is created, permissions seem correct, but it is empty.
also tried with running helm as sudo. No luck either...
Since you brought up permissions, the problem might be with using the /tmp directory for datree. Some part of the plugin might use the system-wide temp, and helm can only use its' own snap temp folder.
I think i've foud a problem (or at least something that could help resolving the issue).
I've downloaded the datree binary, and ran helm template ./helm-charts/app | datree test -
in my project folder.
It seems to me, that datree is trying to create the /tmp path based on a relative path to current directory.
$ helm template ./helm-charts/app | datree test -
>> File: ../../../../../tmp/datree_temp_3723076163.yaml
If i run the helm plugin command it resolves to absolute path
$ helm template ./helm-charts/app | datree test -
>> File: ../../../../../tmp/datree_temp_3723076163.yaml
I did not review helm plugin code, but assuming it does helm template xxx > $file && datree test $file
- the seems to be helm seeing only its' own /tmp dir, and datree only seeing system /tmp.
edit: fix code styling
@MentalBrake @eyarz I've created a pull request. I don't know if using the temp file is intentional, or is left for debug purposes, so i left it so it works as it has when installation is not snaps.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Pr is in progress. Reopening the issue
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.