Commit graph

624 commits

Author SHA1 Message Date
Debarshi Ray
fb411796bf README.md, cmd/initContainer: Don't require /etc/machine-id in images
Since /etc/machine-id is bind mounted into the toolbox container from
the host operating system, it doesn't make sense to make it mandatory
for images to have that file. Apparently, (some?) Arch Linux images
don't have /etc/machine-id.

Since a missing containerPath for a directory is handled the same way,
there's no reason not to do the same for regular files. It will make
life a bit easier for those creating toolbox images for different
distributions.

https://github.com/containers/toolbox/pull/710
2021-06-22 02:31:30 +02:00
Debarshi Ray
dd3936c223 cmd/initContainer: Add more information to errors from mountBind
Errors thrown from 'toolbox init-container' are usually not shown to
the user. One has to use 'podman start --attach ...' to see them.
Therefore, it's worth adding the extra bit of information to the error.

https://github.com/containers/toolbox/pull/710
2021-06-22 02:31:30 +02:00
Debarshi Ray
7cbb7f39f5 cmd/initContainer: State that it's a directory in the debug logs
A subsequent commit will handle a missing containerPath when bind
mounting a regular file like /etc/machine-id. Therefore, it's better to
explicitly state that this code is dealing with a directory.

https://github.com/containers/toolbox/pull/710
2021-06-22 02:31:30 +02:00
Ondřej Míchal
dd5cd5f25a playbooks/setup-env: Show versions of more packages
https://github.com/containers/toolbox/pull/795
2021-06-22 00:00:57 +02:00
Ondřej Míchal
7d133001f4 test/system: Fix variable dereference
https://github.com/containers/toolbox/pull/793
2021-06-21 18:42:21 +02:00
Debarshi Ray
e8512828c1 cmd/list, test/system: Ignore the problem of UBI not being listed
Not having the corresponding image for UBI toolbox containers show up
in 'toolbox list' is a rough edge. However, the whole UBI feature is
a bit experimental. It's about a gratis RHEL environment getting
created in a jiffy on any host, which is something that hasn't been
done before, and those containers also suffer from various shortcomings
because of the limited package set of UBI.

So it's not that big of a problem if it takes a release or two to
hammer out the details. Especially since it's likely that there will
be a special Toolbox-specific image that's created out of the UBI RPM
repositories, which will likely have the com.github.containers.toolbox
label.

There's also the issue that 0.1.0 needs to be finished, and for that
the the churn needs to be kept down. Changing the labels can very
likely lead to compatibility issues in the future, because of which it
either can't be removed for a while or the wrong images start to get
listed. Some of the older labels have finally been removed, so it's
better not to add more to the list.

In short, this problem will likely fix itself in the coming months, so
it's wise not to create complications trying to rush through a fix.

This reverts commits 1df36591d0 and
e09de9f3e5.

https://github.com/containers/toolbox/issues/753
2021-06-19 01:12:08 +02:00
Ondřej Míchal
1df36591d0 list: Fix typo
Fallout from https://github.com/containers/toolbox/pull/776

https://github.com/containers/toolbox/pull/782
2021-06-01 07:40:06 +02:00
Ondřej Míchal
e09de9f3e5 list: Recognize UBI8 as Toolbox image & split tracked labels
UBI[0] does not have the recommend Toolbox labels used to track whether
an image/container is truly a toolbox image/container. Thankfully, they
have a number of labels to choose from that we can use to identify the
image. The "com.redhat.component=ubi8-container" seems to be ideal.

The approach of using the UBI8 label introduces one problem though. If
we were to use only one set of labels for both images and containers,
containers created with Podman and not Toolbox from UBI8 would also be
marked as toolbox containers. This is not desired and therefore there
are now two sets of labels. Ones for images where the new label has been
added and other for containers that stays the same.
2021-06-01 01:49:54 +02:00
Ondřej Míchal
54a2ca1ead test/system: Decouple image caching from Zuul
Since the rewrite of the system test suite[0] we've relied on the Zuul
playbooks for taking care of caching images using Skopeo for increasing
the reliability of the tests (in the past the instability of the Fedora
registry caused problems). This state is problematic if we want to use
the tests in other environments than the Zuul CI. This moves the caching
from Zuul into the system tests.

