Commit Graph

1524 Commits

Author SHA1 Message Date
Debarshi Ray 836c0557f4 test/system: Optimize the environment variable tests
The system tests can be very I/O intensive, because many of them copy
OCI images from the test suite's image cache directory to its local
container/storage store, create containers, and then delete everything
to run the next test with a clean slate.  This makes them slow.

The runtime environment tests, which includes the environment variable
tests, are particularly slow because they don't skip the I/O even when
testing error handling.  This makes them a good target for
optimizations.

The environment variable tests query the values of different environment
variables from different containers without changing their state.
Therefore, a lot of disk I/O can be avoided by creating these containers
only once for all the tests.

This can reduce the time needed to run the environment variable tests
from almost 26 minutes to almost 9 minutes.

https://github.com/containers/toolbox/pull/1646
2025-05-12 23:26:00 +02:00
Debarshi Ray a5a0d5350f test/system: Remove redundant clean-up
The IMAGE_CACHE_DIR environment variable is defined as
"${BATS_SUITE_TMPDIR}/image-cache" [1].  Earlier, it used to be
"${BATS_RUN_TMPDIR}/image-cache".

There's no need to clean up anything inside BATS_RUN_TMPDIR or
BATS_SUITE_TMPDIR after the test suite has finished running, because
their life cycle is managed by Bats [2].

[1] Commit 3a549a6252
    https://github.com/containers/toolbox/commit/3a549a6252e990d6
    https://github.com/containers/toolbox/pull/1452

[2] https://bats-core.readthedocs.io/en/stable/writing-tests.html

Fallout from 9820550c82

https://github.com/containers/toolbox/pull/1645
2025-05-12 17:58:15 +02:00
Debarshi Ray d64682af0d test/system: Don't use XDG_CACHE_HOME or HOME for temporary files
The XDG_CACHE_HOME environment variable is supposed to default to
$HOME/.cache [1], just as it did in the test suite, and this location is
meant to be used as a cache for 'normal' use by the user.  Test suites
generally don't qualify as 'normal' use.

One expects that deleting the cache shouldn't affect 'normal' use other
than degrading performance.  However, deleting these temporary files
used by the test suite will cause actual breakage.  Even if the user
doesn't manually delete the cache, two concurrent invocations of the
test suite can do so or lead to other unexpected collisions, because the
paths are constant across multiple invocations.

Therefore, it's better to limit the scope of the test suite's temporary
files within the sandbox offered by Bats [2].  The sandbox is clearly
labelled as being used by Bats, is unique for each invocation, and Bats
takes care of cleaning everything up once it has finished running.

Note that there's no need for the system-test-storage sub-directory
under BATS_SUITE_TMPDIR.  So it was left out.

[1] https://specifications.freedesktop.org/basedir-spec/latest/

[2] https://bats-core.readthedocs.io/en/stable/writing-tests.html

https://github.com/containers/toolbox/pull/1645
2025-05-12 17:41:52 +02:00
Debarshi Ray e98032352e images/ubuntu: Create the directory for configuring PKCS#11 modules
The p11-kit-modules package in Ubuntu provides p11-kit-client.so, but
the /etc/pkcs11/modules directory that's necessary to configure p11-kit
to use p11-kit-client.so is not created by any package.

It's better to ensure that the /etc/pkcs11/modules directory exists in
the image, instead of having the Toolbx container's entry point create
it at runtime, because it can be a confirmation that p11-kit was built
to read the module configuration from this location.

This should have been part of commit aa8507730d.

https://github.com/containers/toolbox/issues/626
2025-05-07 19:03:18 +02:00
Debarshi Ray 26b3314fa5 images/arch: Create the directory for configuring PKCS#11 modules
The /etc/pkcs11 directory and /etc/pkcs11/pkcs11.conf.example file are
created by the p11-kit package in Arch Linux, and the lib11-kit package
provides p11-kit-client.so.  However, the /etc/pkcs11/modules directory
that's necessary to configure p11-kit to use p11-kit-client.so is not
created by any package.

It's better to ensure that the /etc/pkcs11/modules directory exists in
the image, instead of having the Toolbx container's entry point create
it at runtime, because it can be a confirmation that p11-kit was built
to read the module configuration from this location.

This should have been part of commit 259de86c8f.

