grafana / k6

A modern load testing tool, using Go and JavaScript - https://k6.io
GNU Affero General Public License v3.0
25.11k stars 1.24k forks source link

K6_BLACKLIST_IPS parsing is broken #1257

Open imiric opened 4 years ago

imiric commented 4 years ago

Current behavior on master (a2e1c6f4e6207d69461a1b0f24c3aa2c72233101):

$ K6_BLACKLIST_IPS="10.0.0.0/8" go run main.go run samples/thresholds.js

          /\      |‾‾|  /‾‾/  /‾/
     /\  /  \     |  |_/  /  / /
    /  \/    \    |      |  /  ‾‾\
   /          \   |  |‾\  \ | (_) |
  / __________ \  |__|  \__\ \___/ .io

panic: runtime error: invalid memory address or nil pointer dereferenceptions
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x984ddd]

goroutine 1 [running]:
github.com/loadimpact/k6/lib.(*IPNet).UnmarshalText(0x0, 0xc0027240f0, 0xa, 0x10, 0xa, 0x10)
        /home/ivan/.local/go/src/github.com/loadimpact/k6/lib/options.go:173 +0x7d
github.com/loadimpact/k6/vendor/github.com/kelseyhightower/envconfig.processField(0xc000036511, 0xa, 0xd6a700, 0xc00309d260, 0x196, 0xc00309d260, 0x196)
        /home/ivan/.local/go/src/github.com/loadimpact/k6/vendor/github.com/kelseyhightower/envconfig/envconfig.go:251 +0x1415
github.com/loadimpact/k6/vendor/github.com/kelseyhightower/envconfig.processField(0xc000036511, 0xa, 0xcff020, 0xc00092d638, 0x197, 0x0, 0x0)
        /home/ivan/.local/go/src/github.com/loadimpact/k6/vendor/github.com/kelseyhightower/envconfig/envconfig.go:312 +0x10f7
github.com/loadimpact/k6/vendor/github.com/kelseyhightower/envconfig.Process(0x0, 0x0, 0xd7d220, 0xc00092d500, 0x494dbd, 0x10a8bc0)
        /home/ivan/.local/go/src/github.com/loadimpact/k6/vendor/github.com/kelseyhightower/envconfig/envconfig.go:215 +0x5aa
github.com/loadimpact/k6/cmd.readEnvConfig(0x10c6b20, 0x1982838, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/ivan/.local/go/src/github.com/loadimpact/k6/cmd/config.go:188 +0x69
github.com/loadimpact/k6/cmd.getConsolidatedConfig(0x10c6b20, 0x1982838, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/ivan/.local/go/src/github.com/loadimpact/k6/cmd/config.go:311 +0x8f7
github.com/loadimpact/k6/cmd.glob..func11(0x1957f00, 0xc0002c45f0, 0x1, 0x1, 0x0, 0x0)
        /home/ivan/.local/go/src/github.com/loadimpact/k6/cmd/run.go:139 +0x817
github.com/loadimpact/k6/vendor/github.com/spf13/cobra.(*Command).execute(0x1957f00, 0xc0002c45c0, 0x1, 0x1, 0x1957f00, 0xc0002c45c0)
        /home/ivan/.local/go/src/github.com/loadimpact/k6/vendor/github.com/spf13/cobra/command.go:762 +0x460
github.com/loadimpact/k6/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1957580, 0xc0003aa100, 0xc000038ba0, 0xe9535d)
        /home/ivan/.local/go/src/github.com/loadimpact/k6/vendor/github.com/spf13/cobra/command.go:852 +0x2ea
github.com/loadimpact/k6/vendor/github.com/spf13/cobra.(*Command).Execute(...)
        /home/ivan/.local/go/src/github.com/loadimpact/k6/vendor/github.com/spf13/cobra/command.go:800
github.com/loadimpact/k6/cmd.Execute()
        /home/ivan/.local/go/src/github.com/loadimpact/k6/cmd/root.go:89 +0x3f
main.main()
        /home/ivan/.local/go/src/github.com/loadimpact/k6/main.go:28 +0x20
exit status 2

Passing it via CLI works fine (go run main.go run --blacklist-ip '10.0.0.0/8' samples/thresholds.js).

cuonglm commented 4 years ago

I think it's not us but the envconfig.

I raised an issue and made the PR to fix it https://github.com/kelseyhightower/envconfig/issues/157

codebien commented 11 months ago

envconfig seems to be unmaintained and the PR is no getting reviews. The suggestion here is to add a specific code on k6 side for fixing this specific issue then add a comment mentioning the PR. In the comment a mention to #883, which probably will provide the optimal solution, should be added.

mstoykov commented 11 months ago

given that we no longer use hte orignal envconfig but a fork ... we might want to merge this PR there - if that mkaes more sense.

But IMO more testing is needed.

codebien commented 11 months ago

Oh, I forgot about the fork! Sure, we can merge the PR there + more tests and then we need to bump the dependency here in k6.