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

Failed to write to log, invalid argument #233

Closed
eine opened this issue Sep 26, 2019 · 8 comments · Fixed by #252
Closed

Failed to write to log, invalid argument #233

eine opened this issue Sep 26, 2019 · 8 comments · Fixed by #252

Comments

@eine
Copy link

eine commented Sep 26, 2019

On Win10, when using full, the docker cli is found and the target image is succesfully pulled. However, dive fails because of some issue with the log:

# docker run --rm -v //var/run/docker.sock://var/run/docker.sock wagoodman/dive:full ghdl/run:buster-gcc
Unable to find image 'wagoodman/dive:full' locally
full: Pulling from wagoodman/dive
c4417d4ce49e: Pulling fs layer
f54082d45830: Pulling fs layer
f54082d45830: Verifying Checksum
f54082d45830: Download complete
c4417d4ce49e: Verifying Checksum
c4417d4ce49e: Download complete
c4417d4ce49e: Pull complete
f54082d45830: Pull complete
Digest: sha256:196d317a75f6691b8fccb4d27f81366cbf97da03a4a787ad6e05b45ddbae211b
Status: Downloaded newer image for wagoodman/dive:full
Fetching image... (this can take a while with large images)
Image not available locally. Trying to pull 'ghdl/run:buster-gcc'...
buster-gcc: Pulling from ghdl/run
1ab2bdfe9778: Already exists
765cf918ec12: Pulling fs layer
a6f4bbfc5d61: Pulling fs layer
867fa6686aa6: Pulling fs layer
a6f4bbfc5d61: Download complete
867fa6686aa6: Verifying Checksum
867fa6686aa6: Download complete
765cf918ec12: Verifying Checksum
765cf918ec12: Download complete
765cf918ec12: Pull complete
a6f4bbfc5d61: Pull complete
867fa6686aa6: Pull complete
Digest: sha256:de28d4886eb540b6ca51eea348baee1b6e54e2f2966b7ffa19444d0404660e90
Status: Downloaded newer image for ghdl/run:buster-gcc
docker.io/ghdl/run:buster-gcc
Parsing image...
Analyzing image...
Building cache...
Failed to write to log, invalid argument

This is the same if I try to use dive with any image which is available locally already.

@wagoodman
Copy link
Owner

I think this is a PATH problem within the container. There is a good chance you would not see this on the new release, v0.9.0 (mind reporting back if the latest release works for you)?

@eine
Copy link
Author

eine commented Nov 5, 2019

I just tested the latest release, but it fails. There is an additional error message:

# docker run --rm -v //var/run/docker.sock://var/run/docker.sock wagoodman/dive ghdl/run:buster-gcc
Image Source: docker://ghdl/run:buster-gcc
Fetching image... (this can take a while for large images)
Analyzing image...
Building cache...
Failed to write to log, invalid argument
open /dev/tty: no such device or address

@eine
Copy link
Author

eine commented Nov 5, 2019

Upon further testing, dive requires the container to have an allocated pseudo-TTY (i.e. option --tty or -t). It'd be useful if dive exited cleanly when it is not available.

On MSYS2, using -t only produces a segmentation violation:

# docker run --rm -tv //var/run/docker.sock://var/run/docker.sock wagoodman/dive ghdl/run:buster-gcc
Image Source: docker://ghdl/run:buster-gcc
Fetching image... (this can take a while for large images)
Analyzing image...
Building cache...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x80 pc=0x13036b2]

goroutine 28 [running]:
github.com/jroimartin/gocui.(*View).Clear(...)
        /home/wagoodman/go/pkg/mod/github.com/jroimartin/[email protected]/view.go:392
github.com/wagoodman/dive/runtime/ui/view.(*FileTree).Render.func1(0xc0000dd170, 0xc000241ac8, 0x2)
        /home/wagoodman/github/dive/runtime/ui/view/filetree.go:373 +0x42
github.com/jroimartin/gocui.(*Gui).MainLoop(0xc0000dd170, 0xc0003ddc70, 0xc000adfc20)
        /home/wagoodman/go/pkg/mod/github.com/jroimartin/[email protected]/gui.go:377 +0x2d9
github.com/wagoodman/dive/runtime/ui.Run(0xc0003ddc70, 0xc000adfc20, 0x4, 0x4, 0xc000355c20, 0x0, 0x0)
        /home/wagoodman/github/dive/runtime/ui/app.go:135 +0x10f
github.com/wagoodman/dive/runtime.run(0x23be501, 0x0, 0x7ffe4acb6f62, 0x13, 0x1, 0x0, 0x0, 0xc000108f00, 0x0, 0x0, ...)
        /home/wagoodman/github/dive/runtime/run.go:105 +0x8e4
created by github.com/wagoodman/dive/runtime.Run
        /home/wagoodman/github/dive/runtime/run.go:127 +0x118

winpty is required:

# winpty docker run --rm -tv //var/run/docker.sock://var/run/docker.sock wagoodman/dive ghdl/run:buster-gcc
Image Source: docker://ghdl/run:buster-gcc
Fetching image... (this can take a while for large images)
...