https://github.com/containers/toolbox/issues/626
2025-05-07 17:43:29 +02:00
Debarshi Ray f0a7304e75 pkg/utils: Mark a private function as such and drop one that's unused
It's been a while since it's been necessary to read the ID field from
os-release(5) outside this package or the VARIANT_ID field anywhere at
all.  Therefore, it's time to adjust the code to reflect this reality.

Fallout from 8caa7cd828

https://github.com/containers/toolbox/pull/1642
2025-05-07 01:50:25 +02:00
Debarshi Ray 5881bc43f3 test/system: Optimize the D-Bus tests
The system tests can be very I/O intensive, because many of them copy
OCI images from the test suite's image cache directory to its local
container/storage store, create containers, and then delete everything
to run the next test with a clean slate.  This makes them slow.

The runtime environment tests, which includes the D-Bus tests, are
particularly slow because they don't skip the I/O even when testing
error handling.  This makes them a good target for optimizations.

The D-Bus tests check if methods can be called across the user or
session and system D-Bus instances from different containers without
changing their state.  Therefore, a lot of disk I/O can be avoided by
reating these containers only once for all the tests.

This can reduce the time needed to run the D-Bus tests from almost 10
minutes to almost 5 minutes.

https://github.com/containers/toolbox/pull/1641
2025-05-06 23:16:27 +02:00
Debarshi Ray 7a413e66b9 Move the code for Ubuntu support into its own file
This will reduce the size of the src/pkg/utils/utils.go file and make it
easier to specify which part of the code base is maintained by whom.

https://github.com/containers/toolbox/pull/1639
2025-05-06 02:39:28 +02:00
Debarshi Ray c794e183da Move the code for Red Hat Enterprise Linux support into its own file
This will reduce the size of the src/pkg/utils/utils.go file and make it
easier to specify which part of the code base is maintained by whom.

https://github.com/containers/toolbox/pull/1639
2025-05-06 02:20:18 +02:00
Debarshi Ray ab76cbca67 Move the code for Fedora support into its own file
This will reduce the size of the src/pkg/utils/utils.go file and make it
easier to specify which part of the code base is maintained by whom.

https://github.com/containers/toolbox/pull/1639
2025-05-06 02:07:17 +02:00
Debarshi Ray f9ebd5195b Move the code for Arch Linux support into its own file
This will reduce the size of the src/pkg/utils/utils.go file and make it
easier to specify which part of the code base is maintained by whom.

https://github.com/containers/toolbox/pull/1639
2025-05-06 01:56:01 +02:00
Debarshi Ray 1b9dd007ea test/system: Optimize the networking tests
The system tests can be very I/O intensive, because many of them copy
OCI images from the test suite's image cache directory to its local
container/storage store, create containers, and then delete everything
to run the next test with a clean slate.  This makes them slow.

The runtime environment tests, which includes the networking tests, are
particularly slow because they don't skip the I/O even when testing
error handling.  This makes them a good target for optimizations.

The networking tests check the behaviour and configuration of the
network in different containers without changing their state.
Therefore, a lot of disk I/O can be avoided by creating these containers
only once for all the tests.

This can reduce the time needed to run the networking tests from almost
15 minutes to almost 6 minutes.

https://github.com/containers/toolbox/pull/1637
2025-05-01 23:28:17 +02:00
Debarshi Ray 259de86c8f images/arch: Avoid losing p11-kit-client.so by accident
The libp11-kit package was added to the arch-toolbox image to ensure the
presence of p11-kit-client.so.  Currently, the package is already pulled
in by various dependencies, like the gnutls and p11-kit packages.
Therefore, it doesn't increase the size of the base image, but serves as
a safeguard against any inadvertent changes.

A subsequent commit will use this to give Toolbx containers access to
the certificates from certificate authorities on the host.  This commit
was kept separate from the changes to toolbox(1) to ensure that the
arch-toolbox image is ready before that happens.

https://github.com/containers/toolbox/issues/626
2025-05-01 20:37:18 +02:00
Debarshi Ray aa8507730d .github/workflows, images/ubuntu: Add p11-kit-client.so to newer Ubuntus
A subsequent commit will use this to give Toolbx containers access to
the certificates from certificate authorities on the host.  This commit
was kept separate from the changes to toolbox(1) to ensure that the
ubuntu-toolbox images are ready before that happens.

Unfortunately, Ubuntu 16.04 Xenial Xerus has p11-kit 0.23.2 [1], while
p11-kit-client.so was introduced in p11-kit 0.23.10 [2].  Therefore,
this feature will be disabled for Ubuntu 16.04.