Currently, Bats does not support officially suite-wide setup and
teardown functions. The solution I chose was to add two new test files
that are executed before and after all tests. This may complicate the
execution of cherry-picked tests but that is not a very common use case
anyway.

The tests are now to some extent capable of adjusting to the host
environment. This is meant in the sense of: I'm running on RHEL, the
"default image" is UBI; I'm running on Fedora, the "default image" is
fedora-toolbox. This mechanism relies on os-release, which is the same
as what Toolbox itself uses.

[0] https://github.com/containers/toolbox/pull/517

https://github.com/containers/toolbox/pull/774
2021-06-01 00:41:20 +02:00
Ondřej Míchal
a24c2f6dc1 test/system: Bump secondary fedora image from 29 to 32
The fedora-toolbox:32 image is the first of images in the renamed
toolbox image repository[0]. With the change we can drop the
pull_image_old() function because it was kept only for the old image.

Seems like newer version of ShellCheck checks the validity of variable
names (SC2153). This caused a false positive, so I silenced it.

[0] https://github.com/containers/toolbox/pull/615

https://github.com/containers/toolbox/pull/780
2021-05-31 12:28:24 +02:00
Ondřej Míchal
d36cf1cf43 ci: Drop testing on Fedora 32
Fedora 32 has reached EOL in 25/05/2021[0]. Bye bye...

[0] https://fedorapeople.org/groups/schedule/f-32/f-32-all-tasks.html

https://github.com/containers/toolbox/pull/779
2021-05-27 00:37:55 +02:00
Ondřej Míchal
871d905ceb test/system: Use env var for invoking Toolbox
The system test refactor[0] replaced the 'run_toolbox' helper function
with 'run toolbox', which is a normal invocation of Toolbox. This makes
it impossible to override Toolbox used during the tests using env var.

[0] https://github.com/containers/toolbox/pull/693
2021-05-26 22:52:40 +02:00
Ondřej Míchal
2369da5d31 cmd/list: Filter images/containers using labels
Instead of executing 'podman ps|images' several times in a row, call
them only once and get output with all images/containers. Then, filter
out the JSON using labels and keep images/containers only with matching
labels.

This simplifies the code significantly and cuts down the execution time
of 'toolbox list'. The speed gain is noticeable:

- the system has 5 images and 10 containers

Before patch: ~1.45s
After patch:  ~0.85s
2021-05-24 17:28:02 +02:00
Ondřej Míchal
49460ebc56 cmd/list: Track labels of images/containers
This will be needed in a following commit.
2021-05-24 17:28:02 +02:00
Ondřej Míchal
ea452d7ced doc: Update to match current state & extend docs
- Update "See also" sections

Toolbox does not use Buildah for a considerable time now[0]. We can stop
referencing it in the "See also" sections of the documentation.

In some places mention podman command man pages where they are relevant.

- Add section about toolbox images/containers

Toolbox only supports certain OCI images. These should be documented.
Also, document the change of fedora-toolbox image name.

- Add a section about toolbox container setup

Toolbox containers are specifically configured OCI containers. This
should be documented so that users know what they're using.

- Remove redundant part documentation

The description of what `toolbox init-container` does is already in
toolbox-init-container(1). There's no need to have it in
toolbox-create(1). Instead, replace the text with a hint to visit the
other part of documentation.

- Clarify behaviour of --image option

The fact that Toolbox by default tries to pull from the Fedora
registry[1] should be noted.

- Update synopsis & description of commands

Mention options passed to `podman exec`. Remove redundant paragraph
about container names (is already dealt with in toolbox-create(1)).

There's no need to mention the name of the default container on Fedora
since Toolbox now also supports RHEL.

Mention the default used image on unrecognised systems.

Emphasize the fact that toolboxes are not a fully sandboxed environment.

Update the wording of the description and splits it into a few
subsections.

The description of the --monitor-host was inaccurate and while the
option will go away in the future[2], it is currently in and should be
more documented.

