[RESOLVED] Resin-cli preload stuck at "reading image information"

I am trying out resin-cli tool to preload my image. But after a few tryings, it always stuck at the same step.

$ resin preload kiosk.img --app Kiosk
Building Docker preloader image. [========================] 100%
/ Creating preloader container
- Starting preloader container
\ Fetching application Kiosk
| Fetching application Kiosk
\ Reading image information

And in docker, I see an image as

resin/resin-preload   latest              6c03d0547073        6 hours ago         278MB

But no running/stopped container.

What should I do?

Hi, can you run it with DEBUG=1 added in front of the command? That is:

DEBUG=1 resin preload kiosk.img --app Kiosk

and paste if there’s any more info here?

What device type is the Kiosk application? What OS are you running this on?

That is quite helpful. I got some error message. Interestingly, that did not stop the whole process. I will dig from here.

\ Starting preloader container
\ Fetching application KioskTraceback (most recent call last):
  File "/usr/src/app/preload.py", line 774, in <module>
    PARTITIONS_CACHE[None] = prepare_global_partitions()
  File "/usr/src/app/preload.py", line 76, in prepare_global_partitions
    return get_partitions(IMAGE)
  File "/usr/src/app/preload.py", line 65, in get_partitions
    return {p.label: p for p in PartitionTable(image).partitions if p.label}
  File "/usr/src/app/preload.py", line 368, in __init__
    sfdisk("--dump", "--json", image).stdout.decode("utf8")
  File "/usr/lib/python3.6/site-packages/sh.py", line 1427, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/usr/lib/python3.6/site-packages/sh.py", line 774, in __init__
    self.wait()
  File "/usr/lib/python3.6/site-packages/sh.py", line 792, in wait
    self.handle_command_exit_code(exit_code)
  File "/usr/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /sbin/sfdisk --dump --json /img/resin.img

  STDOUT:


  STDERR:
sfdisk: cannot open /img/resin.img: Not a tty

- Cleaning up temporary files

The device type is ARMv7hf, the command was run on Ubuntu x64.

Hi,

Thanks for the response, could you please give us the version numbers for:

  • resin-cli (resin --version)

  • resin-preload (npm ls | grep resin-preload)

  • Ubuntu

that you’re using, and the actual device type (the architecture is armv7hf, so is this, for example, a Raspberry Pi3?).

Many thanks, Heds

  • resin version: 7.9.3
  • resin-preload: I do not have such node module since my resin is prebuilt binary (downloaded as resin-cli-v7.9.3-linux-x64.zip)
  • Ubuntu: 18.04.1
  • Actual Device is RaspBerryPi 3.

Hi,

Apologies for the multiple questions. Could you also let us know the current version of Docker that you’re using? We’re trying to ascertain what might be causing these problems so need to keep looking at different components.

Best regards, Heds

No worries. Glad to help.

Package: docker-ce
Version: 18.06.1~ce~3-0~ubuntu
APT-Sources: https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages

Hi, can you please run the following command:

docker run --rm -v PATH_TO_YOUR_IMAGE:/resin.img resin/resin-preload sfdisk --dump --json /resin.img

?

Not quite sure about the first resin.img part. PATH_TO_YOUR_IMAGE:/resin.img, what does it mean? I replaced it with my output name (./kiosk.img), and got:

sfdisk: cannot open /resin.img: Is a directory

You should use the absolute path to the image, like docker run --rm -v /absolute/path/to/kiosk.img:/resin.img resin/resin-preload sfdisk --dump --json /resin.img

Thanks. So got same error:

sfdisk: cannot open /resin.img: Not a tty

This is very strange

Can you try deleting the resin/resin-preload docker image and the containers using it and retry the same command as above ?

or running docker run --rm resin/resin-preload sfdisk --version, you should get sfdisk from util-linux 2.28.2

So I removed the image and reran the command.

