zapier / kubechecks

Check your Kubernetes changes before they hit the cluster
https://kubechecks.readthedocs.io/en/latest/
Mozilla Public License 2.0
147 stars 9 forks source link

Unable to set location for remote repository #169

Closed pauloconnor closed 5 months ago

pauloconnor commented 5 months ago

It is assumed that every repository will follow the file structure that's defined here. However, if I want to use something like https://github.com/datreeio/CRDs-catalog/ which uses a different layout {{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json, I'm unable to define both the repository and the file structure.

djeebus commented 5 months ago

I think the most recent release should resolve this. Can you upgrade to 1.5.1, set KUBECHECKS_SCHEMAS_LOCATION=https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json and see if that works?

pauloconnor commented 5 months ago
6:42PM ??? ⇨ http server started on [::]:8080
6:42PM INF appwatcher: onApplicationAdded key=argocd/argo
6:42PM DBG add app appName=argo cluster-name= cluster-server=https://kubernetes.default.svc
E0322 18:42:19.733887       1 runtime.go:79] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference)
goroutine 118 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic({0x3057900?, 0x5d41ca0})
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/runtime/runtime.go:75 +0x85
k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0xc000fef200?})
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/runtime/runtime.go:49 +0x6b
panic({0x3057900?, 0x5d41ca0?})
    /usr/local/go/src/runtime/panic.go:914 +0x21f
github.com/zapier/kubechecks/pkg/app_watcher.canProcessApp({0x35f2180?, 0xc001b803c0})
    /src/pkg/app_watcher/app_watcher.go:155 +0xe8
github.com/zapier/kubechecks/pkg/app_watcher.(*ApplicationWatcher).onApplicationAdded(0xc0007ffae0, {0x35f2180, 0xc001b803c0})
    /src/pkg/app_watcher/app_watcher.go:74 +0x2c
k8s.io/client-go/tools/cache.ResourceEventHandlerFuncs.OnAdd(...)
    /go/pkg/mod/k8s.io/client-go@v0.26.12/tools/cache/controller.go:232
k8s.io/client-go/tools/cache.(*processorListener).run.func1()
    /go/pkg/mod/k8s.io/client-go@v0.26.12/tools/cache/shared_informer.go:909 +0x125
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0x30?)
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:157 +0x33
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc000504f38?, {0x3eccd00, 0xc000fdc000}, 0x1, 0xc000fd6000)
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:158 +0xaf
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0x0?, 0x3b9aca00, 0x0, 0x40?, 0xc000504f88?)
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:135 +0x7f
k8s.io/apimachinery/pkg/util/wait.Until(...)
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:92
k8s.io/client-go/tools/cache.(*processorListener).run(0xc0001ce100)
    /go/pkg/mod/k8s.io/client-go@v0.26.12/tools/cache/shared_informer.go:903 +0x69
k8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1()
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:75 +0x4f
created by k8s.io/apimachinery/pkg/util/wait.(*Group).Start in goroutine 149
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:73 +0x73
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1dff328]

goroutine 118 [running]:
k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0xc000fef200?})
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/runtime/runtime.go:56 +0xcd
panic({0x3057900?, 0x5d41ca0?})
    /usr/local/go/src/runtime/panic.go:914 +0x21f
github.com/zapier/kubechecks/pkg/app_watcher.canProcessApp({0x35f2180?, 0xc001b803c0})
    /src/pkg/app_watcher/app_watcher.go:155 +0xe8
github.com/zapier/kubechecks/pkg/app_watcher.(*ApplicationWatcher).onApplicationAdded(0xc0007ffae0, {0x35f2180, 0xc001b803c0})
    /src/pkg/app_watcher/app_watcher.go:74 +0x2c
k8s.io/client-go/tools/cache.ResourceEventHandlerFuncs.OnAdd(...)
    /go/pkg/mod/k8s.io/client-go@v0.26.12/tools/cache/controller.go:232
k8s.io/client-go/tools/cache.(*processorListener).run.func1()
    /go/pkg/mod/k8s.io/client-go@v0.26.12/tools/cache/shared_informer.go:909 +0x125
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0x30?)
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:157 +0x33
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc000504f38?, {0x3eccd00, 0xc000fdc000}, 0x1, 0xc000fd6000)
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:158 +0xaf
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0x0?, 0x3b9aca00, 0x0, 0x40?, 0xc000504f88?)
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:135 +0x7f
k8s.io/apimachinery/pkg/util/wait.Until(...)
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:92
k8s.io/client-go/tools/cache.(*processorListener).run(0xc0001ce100)
    /go/pkg/mod/k8s.io/client-go@v0.26.12/tools/cache/shared_informer.go:903 +0x69
k8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1()
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:75 +0x4f
created by k8s.io/apimachinery/pkg/util/wait.(*Group).Start in goroutine 149
    /go/pkg/mod/k8s.io/apimachinery@v0.26.12/pkg/util/wait/wait.go:73 +0x73

It's really not happy now. Also, could you bump the AppVersion in the Helm chart too? There's no other way to override the image tag currently

djeebus commented 5 months ago

lol, oh my. I'm guessing you have an app that doesn't have a Source? Let me get that sorted out.

djeebus commented 5 months ago

And if you set deployment.image.tag in the helm chart, it should let you upgrade the image

pauloconnor commented 5 months ago

lol, oh my. I'm guessing you have an app that doesn't have a Source? Let me get that sorted out.

Lot of multi source appsets

I really need to read those charts better 😂

djeebus commented 5 months ago

haha, all good. helm charts are many things; "easily readable" is not one of them.

djeebus commented 5 months ago

if you want to check out a pre-release version, ghcr.io/zapier/kubechecks:0.0.0-pr170 should fix the nil panic (built off of #170)

pauloconnor commented 5 months ago

Managed to get that PR 170 build deployed, and we're still seeing a cloning issue:

2:53PM ERR unable to clone repository, Cloning into '/tmp/schemas442860011'...
remote: 404: Not Found
fatal: repository 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json/' not found
 error="exit status 128"
2:53PM ERR failed to clone repository error="exit status 128" clone-url=https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json

My env secret contains:

KUBECHECKS_SCHEMAS_LOCATION: |
          https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{`{{.Group}}`}}/{{`{{.ResourceKind}}`}}_{{`{{.ResourceAPIVersion}}`}}.json
djeebus commented 5 months ago

Ok, this is very strange. I've now got a test that would indicate that the string you provided should not attempt to be cloned. Can you swap to and verify that you're running the latest released version? You should see something like the following when launching:

8:44PM INF Starting KubeChecks git-commit=8857b09 git-tag=v1.5.2
pauloconnor commented 5 months ago

So, I set deployment.image.tag to v1.5.2, and it pulled down the correct image. Now though, I'm getting

http.go:89: could not find schema at https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.27.0-standalone-strict/applicationset-argoproj-v1alpha1.json
http.go:80: failed downloading schema at https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/applicationset_v1alpha1.json
/v1.27.0-standalone-strict/applicationset-argoproj-v1alpha1.json: parse "https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/applicationset_v1alpha1.json\n/v1.27.0-standalone-strict/applicationset-argoproj-v1alpha1.json": net/url: invalid control character in URL

It seems to be appending the default location to the location that I've set

djeebus commented 5 months ago

There's a weird newline in the middle of your url, any idea where that came from? More importantly, any chance you can get rid of it?

pauloconnor commented 5 months ago

I really hate yaml... Found where that newline was coming from, and it parses the URL properly now