This reverts parts of commit 1e9308625a to
re-enable building the ubuntu-toolbox:18.04 image.

[1] https://code.launchpad.net/~git-ubuntu-import/ubuntu/+source/p11-kit/+git/p11-kit/+ref/ubuntu/xenial-updates

[2] p11-kit commit 0684cd7b7f815b41
    https://github.com/p11-glue/p11-kit/commit/0684cd7b7f815b41
    https://github.com/p11-glue/p11-kit/pull/15

https://github.com/containers/toolbox/issues/626
2025-05-01 20:29:12 +02:00
Debarshi Ray 02fe08f70e cmd/initContainer: Style fix
Use a strings.Builder [1] instance instead of raw string literals for
consistency.

Fallout from 772b66bf3e

[1] https://pkg.go.dev/strings#Builder

https://github.com/containers/toolbox/pull/1636
2025-05-01 20:28:04 +02:00
Debarshi Ray 3017a46c03 test/system: Optimize the group and user tests
The system tests can be very I/O intensive, because many of them copy
OCI images from the test suite's image cache directory to its local
container/storage store, create containers, and then delete everything
to run the next test with a clean slate.  This makes them slow.

The runtime environment tests, which includes the group and user tests,
are particularly slow because they don't skip the I/O even when testing
error handling.  This makes them a good target for optimizations.

The group and user tests check the group and user configuration in
different containers without changing their state.  Therefore, a lot of
disk I/O can be avoided by creating these containers only once for all
the tests.

This can reduce the time needed to run the group and user tests from
almost 22 minutes to almost 5 minutes.

https://github.com/containers/toolbox/pull/1635
2025-05-01 20:24:07 +02:00
Debarshi Ray 69d6b11a9b test/system: Optimize the help tests
The system tests can be very I/O intensive, because many of them copy
OCI images from the test suite's image cache directory to its local
container/storage store, create containers, and then delete everything
to run the next test with a clean slate.  This makes them slow.

The tests for toolbox(1) invocations forwarded to the host, which
includes the help tests, are particularly slow because they never skip
the I/O.  This makes them a good target for optimizations.

The help tests for toolbox(1) invocations forwarded to the host use the
same default Toolbx container to invoke toolbox(1) from without changing
its state.  Therefore, a lot of disk I/O can be avoided by creating the
default container only once for all those tests.

This can reduce the time needed to run the help tests from almost 7
minutes to a few seconds.

https://github.com/containers/toolbox/pull/1635
2025-05-01 18:05:28 +02:00
Debarshi Ray a062224db3 Link to the website instead of the code repository (part 2)
Now that there's a website at https://containertoolbx.org/ it makes more
sense to link to it instead of the code repository.  The website is a
superset of the code repository and contains a lot more useful
information for someone who is not familiar with the Toolbx project.

https://github.com/containers/toolbox/pull/1632
2025-05-01 14:11:42 +02:00
Debarshi Ray 6b703b8d3c cmd: Simplify string building
When the fmt.Fprintf() [1] function is used to write to a
strings.Builder [2] instance, it uses the io.Writer [3] interface, which
is the strings.Builder.Write() method.  This method is practically the
same as the strings.Builder.WriteString() method, other than the fact
that the former accepts a slice of bytes and the latter accepts a
string.  So, the difference is the initial call to fmt.Fprintf().

Therefore, unless format verbs [4] are needed to build the string,
fmt.Fprintf() can be replaced with strings.Builder.WriteString().  It
reduces one function call and is shorter to type.

Fallout from the following:
  * e390f15469
  * 7542f5fc86
  * e58992066f
  * 8dd2f8e80a
  * 063bdf965f

[1] https://pkg.go.dev/fmt#Fprintf

[2] https://pkg.go.dev/strings#Builder

[3] https://pkg.go.dev/io#Writer

[4] https://pkg.go.dev/fmt

https://github.com/containers/toolbox/pull/1632
2025-05-01 00:15:00 +02:00
Debarshi Ray 2956ecacb4 cmd, pkg/utils: Split out the code to get the initialization stamp path
This will prevent any silly bug in getting the initialization stamp path
from breaking the communication protocol between the 'enter' or 'run'
commands on the host and the Toolbx container's entry point process.