$ DEBUG=1 ./resin preload kiosk.img --app Kiosk
Building Docker preloader image. [===                     ] 12%
Step 1/7 : FROM docker:17.10.0-ce-dind
Building Docker preloader image. [======                  ] 25%
Step 2/7 : RUN apk update && apk add --no-cache python3 parted btrfs-progs docker util-linux sfdisk file coreutils sgdisk
 ---> Running in 4f0825289c30
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
v3.6.2-389-g0330746cad [http://dl-cdn.alpinelinux.org/alpine/v3.6/main]
v3.6.2-356-g4986359204 [http://dl-cdn.alpinelinux.org/alpine/v3.6/community]
OK: 8444 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
(1/29) Installing libattr (2.4.47-r6)
(2/29) Installing libacl (2.2.52-r3)
(3/29) Installing coreutils (8.27-r0)
(4/29) Installing device-mapper-libs (2.02.168-r3)
(5/29) Installing libseccomp (2.3.2-r0)
(6/29) Installing docker (17.05.0-r0)
Executing docker-17.05.0-r0.pre-install
(7/29) Installing libmagic (5.32-r0)
(8/29) Installing file (5.32-r0)
(9/29) Installing ncurses-terminfo-base (6.0_p20171125-r1)
(10/29) Installing ncurses-terminfo (6.0_p20171125-r1)
(11/29) Installing ncurses-libs (6.0_p20171125-r1)
(12/29) Installing readline (6.3.008-r5)
(13/29) Installing parted (3.2-r5)
(14/29) Installing libbz2 (1.0.6-r5)
(15/29) Installing expat (2.2.0-r1)
(16/29) Installing libffi (3.2.1-r3)
(17/29) Installing gdbm (1.12-r0)
(18/29) Installing sqlite-libs (3.20.1-r2)
(19/29) Installing python3 (3.6.5-r0)
(20/29) Installing libfdisk (2.28.2-r2)
(21/29) Installing libsmartcols (2.28.2-r2)
(22/29) Installing sfdisk (2.28.2-r2)
(23/29) Installing libgcc (6.3.0-r4)
(24/29) Installing popt (1.16-r6)
(25/29) Installing libstdc++ (6.3.0-r4)
(26/29) Installing sgdisk (1.0.1-r1)
(27/29) Installing libmount (2.28.2-r2)
(28/29) Installing findmnt (2.28.2-r2)
(29/29) Installing util-linux (2.28.2-r2)
Executing busybox-1.26.2-r7.trigger
OK: 188 MiB in 63 packages
Removing intermediate container 4f0825289c30
Building Docker preloader image. [=========               ] 37%
Step 3/7 : COPY ./requirements.txt /tmp/
Building Docker preloader image. [============            ] 50%
Step 4/7 : RUN pip3 install -r /tmp/requirements.txt
 ---> Running in b38d13ff09df
Collecting sh==1.12.14 (from -r /tmp/requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/4a/22/17b22ef5b049f12080f5815c41bf94de3c229217609e469001a8f80c1b3d/sh-1.12.14-py2.py3-none-any.whl
Installing collected packages: sh
Successfully installed sh-1.12.14
You are using pip version 9.0.3, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Removing intermediate container b38d13ff09df
Building Docker preloader image. [===============         ] 62%
Step 5/7 : COPY ./src /usr/src/app
Building Docker preloader image. [==================      ] 75%
Step 6/7 : WORKDIR /usr/src/app
 ---> Running in b9c9e08b2f4e
Removing intermediate container b9c9e08b2f4e
Building Docker preloader image. [=====================   ] 87%
Step 7/7 : CMD /usr/src/app/preload.py
 ---> Running in f2b6bf692ad2
Removing intermediate container f2b6bf692ad2
 ---> b77cff69a85f
Successfully built b77cff69a85f
Building Docker preloader image. [========================] 100%



/ Creating preloader container
- Starting preloader container
| Fetching application KioskTraceback (most recent call last):
  File "/usr/src/app/preload.py", line 774, in <module>
    PARTITIONS_CACHE[None] = prepare_global_partitions()
  File "/usr/src/app/preload.py", line 76, in prepare_global_partitions
    return get_partitions(IMAGE)
  File "/usr/src/app/preload.py", line 65, in get_partitions
    return {p.label: p for p in PartitionTable(image).partitions if p.label}
  File "/usr/src/app/preload.py", line 368, in __init__
    sfdisk("--dump", "--json", image).stdout.decode("utf8")
  File "/usr/lib/python3.6/site-packages/sh.py", line 1427, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/usr/lib/python3.6/site-packages/sh.py", line 774, in __init__
    self.wait()
  File "/usr/lib/python3.6/site-packages/sh.py", line 792, in wait
    self.handle_command_exit_code(exit_code)
  File "/usr/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /sbin/sfdisk --dump --json /img/resin.img

  STDOUT:


  STDERR:
sfdisk: cannot open /img/resin.img: Not a tty

- Cleaning up temporary files
\ Fetching application Kiosk
/ Reading image information

Seems to be the same issue as on https://github.com/resin-io/resin-cli/issues/878

I am struggling with the same issue on Windows 10. I have sfdisk from util-linux 2.28.2. DEBUG=1 doesn’t show errors.

/ Creating preloader container
/ Starting preloader container
\ Fetching application xxx
/ Fetching application xxx
| Reading image information

I think I get it. My output image (kiosk.img) was zero sized. If I filled it with some random data, the “not a tty” error was gone. I got “sfdisk: failed to dump partition table: No error information” instead, which apparently related to the image file.

I think preload command requires a working image as input, not as I thought, an image creating tool.

@magicloud, yes you are correct the preloader is not an image creating tool, but rather a tool for injecting docker images into a resinOS images so that they boot on initial provisioning.

Thanks. So I marked this thread resolved.