Skip to content

Commit

Permalink
Updated default registry to docker.io
Browse files Browse the repository at this point in the history
  • Loading branch information
Madeeks committed Jul 11, 2022
1 parent ccc44f6 commit 9808a4a
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 41 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed

- Changed the default registry to `docker.io`.
When the server is not entered as part of the image reference, the `sarus run` command first looks under `docker.io` repositories and, if the image is not available, falls back to images under the previous default server (`index.docker.io`). This is done to preserve compatibility with existing workflows.
The `sarus images` and `sarus rmi` commands treat images from `index.docker.io` as images from a 3rd party registry.
- If the image manifest obtained from a registry during a pull does not feature the `mediaType` property, Sarus now attempts to process the manifest as an OCI Manifest V1 instead of failing with an error.
- Updated recommended libnvidia-container version to 1.10.0
- Updated recommended NVIDIA Container Toolkit version to 1.10.0
Expand All @@ -16,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed

- Fixed an issue in the generation of manifest digests, where the digest result was incorrectly influenced by JSON formatting
- Fixed an inconsistency with Skopeo which was preventing to pull private images from Docker Hub


## [1.5.0]
Expand Down
13 changes: 11 additions & 2 deletions CI/src/integration_tests/test_command_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,24 @@ def _test_command_images_digests(self, image, expected_name, expected_tag, expec
def _test_command_images(self, is_centralized_repository):
expected_header = ["REPOSITORY", "TAG", "IMAGE", "ID", "CREATED", "SIZE", "SERVER"]

# import image (with fixed digest)
# pull image from default registry
util.pull_image_if_necessary(is_centralized_repository, "alpine")

# load image (with fixed digest)
image_archive = os.path.dirname(os.path.abspath(__file__)) + "/saved_image.tar"
util.load_image(is_centralized_repository, image_archive, self._IMAGE_NAME)

# header
actual_header = self._header_in_output_of_images_command(is_centralized_repository)
self.assertEqual(actual_header, expected_header)

# imported image
# pulled image from default registry
image_output = self._image_in_output_of_images_command(is_centralized_repository, False, "alpine", "latest", "")
self.assertEqual(image_output[0], "alpine")
self.assertEqual(image_output[1], "latest")
self.assertEqual(image_output[5], "docker.io")

# loaded image
image_output = self._image_in_output_of_images_command(is_centralized_repository, False, "load/library/loaded_image", "latest", "")
self.assertEqual(image_output[0], "load/library/loaded_image")
self.assertEqual(image_output[1], "latest")
Expand Down
5 changes: 5 additions & 0 deletions CI/src/integration_tests/test_command_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def test_command_run_with_local_repository(self):
def test_command_run_with_centralized_repository(self):
self._test_command_run(is_centralized_repository=True)

def test_fallback_on_legacy_default_server(self):
util.remove_image_if_necessary(is_centralized_repository=False, image="alpine")
util.pull_image_if_necessary(is_centralized_repository=False, image="index.docker.io/library/alpine")
assert util.run_image_and_get_prettyname(is_centralized_repository=False, image="alpine").startswith("Alpine Linux")

def test_workdir(self):
util.pull_image_if_necessary(is_centralized_repository=True, image=self.default_image)

Expand Down
17 changes: 10 additions & 7 deletions CI/src/integration_tests/test_error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_command_pull(self):
self._check(command, expected_message)

command = ["sarus", "pull", "invalid-image-1kds710dkj"]
expected_message = ("Failed to pull image 'index.docker.io/library/invalid-image-1kds710dkj:latest'"
expected_message = ("Failed to pull image 'docker.io/library/invalid-image-1kds710dkj:latest'"
"\nError reading manifest from registry."
"\nThe image may be private or not present in the remote registry."
"\nDid you perform a login with the proper credentials?"
Expand All @@ -142,7 +142,7 @@ def test_command_pull(self):
self._check(command, expected_message)

command = ["sarus", "pull", "ethcscs/private-example"]
expected_message = ("Failed to pull image 'index.docker.io/ethcscs/private-example:latest'"
expected_message = ("Failed to pull image 'docker.io/ethcscs/private-example:latest'"
"\nError reading manifest from registry."
"\nThe image may be private or not present in the remote registry."
"\nDid you perform a login with the proper credentials?"
Expand Down Expand Up @@ -203,7 +203,7 @@ def test_command_rmi(self):
self._check(command, expected_message)

command = ["sarus", "rmi", "invalid-image-9as7302j"]
expected_message = "Cannot find image 'index.docker.io/library/invalid-image-9as7302j:latest'"
expected_message = "Cannot find image 'docker.io/library/invalid-image-9as7302j:latest'"
self._check(command, expected_message)

def test_command_run(self):
Expand All @@ -216,20 +216,23 @@ def test_command_run(self):
self._check(command, expected_message)

command = ["sarus", "run", "not-available-image", "true"]
expected_message = "Specified image index.docker.io/library/not-available-image:latest is not available"
self._check(command, expected_message)
default_server_expected_message = ("Image docker.io/library/not-available-image:latest is not available. "
"Attempting to look for equivalent image in index.docker.io server repositories")
legacy_default_server_expected_message = "Image index.docker.io/library/not-available-image:latest is not available"
self._check(command, default_server_expected_message)
self._check(command, legacy_default_server_expected_message)

# Error message when running by digest and only corresponding tagged image is available
util.remove_image_if_necessary(is_centralized_repository=False,
image="quay.io/ethcscs/alpine@sha256:1775bebec23e1f3ce486989bfc9ff3c4e951690df84aa9f926497d82f2ffca9d")
util.pull_image_if_necessary(is_centralized_repository=False, image="quay.io/ethcscs/alpine:3.14")
command = ["sarus", "run", "quay.io/ethcscs/alpine@sha256:1775bebec23e1f3ce486989bfc9ff3c4e951690df84aa9f926497d82f2ffca9d", "true"]
expected_message = "Specified image quay.io/ethcscs/alpine@sha256:1775bebec23e1f3ce486989bfc9ff3c4e951690df84aa9f926497d82f2ffca9d is not available"
expected_message = "Image quay.io/ethcscs/alpine@sha256:1775bebec23e1f3ce486989bfc9ff3c4e951690df84aa9f926497d82f2ffca9d is not available"
self._check(command, expected_message)

# Error message when running by tag+digest and only corresponding tagged image is available
command = ["sarus", "run", "quay.io/ethcscs/alpine:3.14@sha256:1775bebec23e1f3ce486989bfc9ff3c4e951690df84aa9f926497d82f2ffca9d", "true"]
expected_message = "Specified image quay.io/ethcscs/alpine@sha256:1775bebec23e1f3ce486989bfc9ff3c4e951690df84aa9f926497d82f2ffca9d is not available"
expected_message = "Image quay.io/ethcscs/alpine@sha256:1775bebec23e1f3ce486989bfc9ff3c4e951690df84aa9f926497d82f2ffca9d is not available"
self._check(command, expected_message)

command = ["sarus", "run", "--invalid-option", "quay.io/ethcscs/alpine", "true"]
Expand Down
2 changes: 1 addition & 1 deletion doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ used in the scope of Sarus and throughout its documentation.
image belongs. This component is similar to a URL, but does not contain a
protocol specifier; it can specify a port number, separated by a colon
(for example ``test.registry.io:5000``). When a ``server`` component is
not specified in the command line, Sarus defaults to ``index.docker.io``
not specified in the command line, Sarus defaults to ``docker.io``
(Docker Hub).

The ``namespace`` component represents a namespace which may exist within
Expand Down
4 changes: 2 additions & 2 deletions doc/overview/local-repository.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions doc/quickstart/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Below is an example of some basic usage of Sarus:
.. code-block:: bash
$ sarus pull alpine
# image : index.docker.io/library/alpine:latest
# image : docker.io/library/alpine:latest
# cache directory : "/home/user/.sarus/cache"
# temp directory : "/tmp"
# images directory : "/home/user/.sarus/images"
Expand All @@ -103,11 +103,11 @@ Below is an example of some basic usage of Sarus:
Writing manifest to image destination
Storing signatures
> unpacking OCI image
> making squashfs image: "/home/user/.sarus/images/index.docker.io/library/alpine/latest.squashfs"
> making squashfs image: "/home/user/.sarus/images/docker.io/library/alpine/latest.squashfs"
$ sarus images
REPOSITORY TAG IMAGE ID CREATED SIZE SERVER
alpine latest a366738a1861 2022-05-25T09:19:59 2.59MB index.docker.io
alpine latest a366738a1861 2022-05-25T09:19:59 2.59MB docker.io
$ sarus run alpine cat /etc/os-release
NAME="Alpine Linux"
Expand Down
24 changes: 12 additions & 12 deletions doc/user/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ You can use :program:`sarus images` to list the images available on the system:
$ sarus images
REPOSITORY TAG IMAGE ID CREATED SIZE SERVER
<repo name>/hello-python 1.0 6bc9d2cd1831 2018-01-19T09:43:04 40.16MB index.docker.io
<repo name>/hello-python 1.0 6bc9d2cd1831 2018-01-19T09:43:04 40.16MB docker.io
4. Run the image at scale with Sarus
------------------------------------
Expand Down Expand Up @@ -331,7 +331,7 @@ separator:
.. code-block:: bash
$ sarus pull debian@sha256:039f72a400b48c272c6348f0a3f749509b18e611901a21379abc7eb6edd53392
# image : index.docker.io/library/debian@sha256:039f72a400b48c272c6348f0a3f749509b18e611901a21379abc7eb6edd53392
# image : docker.io/library/debian@sha256:039f72a400b48c272c6348f0a3f749509b18e611901a21379abc7eb6edd53392
# cache directory : "/home/<user>/.sarus/cache"
# temp directory : "/tmp"
# images directory : "/home/<user>/.sarus/images"
Expand All @@ -342,7 +342,7 @@ separator:
Writing manifest to image destination
Storing signatures
> unpacking OCI image
> make squashfs image: "/home/<user>/.sarus/images/index.docker.io/library/debian/sha256-039f72a400b48c272c6348f0a3f749509b18e611901a21379abc7eb6edd53392.squashfs"
> make squashfs image: "/home/<user>/.sarus/images/docker.io/library/debian/sha256-039f72a400b48c272c6348f0a3f749509b18e611901a21379abc7eb6edd53392.squashfs"
It is possible to combine tag and digest in the argument of the :program:`sarus pull`
command. In this case, Sarus proceeds to pull the image indicated by the digest
Expand All @@ -352,7 +352,7 @@ tools like Docker, Podman and Buildah:
.. code-block::
$ sarus pull alpine:3.15.2@sha256:73c155696fe65b68696e6ea24088693546ac468b3e14542f23f0efbde289cc97
# image : index.docker.io/library/alpine:3.15.2@sha256:73c155696fe65b68696e6ea24088693546ac468b3e14542f23f0efbde289cc97
# image : docker.io/library/alpine:3.15.2@sha256:73c155696fe65b68696e6ea24088693546ac468b3e14542f23f0efbde289cc97
# cache directory : "/home/<user>/.sarus/cache"
# temp directory : "/tmp"
# images directory : "/home/<user>/.sarus/images"
Expand All @@ -363,7 +363,7 @@ tools like Docker, Podman and Buildah:
Writing manifest to image destination
Storing signatures
> unpacking OCI image
> make squashfs image: "/home/<user>/.sarus/images/index.docker.io/library/alpine/sha256-73c155696fe65b68696e6ea24088693546ac468b3e14542f23f0efbde289cc97.squashfs"
> make squashfs image: "/home/<user>/.sarus/images/docker.io/library/alpine/sha256-73c155696fe65b68696e6ea24088693546ac468b3e14542f23f0efbde289cc97.squashfs"
Even if the tag is ignored by the pull, it can still serve as a visual aid for
for users writing or reading the command, helping to understand what image the
Expand Down Expand Up @@ -553,9 +553,9 @@ command:
$ sarus images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE SERVER
alpine latest sha256:73c155696fe65b68696e6ea24088693546ac468b3e14542f23f0efbde289cc97 e3671980822d 2022-03-25T13:17:13 2.61MB index.docker.io
fedora latest sha256:36af84ba69e21c9ef86a0424a090674c433b2b80c2462e57503886f1d823abe8 04d13a5c8de5 2022-03-25T13:17:57 50.03MB index.docker.io
ubuntu <none> sha256:dcc176d1ab45d154b767be03c703a35fe0df16cfb1cc7ea5dd3b6f9af99b6718 4f4768f23ea4 2022-03-25T13:21:40 26.41MB index.docker.io
alpine latest sha256:73c155696fe65b68696e6ea24088693546ac468b3e14542f23f0efbde289cc97 e3671980822d 2022-03-25T13:17:13 2.61MB docker.io
fedora latest sha256:36af84ba69e21c9ef86a0424a090674c433b2b80c2462e57503886f1d823abe8 04d13a5c8de5 2022-03-25T13:17:57 50.03MB docker.io
ubuntu <none> sha256:dcc176d1ab45d154b767be03c703a35fe0df16cfb1cc7ea5dd3b6f9af99b6718 4f4768f23ea4 2022-03-25T13:21:40 26.41MB docker.io
Running images by digest
------------------------
Expand All @@ -567,7 +567,7 @@ To run images pulled by digest, append the digest to the image name using
$ sarus images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE SERVER
alpine <none> sha256:73c155696fe65b68696e6ea24088693546ac468b3e14542f23f0efbde289cc97 e3671980822d 2022-03-25T14:28:45 2.61MB index.docker.io
alpine <none> sha256:73c155696fe65b68696e6ea24088693546ac468b3e14542f23f0efbde289cc97 e3671980822d 2022-03-25T14:28:45 2.61MB docker.io
$ sarus run alpine@sha256:73c155696fe65b68696e6ea24088693546ac468b3e14542f23f0efbde289cc97 cat /etc/os-release
NAME="Alpine Linux"
Expand Down Expand Up @@ -600,10 +600,10 @@ rmi` command:
$ sarus images
REPOSITORY TAG IMAGE ID CREATED SIZE SERVER
library/debian latest 6bc9d2cd1831 2018-01-31T14:11:27 40.17MB index.docker.io
library/debian latest 6bc9d2cd1831 2018-01-31T14:11:27 40.17MB docker.io
$ sarus rmi debian:latest
removed index.docker.io/library/debian/latest
removed docker.io/library/debian/latest
$ sarus images
REPOSITORY TAG IMAGE ID CREATED SIZE SERVER
Expand All @@ -627,7 +627,7 @@ To remove images pulled by digest, append the digest to the image name using
.. code-block::
$ sarus rmi ubuntu@sha256:dcc176d1ab45d154b767be03c703a35fe0df16cfb1cc7ea5dd3b6f9af99b6718
removed image index.docker.io/library/ubuntu@sha256:dcc176d1ab45d154b767be03c703a35fe0df16cfb1cc7ea5dd3b6f9af99b6718
removed image docker.io/library/ubuntu@sha256:dcc176d1ab45d154b767be03c703a35fe0df16cfb1cc7ea5dd3b6f9af99b6718
.. _user-environment:
Expand Down
14 changes: 11 additions & 3 deletions src/cli/CommandRun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ class CommandRun : public Command {
}

void verifyThatImageIsAvailable() const {
cli::utility::printLog( boost::format("Verifying that image %s is available") % conf->getImageFile(),
cli::utility::printLog( boost::format("Verifying that image %s is available") % conf->imageReference,
common::LogLevel::INFO);
// switch to user filesystem identity to make sure we can access images on root_squashed filesystems
auto rootIdentity = common::UserIdentity{};
Expand All @@ -459,8 +459,15 @@ class CommandRun : public Command {
try {
auto imageStore = image_manager::ImageStore(conf);
auto image = imageStore.findImage(conf->imageReference);
if(!image && conf->imageReference.server == common::ImageReference::DEFAULT_SERVER) {
auto message = boost::format("Image %s is not available. Attempting to look for equivalent image in %s server repositories")
% conf->imageReference % common::ImageReference::LEGACY_DEFAULT_SERVER;
cli::utility::printLog(message.str(), common::LogLevel::GENERAL, std::cerr);
conf->imageReference.server = common::ImageReference::LEGACY_DEFAULT_SERVER;
image = imageStore.findImage(conf->imageReference);
}
if(!image) {
auto message = boost::format("Specified image %s is not available") % conf->imageReference;
auto message = boost::format("Image %s is not available") % conf->imageReference;
cli::utility::printLog(message.str(), common::LogLevel::GENERAL, std::cerr);
exit(EXIT_FAILURE);
}
Expand All @@ -471,7 +478,8 @@ class CommandRun : public Command {

common::setFilesystemUid(rootIdentity);

cli::utility::printLog("Successfully verified that image is available", common::LogLevel::INFO);
cli::utility::printLog(boost::format("Successfully verified that image %s is available") % conf->imageReference,
common::LogLevel::INFO);
}

void verifyImageBackingFiles(const common::SarusImage& image) const {
Expand Down
Loading

0 comments on commit 9808a4a

Please sign in to comment.