4 Commits

Author SHA1 Message Date
Albert Esteve
3ef97fbaa9 container: serve image with nbd
Include qemu-nbd in the container to make it
easier for users to use the containerized imageio
server.

The container now runs with a script as an
ENTRYPOINT. The script runs as a program that
can receive additional command line parameters.
The script is basically a launcher for the two
main services involved:
- qemu-nbd serving the image
- ovirt-imageio exposing the image through http

This commit removes support for file ticket, only
nbd tickets are implicitely used. This is better,
as nbd does much of the hard work for us, so will
perform better.

Users will not have to worry about
the ticket anyway, the ticket is also generated
automatically, so no need to mount the ticket
inside the container, or give an environment
variable. Users can set the ticket ID in the
command line, or use the file name as default.

Example session:

$ mkdir /var/tmp/images
$ qemu-img create -f raw /var/tmp/images/disk.raw 6g

$ podman run \
        --interactive \
        --tty \
        --rm \
        --publish 8080:80 \
        --volume /var/tmp/images:/var/tmp:Z \
        localhost/ovirt-imageio:latest /var/tmp/disk.raw
2022-10-20 14:46:08,953 INFO    (MainThread) [server] Starting (hostname=1594cc8a121b pid=8, version=2.4.7)
2022-10-20 14:46:08,970 INFO    (MainThread) [services] remote.service listening on ('::', 80)
2022-10-20 14:46:08,970 INFO    (MainThread) [server] Initial ticket: /ticket.json
2022-10-20 14:46:08,971 INFO    (MainThread) [server] Ready for requests
...
2022-10-26 12:07:00,155 INFO    (MainThread) [server] Received signal 2, shutting down
Interrupted, shutting down

$ examples/imageio-client download -f raw http://localhost:8080/images/disk.raw download.raw
[ 100%  ] 6.00 GiB, 0.10 s, 57.23 GiB/s

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2022-10-31 21:09:32 +02:00
Albert Esteve
976f004ba5 reuse: addheader container folder
Add SPDX header to files in the container
directory.

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2022-10-18 13:04:20 +02:00
Albert Esteve
57cdb2e34c container: load ticket during start
Use an environment variable, namely
TICKET_PATH, to allow users to define
the full path for the volume mount point
and the ticket name, so that the file
can be used in the CMD instruction,
and the containerized imageio
can load the ticket from start.

The volume containing the image should be
mounted at runtime in the path specified
in the ticket, and have the right permissions.

Example session:

    $ mkdir /var/tmp/images
    $ qemu-img create -f raw /var/tmp/images/disk.raw 6g
    $ podman run \
        --interactive \
        --tty \
        --rm \
        --publish 8080:80 \
        --env TICKET_PATH=/ticket/file.json \
        --volume ./examples:/ticket:Z \
        --volume /var/tmp/images:/var/tmp:Z \
        localhost/ovirt-imageio:latest
    2022-10-08 14:41:14,961 INFO    (MainThread) [server] Starting (hostname=51365cc84a8b pid=1, version=2.4.7)
    2022-10-08 14:41:14,966 INFO    (MainThread) [services] remote.service listening on ('::', 80)
    2022-10-08 14:41:14,966 INFO    (MainThread) [server] Initial ticket: /ticket/file.json
    2022-10-08 14:41:14,967 INFO    (MainThread) [server] Ready for requests

In another shell, download the image:

    $ curl http://localhost:8080/images/file -o /data/tmp/download.raw
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 6144M  100 6144M    0     0  1342M      0  0:00:04  0:00:04 --:--:-- 1347M

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2022-10-17 14:28:29 +02:00
Nir Soffer
3e39567be9 container: Add ovirt-imageio container
Start a container image for running imageio and container.

Using a container, the user will run an image transfer pod for every
transfer, exposing the pod for remote access, and connecting the
relevant storage the pod. When the transfer is done, the user will
unexpose the pod and terminate it.

In this mode the imageio server will serve one ticket, injected into the
pod when starting the pod, instead of adding a ticket using the control
service.

To created the container run:

    make container

This creates localhost/ovirt-imageio container image using podman
configured for rootless environment[1].

To run the container:

    podman run --publish 8080:80 -v /path/to/image:/images:Z ovirt-imageio

Next we only need to load a ticket and create the image in the mounted
images folder. Note that the path for the file in the ticket needs
to match the path where we mounted the images folder in the container.

Alternatively, we can mount the nbd socket path in the container
and request the image with a nbd ticket.

More work is needed:
- Modify the server to load a ticket from file during startup
- Document how to mount the image to transfer or the nbd socket in
  the container.
- Inject PKI files into the container (can be done later)

[1] https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
2022-10-17 14:28:29 +02:00