https://github.com/containers/toolbox/pull/1633
2025-05-01 00:13:48 +02:00
Debarshi Ray 63309e4666 cmd/initContainer: Sprinkle some debug logs
https://github.com/containers/toolbox/pull/1631
2025-04-30 22:32:34 +02:00
Debarshi Ray ee182260b7 cmd/initContainer: Split out the code to configure Kerberos
This is meant to reduce the size of the initContainer() function that
implements the heart of the 'init-container' command.

The debug log and error message were tweaked to match the name of the
function and for consistency with the configureRPM() function.

https://github.com/containers/toolbox/pull/1631
2025-04-30 16:19:30 +02:00
Debarshi Ray 06f81546ef cmd/initContainer: Split out the code to configure RPM
This is meant to reduce the size of the initContainer() function that
implements the heart of the 'init-container' command.

https://github.com/containers/toolbox/pull/1631
2025-04-30 16:19:30 +02:00
Debarshi Ray 69702119b4 .github/workflows, test/system: Test the Kerberos configuration
https://github.com/containers/toolbox/pull/1631
2025-04-30 16:12:22 +02:00
Debarshi Ray 9ec4f139df .github/workflows, test/system: Test the RPM configuration
https://github.com/containers/toolbox/pull/1631
2025-04-30 01:45:20 +02:00
Debarshi Ray c512909acc build: Bump github.com/spf13/viper to 1.19.0
The indirect dependencies in the src/go.mod file, and the src/go.sum
file were updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1630
2025-04-28 14:10:39 +02:00
Debarshi Ray c2096cb7fa build: Bump github.com/spf13/viper to 1.18.2
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1630
2025-04-28 13:56:45 +02:00
Debarshi Ray 4dac44d42e build: Bump github.com/spf13/viper to 1.18.1
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1630
2025-04-28 13:55:13 +02:00
Debarshi Ray 454c05685a build: Bump github.com/spf13/viper to 1.18.0
The indirect dependencies in the src/go.mod file, and the src/go.sum
file were updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1630
2025-04-28 13:44:22 +02:00
Debarshi Ray 9989ffac14 cmd/root, pkg/utils: Use errors.Is() instead of os.IsNotExist()
The os.IsNotExist() function [1] predates the introduction of the
errors.Is() function [2] in Go 1.13 [3].  From Go >= 1.16, the
documentation explicitly recommends the use of errors.Is() instead of
os.IsNotExist() [4].

The Go implementation of Toolbx never used any Go older than 1.13 [5],
and currently it requires Go >= 1.21 [6].  So, there's no reason not to
use the more modern and recommended alternative.

[1] https://pkg.go.dev/os#IsNotExist

[2] https://pkg.go.dev/errors#Is

[3] https://go.dev/blog/go1.13-errors

[4] Go commit b641f0dcf48aa748
    https://github.com/golang/go/commit/b641f0dcf48aa748
    https://github.com/golang/go/issues/41122

[5] Commit d857471aa2
    https://github.com/containers/toolbox/commit/d857471aa2f233e5
    https://github.com/containers/toolbox/pull/318

[6] Commit 82e85bac9f
    https://github.com/containers/toolbox/commit/82e85bac9f5e69a5
    https://github.com/containers/toolbox/pull/1614

https://github.com/containers/toolbox/pull/1629
2025-04-28 13:39:49 +02:00
Debarshi Ray e9e77fb069 pkg/utils: Test PathExists
https://github.com/containers/toolbox/pull/1629
2025-04-28 13:29:28 +02:00
Debarshi Ray c4df57944e cmd/run: Style fixes
Fallout from d8289fb832 and
815d7f6035

https://github.com/containers/toolbox/pull/1628
2025-04-26 00:10:31 +02:00
Debarshi Ray 389216cdca cmd/initContainer: Tweak the debug logs for brevity
Debug logs are sweeter when they are shorter.

Fallout from 6e848b250b and
91a019bef6

https://github.com/containers/toolbox/pull/1628
2025-04-25 23:48:53 +02:00
Debarshi Ray fd427863b0 cmd/initContainer: Style fixes
Fallout from the following:
  * 7542f5fc86
  * 786723116c
  * 6e848b250b

https://github.com/containers/toolbox/pull/1628
2025-04-25 23:48:48 +02:00
Debarshi Ray 94a75d631b build: Bump github.com/NVIDIA/nvidia-container-toolkit to 1.17.4
... for CVE-2025-23359 or GHSA-4hmh-pm5p-9j7j.

