Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic after getting terminal width in some CI environments #1581

Merged
merged 1 commit into from
Aug 10, 2020

Conversation

imiric
Copy link
Contributor

@imiric imiric commented Jul 31, 2020

In some CI environments like Codefresh, k6 detects that it's running in a TTY, the err returned by terminal.GetSize() is nil, yet termWidth is 0. Strange scenario, and we should fix our TTY check if possible, but it shouldn't panic with divide by zero anymore.

Closes #1579

In some CI environments like Codefresh, k6 detects that it's running in
a tty, the err returned by `terminal.GetSize()` is `nil`, yet
`termWidth` is 0. Strange scenario, and we should fix our TTY check if
possible, but it shouldn't panic with `divide by zero` anymore.

Closes #1579
@imiric imiric requested review from mstoykov and na-- July 31, 2020 12:03
@imiric
Copy link
Contributor Author

imiric commented Jul 31, 2020

After this fix, runs on Codefresh show:

WARN[0001] error getting terminal size                   error="<nil>"

And the jobs pass successfully, though there's another issue actually making requests from Codefresh:

WARN[0001] Request Failed                                error="Get \"https://test-api.k6.io/\": x509: certificate signed by unknown authority"

But that can presumably be resolved by updating ca-certificates, though I didn't troubleshoot it further.

if err != nil {
termWidth = defaultTermWidth
tw, _, err := terminal.GetSize(fd)
if tw > 0 && err == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check might be overkill, but better safe than sorry in this case.

Copy link
Member

@na-- na-- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, 🤞 😅

@imiric imiric merged commit 3a713ec into master Aug 10, 2020
@imiric imiric deleted the fix/1579-terminal-panic branch August 10, 2020 14:14
@na-- na-- added this to the v0.28.0 milestone Aug 11, 2020
@luketn
Copy link

luketn commented Sep 24, 2020

Hi, I have the same error reported in #1579 and addressed here running a docker-compose CI build of K6:

Status: Downloaded newer image for loadimpact/k6:latest

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

 Init   [--------------------------------------] runner
  execution: ---------------------------------] Init API serverKlocal
     script: scripts/ewoks.js
     output: influxdb=http://influxdb:8086/k6 (http://influxdb:8086)

  scenarios: (100.00%) 1 executors, 5 max VUs, 50s max duration (incl. graceful stop):
           * default: Up to 5 looping VUs for 20s over 3 stages (gracefulRampDown: 30s, gracefulStop: 30s)

panic: runtime error: integer divide by zero--] Init VUs

goroutine 10 [running]:
github.com/loadimpact/k6/cmd.renderMultipleBars(0xc001680101, 0x7, 0x0, 0x0, 0xc001c02890, 0x2, 0x2, 0x5327a4, 0xd1fce0, 0x0)
	github.com/loadimpact/k6/cmd/ui.go:218 +0xda9
github.com/loadimpact/k6/cmd.showProgress.func2(0xc0004a5101)
	github.com/loadimpact/k6/cmd/ui.go:283 +0x8c
github.com/loadimpact/k6/cmd.showProgress(0x10d8a40, 0xc001df5440, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc001f06600, ...)
	github.com/loadimpact/k6/cmd/ui.go:352 +0x52a
github.com/loadimpact/k6/cmd.glob..func11.1(0x10d8a40, 0xc001df5440, 0xc002077500, 0xc002556a00, 0xc000092000, 0xc002d13180)
	github.com/loadimpact/k6/cmd/run.go:190 +0xb9
created by github.com/loadimpact/k6/cmd.glob..func11
	github.com/loadimpact/k6/cmd/run.go:189 +0xd34

Could you also let us know when the Docker Hub image will be released for 0.28 with this fix in it? Until then I am having to use the bleeding edge :master tag, which I would prefer not to do.

I encountered the bug with the circleci config:

version: 2
jobs:
  build:
    machine: true
    steps:
      - checkout
      - run: |
          docker-compose up -d influxdb grafana
          docker-compose run k6 run script.js

(so this was not limited to CodeFresh CI)

I can confirm that running the same script with the K6 image
loadimpact/k6:master

Fixes the issue.

@imiric
Copy link
Contributor Author

imiric commented Sep 24, 2020

Hi @luketn, sorry about that. We had some issues with the v0.28.0 release that caused the Docker image, Linux and Windows packages to not be built and published.

This is now addressed, and you can pull the loadimpact/k6:0.28.0 image now. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

K6 crashes with "panic: runtime error: integer divide by zero" when run in CodeFresh
4 participants