[0] https://github.com/containers/toolbox/pull/160
[1] https://registry.fedoraproject.org
[2] https://github.com/containers/toolbox/pull/617

https://github.com/containers/toolbox/pull/512
2021-05-24 17:15:50 +02:00
Ondřej Míchal
3db59abf2a cmd/run: Use home folder when $PWD is not in toolbox
Since v0.0.91[0] Toolbox throws an error if $PWD is not available in a
toolbox. While this fixes the problem with 'toolbox enter/run' silently
failing to enter/exec in a container, it still requires an action to be
made by the user. I believe it is better to handle such situations more
gracefully by falling back to entering the user's home folder + printing
a warning about doing so.

[0] https://github.com/containers/toolbox/pull/370
2021-05-24 15:31:29 +02:00
Trung Lê
66c49e0926 Rename Dockerfile to Containerfile
https://github.com/containers/toolbox/pull/757
2021-05-24 15:26:35 +02:00
xPMo
d1e024f9dd README: /etc/machine-id is required
See discussion on #710.
2021-05-24 12:39:49 +02:00
Ondřej Míchal
7fafcd271e completion/bash: Update completion
Following patches were made:

  - Use toolbox for listing containers/images (assumes the existence of
    cut and tail)
  - Suggest containers for cmd enter
  - Don't suggest --container option
  - Update global options
  - Don't suggest cmd if already specified

The preferred way to provide of a container in commands enter & create
is via an argument.

Since the rewrite in Go, Toolbox provides the --log-level & --log-podman
options. These options deprecate the --verbose & --very-verbose options.

The completion script with this pops already used global options from
the list, handles better cases with different options and suggests log
levels for the --log-level option.

Toolbox can't be used with multiple commands.
2021-05-24 12:35:46 +02:00
Debarshi Ray
e935ed893d cmd/create: Unbreak the spinner and the hint about using the container
The spinner needs to be explicitly stopped before showing the example
'enter' command for using the container. Otherwise, it gets misprinted:
  $ toolbox create foo
  Creating container foo: / Created container: foo
  Enter with: toolbox enter foo

A comment was added to highlight this, since it might not be obvious at
first sight.

Due to such potential quirks, it might be better to keep the spinner
somewhat tightly encapsulated with the code that necessitates it, which
in this case is 'podman create'. For instance, we already need to be
careful to avoid enclosing the pullImage function with a spinner
because it carries it's own.

The code lying between the 'podman pull' and the 'podman create' is so
light that a human user isn't able to discern the absence of a
spinner. So, it seems worth leaning towards ease of understanding and
avoiding potential traps.

This reverts commit 3aaa1d30f1.

https://github.com/containers/toolbox/pull/746
2021-04-03 23:21:07 +02:00
Ondřej Míchal
05e6368882 playbooks/system-test: Show test execution time
Execution time of a test can be a very useful tool.

https://github.com/containers/toolbox/pull/725
2021-03-31 16:02:30 +02:00
Debarshi Ray
803063f081 Update references to the default branch name
The default branch was renamed from "master" to "main".

https://github.com/containers/toolbox/issues/740
2021-03-25 23:07:00 +01:00
Jens Petersen
2dc097e9c0 utils: bump Fedora fallback version to 33
see also #546
2021-03-23 21:51:56 +01:00
Ondřej Míchal
2090e51199 cmd/rm,rmi: Properly rename called function
Fallout from: 06dcdbe2a6

https://github.com/containers/toolbox/pull/738
2021-03-22 18:48:17 +01:00
Ondřej Míchal
8bc0018eaa cmd/root: Streamline preRun()
if blocks with long else blocks can be hard to read.
2021-03-22 17:17:34 +01:00
Ondřej Míchal
6bbbedf675 cmd/root: Set up globals during preRun
Don't leave set-ups all over the place. Keep them in a single point.
2021-03-22 17:17:34 +01:00
Ondřej Míchal
06dcdbe2a6 cmd/rm,rmi: Use function for getting list of images/containers
Instead of using own ways of getting all toolbox images/containers (and
thus unnecessary duplication of code) use a dedicated function.
2021-03-22 17:16:53 +01:00
Ondřej Míchal
1e2005a7d0 cmd/list: Rename functions for getting images/containers 2021-03-22 16:23:35 +01:00
Ondřej Míchal
eedfdda535 cmd: Properly wrap around errors
While we mostly report an error correctly, we do not include (wrap) the
underlying cause. This can make debugging tricky at times.