@eine
Copy link
Author

eine commented Nov 6, 2019

FTR, when used in CI mode, -t is not required:

# docker run --rm -e CI=true -v //var/run/docker.sock://var/run/docker.sock wagoodman/dive ghdl/run:buster-gcc
  Using default CI config
Image Source: docker://ghdl/run:buster-gcc
Fetching image... (this can take a while for large images)
Analyzing image...
  efficiency: 99.6966 %

  wastedBytes: 903570 bytes (904 kB)

  userWastedPercent: 0.5500 %

Inefficient Files:
Count  Wasted Space  File Path
    4        374 kB  /var/lib/dpkg/status-old
    4        374 kB  /var/lib/dpkg/status
    3         41 kB  /var/log/dpkg.log
    3         27 kB  /etc/ld.so.cache
    4         25 kB  /var/log/apt/eipp.log.xz
    4         24 kB  /var/lib/apt/extended_states
    3         22 kB  /var/log/apt/term.log
    2         12 kB  /var/cache/ldconfig/aux-cache
    3        4.2 kB  /var/log/apt/history.log
    4           0 B  /var/lib/dpkg/triggers/Lock
    4           0 B  /var/lib/dpkg/lock
Results:
  PASS: highestUserWastedPercent
  SKIP: highestWastedBytes: rule disabled
  PASS: lowestEfficiency
Result:PASS [Total:3] [Passed:2] [Failed:0] [Warn:0] [Skipped:1]

@mdeknowis
Copy link

mdeknowis commented Nov 8, 2019

Executing dive 0.9.0 on Windows 10 in CMD:

>dive registry.access.redhat.com/ubi8/ubi-minimal
�[1mImage Source: �[0mdocker://registry.access.redhat.com/ubi8/ubi-minimal
�[1mFetching image...�[0m (this can take a while for large images)
�[1mAnalyzing image...�[0m
Failed to write to log, invalid argument
�[1mBuilding cache...�[0m
Failed to write to log, invalid argument
cannot build cache tree
Failed to write to log, invalid argument
cannot remove upperNode /var/log/anaconda: path does not exist: /var/log/anaconda

Same in cygwin:

> dive registry.access.redhat.com/ubi8/ubi-minimal
Image Source: docker://registry.access.redhat.com/ubi8/ubi-minimal
Fetching image... (this can take a while for large images)
Analyzing image...
Failed to write to log, invalid argument
Building cache...
Failed to write to log, invalid argument
cannot build cache tree
Failed to write to log, invalid argument
cannot remove upperNode /var/log/anaconda: path does not exist: /var/log/anaconda

Using 0.8.1 is working in the CMD.

But in cygwin I just get:

> dive registry.access.redhat.com/ubi8/ubi-minimal
Fetching image... (this can take a while with large images)
Parsing image...
Analyzing image...
Building cache...
Failed to write to log, invalid argument

@uhinze
Copy link

uhinze commented Nov 18, 2019

+1, facing the same problem on MacOS installed via Homebrew:

~ ❯ dive gcr.io/cloud-builders/docker
Image Source: docker://gcr.io/cloud-builders/docker
Fetching image... (this can take a while for large images)
Analyzing image...
Failed to write to log, invalid argument
Failed to write to log, invalid argument
Failed to write to log, invalid argument
Failed to write to log, invalid argument
Building cache...
Failed to write to log, invalid argument
cannot build cache tree
Failed to write to log, invalid argument
cannot remove upperNode /var/log/alternatives.log: path does not exist: /var/log/alternatives.log

But it works fine with dive alpine

@wagoodman
Copy link
Owner

It seems that there are two problems here:

  • the underlying problem that this ticket is titled after ('failed to write to log...') occurs when logging is disabled a nil file object was still being set as the output destination.
  • secondary failures (unrelated to the first problem) that attempt to log errors (such as "cannot remove upperNode") still show "failed to write log". Both cases provided (thanks @uhinze and @mdeknowis for providing images to reproduce!) are due to some layers having relative path prefix (e.g. ./) and the same path in subsequent layers not having a relative prefix.

Both fixes will make it into the next release.

@eine
Copy link
Author

eine commented Nov 19, 2019

Thanks @wagoodman!

I posted two different variants of the first error:

  • open /dev/tty: no such device or address
  • panic: runtime error: invalid memory address or nil pointer dereference

The first one is because there is no tty and dive does require it (unless in CI mode). Hence, I would suggest to add a message/note when this error is handled and dive is being executed inside a container. I believe I have some golang function to detect this latter condition, but I don't know where is the error reported in the codebase. The message would suggest users to use -t (and -i?).

The second type of error might be trickier. Of course, dive should not crash, but exit gracefully. Apart from that, I don't think that any specific message can be shown. Requiring winpty is specific to some platforms/terminals, and there is no easy mechanism to identify the context from inside the container. A generic message may be added, tho.

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 a pull request may close this issue.

4 participants