Closed xescab closed 1 year ago
Issue was due to a comment in vars.yaml
If you don't mind, can you provide the exact vars.yaml
and goss.yaml
to reproduce this?
Goss should not panic, this is definitely a bug.
Yes, sure! :)
Our vars.yaml
starts with:
domain_name: #DOMAIN#
k8s_version: 1.25
and then on a pipeline we replace #DOMAIN#
by a proper string, but when I was testing locally I forgot to change the value and that is why I got the segfault. Maybe it could be detected and show a proper error message when the variables are not well declared.
Thanks for looking into this, @aelsabbahy !
Just following up on this, I think I'm doing something wrong while trying to reproduce, can you also provide the matching goss.yaml that causes it to panic.
$ cat vars.yaml
domain_name: #DOMAIN#
k8s_version: 1.25
$ cat goss.yaml
command:
echo "hi":
exit-status: 0
stdout:
- {{.Vars.domain_name}}
stderr: []
timeout: 10000
$ goss.3.18 --vars vars.yaml render
command:
echo "hi":
exit-status: 0
stdout:
- <no value>
stderr: []
timeout: 10000
$ goss.3.18 --vars vars.yaml v
.F
Failures/Skipped:
Command: echo "hi": stdout: patterns not found: [<no value>]
Total Duration: 0.002s
Count: 2, Failed: 1, Skipped: 0
Sorry, I am also unable to reproduce with the previous goss.yaml
that caused the segfault. I think we can close it.
It's okay, I have some theories on how it may have happened, but can't reproduce it.
I'll roll out those "fixes" in a future PR. We can leave the ticket open for that, I won't know for sure I fixed the problem, but should help.
Thank you for following back up.
Got it again! It's related with the http
module:
$ ./goss --version
goss version v0.4.1
$ cat goss.yaml
http:
# Ensure argocd is available and redirected to HTTPS
http://argocd.mgmt.{{ .Vars.domain_name }}/:
status: 302
no-follow-redirects: true
headers:
- "Location: https://argocd"
$ cat vars.yaml
domain_name: #DOMAIN#
k8s_version: 1.25
$ ./goss -g goss.yaml --vars vars.yaml render
http:
http://argocd.mgmt.<no value>/:
status: 302
allow-insecure: false
no-follow-redirects: true
headers:
- 'Location: https://argocd'
$ ./goss -g goss.yaml --vars vars.yaml validate
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x7ac440]
goroutine 69 [running]:
github.com/goss-org/goss/system.(*DefHTTP).Status(0xc00012b380)
/home/travis/gopath/src/github.com/goss-org/goss/system/http.go:186 +0x40
github.com/goss-org/goss/resource.ValidateGomegaValue({_, _}, {_, _}, {_, _}, {_, _}, _)
/home/travis/gopath/src/github.com/goss-org/goss/resource/validate.go:160 +0x3f6
github.com/goss-org/goss/resource.ValidateValue({_, _}, {_, _}, {_, _}, {_, _}, _)
/home/travis/gopath/src/github.com/goss-org/goss/resource/validate.go:130 +0x195
github.com/goss-org/goss/resource.(*HTTP).Validate(0xc000460a20, 0xc000330370?)
/home/travis/gopath/src/github.com/goss-org/goss/resource/http.go:81 +0x305
github.com/goss-org/goss.validate.func2()
/home/travis/gopath/src/github.com/goss-org/goss/validate.go:184 +0x91
created by github.com/goss-org/goss.validate
/home/travis/gopath/src/github.com/goss-org/goss/validate.go:181 +0x190
Hope that with this new info you can fix it :)
Awesome, I was able to reproduce it! Will fix it in the next goss release.. surprised not too many people ran into this.
Fixed in pr, will be in the next release.
Describe the bug
After adding an extra condition
(and (eq .name "argocd-applicationset-controller") (eq .port 7000))
when runninggoss -g test.yaml --vars vars.yaml validate
I get this error:How To Reproduce
vars.yaml
test.yaml
Expected Behavior
I want to be able to test for 2 conditions at the same time in a complex if statement.
Actual Behavior
I got a segfault error:
Environment: