NVIDIA / container-canary

A tool for testing and validating container requirements against versioned manifests
Apache License 2.0
246 stars 15 forks source link

`make` fails if docker is not installed and running #31

Closed mattf closed 2 years ago

mattf commented 2 years ago

this was discovered on CBL-Mariner (https://github.com/microsoft/CBL-Mariner), but likely exists everywhere.

steps to reproduce are -

  1. provision a fresh system
  2. git clone container-canary
  3. cd container-canary; make

image

i would expect the test runner to check for docker and check for docker to be running, and provide a clear next steps.

note: mariner uses moby, which includes docker porcelain.

jacobtomlinson commented 2 years ago

Thanks for raising this @mattf. We should definitely be handing errors better if the docker command is missing on the system. I would expect tests to fail as docker is a hard dependency right now, but we can make the error messages nicer.

The traceback I'm seeing in the reproducer is truncated, could you just confirm we are seeing the same thing?

$ docker run --rm -it golang bash  # Jump into a container that doesn't have `docker`

$ git clone https://github.com/NVIDIA/container-canary.git /usr/local/src

$ cd /usr/local/src

$ make
go test -v ./...
?       github.com/nvidia/container-canary      [no test files]
=== RUN   TestRoot
--- PASS: TestRoot (0.00s)
=== RUN   TestValidate
    validate_test.go:35:
                Error Trace:    validate_test.go:35
                Error:          Expected nil, but got: &errors.errorString{s:"no such image: container-canary/kubeflow:shouldpass"}
                Test:           TestValidate
                Messages:       should not error
    validate_test.go:36:
                Error Trace:    validate_test.go:36
                Error:          "Cannot find container-canary/kubeflow:shouldpass, pulling..." does not contain "Validating container-canary/kubeflow:shouldpass against kubeflow"
                Test:           TestValidate
                Messages:       did not validate
    validate_test.go:37:
                Error Trace:    validate_test.go:37
                Error:          "Cannot find container-canary/kubeflow:shouldpass, pulling..." does not contain "validation passed"
                Test:           TestValidate
                Messages:       did not pass
--- FAIL: TestValidate (0.00s)
=== RUN   TestValidateFails
    validate_test.go:49:
                Error Trace:    validate_test.go:49
                Error:          "Cannot find container-canary/kubeflow:shouldfail, pulling..." does not contain "validation failed"
                Test:           TestValidateFails
                Messages:       did not fail
--- FAIL: TestValidateFails (0.00s)
=== RUN   TestFileDoesNotExist
--- PASS: TestFileDoesNotExist (0.00s)
=== RUN   TestVersion
Container Canary
--- PASS: TestVersion (0.00s)
FAIL
FAIL    github.com/nvidia/container-canary/cmd  0.012s
?       github.com/nvidia/container-canary/internal     [no test files]
?       github.com/nvidia/container-canary/internal/apis/v1     [no test files]
=== RUN   TestValidator
--- PASS: TestValidator (0.00s)
PASS
ok      github.com/nvidia/container-canary/internal/config      0.035s
=== RUN   TestDockerContainer
    docker_test.go:45: Failed to start container: exec: "docker": executable file not found in $PATH
    docker_test.go:50: Failed to inspect container: exec: "docker": executable file not found in $PATH
--- FAIL: TestDockerContainer (0.00s)
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=0x28 pc=0xaad1b5]

goroutine 7 [running]:
testing.tRunner.func1.2({0xb22f00, 0x113e3e0})
        /usr/local/go/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
        /usr/local/go/src/testing/testing.go:1392 +0x39f
panic({0xb22f00, 0x113e3e0})
        /usr/local/go/src/runtime/panic.go:838 +0x207
github.com/nvidia/container-canary/internal/container.TestDockerContainer(0xc0001fa680)
        /usr/local/src/internal/container/docker_test.go:52 +0x295
testing.tRunner(0xc0001fa680, 0xc49850)
        /usr/local/go/src/testing/testing.go:1439 +0x102
created by testing.(*T).Run
        /usr/local/go/src/testing/testing.go:1486 +0x35f
FAIL    github.com/nvidia/container-canary/internal/container   0.007s
?       github.com/nvidia/container-canary/internal/validator   [no test files]
FAIL
make: *** [Makefile:30: test] Error 1
mattf commented 2 years ago

the truncation is because i'm running this in a vm. i can confirm it's the same trace...

image