google / shipshape

Program analysis platform
Apache License 2.0
269 stars 35 forks source link

Add better handling of third-party container ports #56

Open emsod opened 9 years ago

emsod commented 9 years ago

I ran some tests with a third-party analyzer for extendj using:

$ bazel-bin/shipshape/cli/shipshape --categories="ExtendJ" \ --analyzer_images="extendj_service/extendj" \ --tag=local

Then I ran the end-to-end-test.sh and got this error in the test log file: ... Pulling complete I0629 14:48:52.256346 13531 shipshape.go:382] Analyzers pulled I0629 14:48:52.256384 13531 shipshape.go:413] Waiting for dockerized analyzers to start up... I0629 14:48:52.302231 13531 shipshape.go:394] Found no analyzer container (android_lint_0) to reuse for gcr.io/shipshape_releases/android_lint: I0629 14:48:52.323912 13531 shipshape.go:399] Failed to stop android_lint_0 (may not be running) I0629 14:48:52.323982 13531 docker.go:131] Running 'docker [run -p=127.0.0.1:10010:10005 -v=/tmp/shipshape-tests:/shipshape-workspace -v=/tmp:/shipshape-output --name=android_lint_0 -d gcr.io/shipshape_releases/android_lint:]' I0629 14:48:52.683436 13531 shipshape.go:403] Could not start gcr.io/shipshape_releases/android_lint: at localhost:10010: exit status 1, stderr: Error response from daemon: Cannot start container c1efd504d306bbe4ec09f19fbe0eaa7f36780d930a2275fa18e5fbebe1eaa675: Bind for 127.0.0.1:10010 failed: port is already allocated ...

The extendj run started a third-party analyzer container on 10010 and then the second run with a different third-party analyzer container fails because the port is already bound.

We should have a more dynamic way of picking ports. We could test until a port is free in an interval of ports.