https://github.com/containers/toolbox/pull/728
2021-03-22 12:04:24 +01:00
Ondřej Míchal
8c1d441916 build: Drop ShellCheck on Shell Toolbox
Shell Toolbox has been replaced by the Go implementation a quite while
ago. It is kept in the repository but is no longer actively developed.
There is no need to continue checking it with ShellCheck.

https://github.com/containers/toolbox/pull/733
2021-03-22 11:50:02 +01:00
Ondřej Míchal
7e60e89086 meson: Rearrange lines & check for Skopeo
Skopeo is now a dependency for running system tests[0]. It is not a hard
dependency but at least give the user a heads-up.

https://github.com/containers/toolbox/pull/732
2021-03-22 10:47:30 +01:00
Ondřej Míchal
424691b404 playbooks: Properly separate builddir setup & build
Call "meson builddir" makes Meson create a build directory called
"builddir". It does not make it build the project. A subsequent call to
"meson compile" or "ninja" needs to be made. This subtle detail causes
a minor (purely visual) discrepancy in the CI output. Fix this for both
unit-test & system-test job definitions.
2021-03-21 23:15:15 +01:00
Ondřej Míchal
b91a93044b Connect Go unit tests to Meson & rename CI job
We now have some Go unit tests[0] and we should use them. By adding a
new test case to Meson, the existing CI job called "shellcheck" has no
longer an accurate name. With this it has been renamed to "unit-test".
Also, the job is now more important and therefore should also be used
for gating.

[0] https://github.com/containers/toolbox/pull/474

https://github.com/containers/toolbox/pull/730
2021-03-21 22:20:59 +01:00
Ondřej Míchal
5c2086e9ea cmd/initContainer: Ignore unknown flags
The init-container command uses several flags. In the future we'd like
to minimize their number. In order to be able to do that without
breaking systems with older versions of Toolbox, the command can't error
out due to usage of unknown flags.

https://github.com/containers/toolbox/pull/724
2021-03-21 22:10:49 +01:00
Ondřej Míchal
1c1808c9d3 pkg/utils: Add missing variable in fmt.Errorf 2021-03-21 21:33:46 +01:00
masch
3cc6ece1f2 pkg/shell: Add unit tests
The used testing framework is testify[0].

[0] https://github.com/stretchr/testify

https://github.com/containers/toolbox/pull/474
2021-03-21 21:13:21 +01:00
Ondřej Míchal
cb56f674f6 cmd/create: Cleanup entry-point command assembly
Too many appends. Instead, put the required sequence into a single array
and append only the variable parts.

Instead of calling "init-container" with "--verbose", call it rather
with "--log-level debug".
2021-03-21 16:16:08 +01:00
Ondřej Míchal
3aaa1d30f1 cmd/create: Start spinner earlier
Showing spinner after a lot of work on creating a toolbox is done (even
though not really time consuming) does not make much sense.

When a spinner is started successfully, a stop command is deferred.
There's no need to stop it additionally.
2021-03-21 16:15:16 +01:00
Debarshi Ray
a8c6fd19d8 images: Use a regular file, not a symbolic link, for README.md
A while ago, 'podman build' stopped supporting COPY with relative
symbolic links [1]. Therefore, these image definitions can't be used
without first temporarily removing the symbolic links, which is
annoying.

The downside is that the copies of README.md now has to be separately
updated, which isn't that big of a hassle compared to the problem that
it fixes.

[1] https://github.com/containers/buildah/issues/1952

https://github.com/containers/toolbox/pull/723
2021-03-15 16:46:07 +01:00
Michael Lingelbach
31d63e9511 Don't assume that the user's GID is the same as the UID
When taking ownership of the runtime directory or the initialization
stamp file inside it, it was assumed that the user's GID and UID were
the same. However that might not always be the case.