The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1627
2025-04-23 03:06:16 +02:00
Debarshi Ray e824bf7216 build: Bump github.com/NVIDIA/go-nvlib to 0.7.1
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1626
2025-04-23 00:02:03 +02:00
Debarshi Ray ec286bb186 pkg/utils: Optimize getting the runtime directory
The runtime directory is needed a few times during the course of
commonly used Toolbx commands.  It's used at start-up for all commands
except 'completion' and 'init-container' to synchronize the invocation
of 'podman system migrate'.  The entry point (ie., 'init-container')
uses it to read the generated Container Device Interface specification
and create the initialization stamp file.  The 'enter' and 'run'
commands use it to write the CDI specification and twice to detect the
creation of the initialization stamp file.

Since the runtime directory is always the same within a process, there's
no need to repeatedly go through all the steps of parsing the user and
group IDs, creating the directory, setting its ownership, and logging
the name of directory.  Once the directory is successfully created, it's
path can be cached and returned for subsequent use.

In case an error occurred while setting up the runtime directory,
subsequent attempts to get it will go through all the steps again.  This
doesn't matter much in practice because toolbox(1) can't continue in the
absence of a working runtime directory.

https://github.com/containers/toolbox/pull/1624
2025-04-11 22:10:53 +02:00
Debarshi Ray 3321bb20b6 cmd/root: Style fix
Fallout from 4a1aa4652e and
c2ba67569b

https://github.com/containers/toolbox/pull/1623
2025-04-11 17:12:06 +02:00
Debarshi Ray fb4cb2eb90 cmd/run: Style fixes
Fallout from d8289fb832 and
815d7f6035

https://github.com/containers/toolbox/pull/1623
2025-04-11 17:11:35 +02:00
Debarshi Ray c2520f2016 .zuul: Enable testing on Fedora 42
https://github.com/containers/toolbox/pull/1619
2025-03-29 01:03:01 +01:00
Debarshi Ray 4f4c3c9d19 build: Bump github.com/NVIDIA/nvidia-container-toolkit to 1.17.3
... for CVE-2024-0135 or GHSA-9v84-cc9j-pxr6, CVE-2024-0136 or
GHSA-vcfp-63cx-4h59, and CVE-2024-0137 or GHSA-frhw-w3wm-6cw4.

The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1614
2025-01-31 00:24:26 +01:00
Debarshi Ray ebd2fc1f8b build: Bump github.com/NVIDIA/nvidia-container-toolkit to 1.17.2
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1614
2025-01-30 23:01:26 +01:00
Debarshi Ray 8b603ad05f build: Bump github.com/NVIDIA/nvidia-container-toolkit to 1.17.1
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1614
2025-01-30 21:36:14 +01:00
Debarshi Ray 82e85bac9f build: Bump github.com/NVIDIA/nvidia-container-toolkit to 1.17.0
... for CVE-2024-0134 or GHSA-7jm9-xpwx-v999.

NVIDIA Container Toolkit 1.17.0 requires Go >= 1.21, even though it's
not mentioned in its go.mod file [1].

The src/go.sum file was updated with 'go mod tidy'.

[1] https://github.com/NVIDIA/nvidia-container-toolkit/issues/886

https://github.com/containers/toolbox/pull/1614
2025-01-30 21:36:14 +01:00
Debarshi Ray 4717be5e23 build: Bump github.com/NVIDIA/go-nvlib to 0.7.0
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1614
2025-01-30 00:28:24 +01:00
Debarshi Ray 957601f1d8 build: Bump github.com/NVIDIA/go-nvml to 0.12.4-1
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1614
2025-01-29 21:20:28 +01:00
Debarshi Ray 85fcd6f4c7 build: Bump golang.org/x/sys to 0.26.0
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1613
2025-01-29 21:09:10 +01:00
Debarshi Ray 09773b9af2 build: Bump golang.org/x/sys to 0.25.0
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1613
2025-01-29 21:03:54 +01:00
Debarshi Ray bff269a9e9 build: Bump github.com/spf13/viper to 1.17.0
The indirect dependencies in the src/go.mod file, and the src/go.sum
file were updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1612
2025-01-27 18:46:01 +01:00
Debarshi Ray 5196d21294 build: Bump github.com/spf13/viper to 1.16.0
The indirect dependencies in the src/go.mod file, and the src/go.sum
file were updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1612
2025-01-27 17:58:27 +01:00