Note that this commit doesn't use the GID passed from the host to the
toolbox container's entry point to configure the user inside the
container. That is actually more difficult than it sounds. The manual
for useradd(8) says that the group specified by the '--gid' flag must
actually exist.

https://github.com/containers/toolbox/issues/664
2021-03-10 16:23:50 +01:00
Ondřej Míchal
fbcc519795 .github: Update issue templates
Recently the issue labels were updated. The templates need to be updated
to auto-set labels correctly.

https://github.com/containers/toolbox/pull/711
2021-03-10 13:18:33 +01:00
Otto Urpelainen
889807ad49 Include the nano default editor
Since Fedora 33, `nano` is the default editor[0]. It needs to be
included in the fedora-toolbox image to have the standard Fedora
experience inside the container.

[0] https://fedoraproject.org/wiki/Changes/UseNanoByDefault
2021-03-10 13:06:15 +01:00
Ondřej Míchal
7ec26a27df src/create: Handle read-only /boot
CoreOS recently made /boot read-only[0]. This caused an issue with
starting containers because /boot was mounted only with option rslave
but missed the ro option. This caused a permission issue.

This scenario is very similar to the one with /usr on Fedora Silverblue.
The solution for this is to check mount options of the path and check if
it uses the rw option or ro and then add it to the mount options in the
--volume option in 'podman create'.

Fixes: https://github.com/coreos/fedora-coreos-tracker/issues/734

[0] 1de21ffa98

https://github.com/containers/toolbox/pull/712
2021-03-01 23:30:58 +01:00
Ondřej Míchal
872eba41a9 pkg/utils: Drop length check when getting mount options
On Fedora Silverblue 33 the output of 'findmnt --noheadings --output
OPTIONS /usr' is:

  ro,relatime,seclabel,ssd,space_cache,subvolid=257,subvol=/root

(Fedora uses btrfs as it's default filesystem since version 33[0]). But
when you make the current deployment mutable using 'ostree admin unlock'
the output of the command changes to something like this:

  ro,relatime,seclabel,ssd,space_cache,subvolid=257,subvol=/root
  rw,relatime,seclabel,lowerdir=usr,upperdir=/var/tmp/ostree-unlock-ovl.JLXHQ0/upper,workdir=/var/tmp/ostree-unlock-ovl.JLXHQ0/work

This causes utils.GetMountOptions to error out preventing a successful
creation of a container with 'toolbox create' when the deployment is
unlocked.

For Toolbox the first line is the more relevant because even though /usr
is technically writeable, it will cease to be after reboot. This is the
current behaviour of the utils.GetMountOptions. Thanks to that I think
it's safe to remove the length check that prevents to create a container
when the current deployment is unlocked.

[0] https://fedoraproject.org/wiki/Changes/BtrfsByDefault

https://github.com/containers/toolbox/pull/554
2021-03-01 21:43:05 +01:00
Seppo Yli-Olli
af602c7d22 src/cmd/initContainer: Give access to systemd-resolved's Varlink socket
Since systemd >= 247, systemd-resolved offers a Varlink interface over
the socket at /run/systemd/resolve/io.systemd.Resolve.

https://github.com/containers/toolbox/pull/707
2021-02-24 22:26:16 +01:00
Seppo Yli-Olli
baac0461bd test/system: Support an optional nano version number
https://github.com/containers/toolbox/pull/709
2021-02-24 22:14:38 +01:00
Debarshi Ray
3801bd6e5a Prepare 0.0.99.1 2021-02-23 19:57:04 +01:00
Michael Lingelbach
a65fe31633 cmd/create: Check if /mnt exists before adding it as a volume mount
No /mnt on NixOS.

https://github.com/containers/toolbox/pull/676
2021-02-20 10:22:30 +01:00
Juanje Ojeda
05c9c06ec6 test/system: Add test for the new --distro option
https://github.com/containers/toolbox/pull/517
2021-02-19 20:38:55 +01:00
Juanje Ojeda
55b5018026 test/system: Test that sudo doesn't require a password
https://github.com/containers/toolbox/pull/517
2021-02-19 20:38:27 +01:00