1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-06 12:45:57 +01:00

57 Commits

Author SHA1 Message Date
Giuseppe Scrivano
b507039153 atomic: honor UNINSTALL after stop of a container
Honor the UNINSTALL label after the specified container was stopped.

Introduced by: 18959843d5

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1576285

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1242
Approved by: rhatdan
2018-06-28 07:48:53 +00:00
Giuseppe Scrivano
18959843d5 atomic: uninstall checks for container existance before rm'ng it
a container might be deleted by the stop label, if it was started with
--rm.  Check for its presence before attempting to delete it.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1576285

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1235
Approved by: rhatdan
2018-05-10 16:46:30 +00:00
Giuseppe Scrivano
ee63a4be01 docker: propagate args from uninstall to stop
so that it is possible to uninstall a running container:

Closes: https://github.com/projectatomic/atomic/issues/1221

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1229
Approved by: rhatdan
2018-04-16 17:53:26 +00:00
Giuseppe Scrivano
ba23e76924 install: support multiple containers per image
Change the install data format to keep a list of containers for each
image installed, so that multiple containers for the same image can be
installed and uninstalled.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1559935

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1214
Approved by: baude
2018-03-27 13:06:11 +00:00
Giuseppe Scrivano
83fce8f33a images: add cache for dangling images
do not reload the list of all the images every time we check if an image
is dangling.  This makes "images list" extremely slow when used on the
Docker backend.

On my system (with ~100 images), this patch brings down the wall clock
from ~10 seconds to ~0.5 seconds:

$ /usr/bin/time -v ./atomic images list -a 2>&1 | grep "wall clock"
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:09.84

to:

$ /usr/bin/time -v ./atomic images list -a 2>&1 | grep "wall clock"
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.58

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1200
Approved by: rhatdan
2018-02-28 14:42:34 +00:00
Giuseppe Scrivano
e3bde4c094 docker: implement validate_layer
use the implementation of validate_image_manifest and
adapt it to be used in place of validate_layer.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1150
Approved by: rhatdan
2018-01-05 09:35:43 +00:00
Giuseppe Scrivano
0fbd768d50 verify: move Docker specific code to backends/_docker.py
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1150
Approved by: rhatdan
2018-01-05 09:35:43 +00:00
Giuseppe Scrivano
30c9504f6d docker: support credentials for accessing the source registry
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1120
Approved by: ashcrow
2017-10-26 16:49:44 +00:00
Yu Qi Zhang
14e878dbfc Fix tests for f26
Fix test failures after updating papr to test with f26 atomic/cloud
images instead of f25, with the following changes:

1. Remove dependency on docker hub tester image. Instead, mimic
what ostree/rpm-ostree does and use a recursive .papr.sh script
to install the necessary packages to the base f26 image in the
fedora registry. This fixes tests on the atomic host since python3.6
is being used, and prevents future tests from testing the wrong
version. (Note this is slightly slower due to having to install
packages during the test rather than using a pre-built image).

2. Fix some pylint errors, and mask others for now

3. Fix failing integration tests due to inter-test interference

4. Remove unnecessary deepcopy in container filter

5. Add compatibility for both c-s-s and d-s-s in storage

6. Update expected sha256 values for dockertar test

Remaining issues:

1. test_storage should possibly be reworked. The current test
setup is conflicting with the new default of overlay as a driver.
For now, the test for generated d-s-s is disabled.

2. some storage commands are still using "docker-storage-setup"
instead of "container-storage-setup". There is a backward
compatible check in place that should be reworked in the future

3. some masked pylint errors should be further investigated

4. keep the dockerfile for the project atomic tester image for now
(bump to 26), since its a little easier and faster to set up with

Signed-off-by: Yu Qi Zhang <jerzhang@redhat.com>

Closes: #1076
Approved by: baude
2017-08-23 18:33:48 +00:00
baude
37ba27992f Atomic/backends/_docker.py: Correct NoneType error (BZ #1481967)
When wanting to run a command in a already running container,
a NoneType error was being thrown when the image lookup
failed.

This was reported in BZ #1481967

Closes: #1069
Approved by: rhatdan
2017-08-16 18:33:59 +00:00
Giuseppe Scrivano
f3c6b8bb74 uninstall: inhibit UNINSTALL if there are running containers
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1456451

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1050
Approved by: rhatdan
2017-07-18 21:48:46 +00:00
Brent Baude
69f6d52370 Atomic/install.py: Don't write the install data if the install fails
A bug was reported in issue #1022 where if the atomic install data failed,
the installation data was still written allowing the user to proceed
with an atomic run.

Disabling test_install.sh until i can follow up with Thomas.

Closes: #1025
Approved by: baude
2017-06-21 20:09:14 +00:00
Brent Baude
e45ad08c8a Atomic/backends/_docker.py: Correct run flow
As pointed out in issue #1023, when you run an interactive
container and then subsequently run it with commands, you can
get a case where the container is running.  If you run another
image that will end up using the same container name but is born
of a different image, you get confusion.

In this case, we adopt the --replace function as we did with earlier
run/image mix-ups.

Closes: #1026
Approved by: baude
2017-06-13 16:26:05 +00:00
Brent Baude
2dfeae1356 Atomic/backends/_docker.py: Error prevention with atomic run
There were two primary cases where a secondary atomic run with a command
would trigger an exception.  The first was reported in
https://github.com/projectatomic/atomic/issues/1006. Basically it can
be summarized as:

```
atomic run registry.fedoraproject.org/fedora:25 date  # works fine
atomic run registry.fedoraproject.org/fedora:26 date  # tries to run in the existing f25 container
```

The second case is as simple as:

```
atomic run registry.fedoraproject.org/fedora:25 date  # works fine
atomic run registry.fedoraproject.org/fedora:25 date  # fails
```

This fails because atomic starts the stopped f25 container and then attempts a docker exec.  The
exec fails because the 'date' command is short-lived and the container exits prior to the exec
being run.

We now catch those exceptions and notify the user.  We added a `--replace` option to run where
atomic will now delete the container in question and re-run it from the correct image.

Closes: #1019
Approved by: baude
2017-05-31 19:20:25 +00:00
Brent Baude
45ff2fdd0b Atomic/tag.py: Fix tag to work with dockerd, invalid images BZ #1454656
The atomic tag function was not working correctly for docker images
in the dockerd.  Also, when attempting to tag an image from one
backend into another, we didn't handle the error correctly.  This should
not work.

Add integration tests for tagging invalid images, dockerd, and ostree.

This should fix BZ #1454656.

Closes: #1014
Approved by: baude
2017-05-25 13:40:44 +00:00
Brent Baude
324ea57020 Do not strip port for insecure check
When checking if a registry is insecure, we should not be stripping
the port from the registry name.

Closes: #1012
Approved by: rhatdan
2017-05-23 17:41:28 +00:00
Brent Baude
dbc34c7123 Atomic/util.py: Add logic to install lookup for shortnames
If a shortname is used to run an image, we need to transform the short
name into the fq-name when doing the lookup in the installed images
data.

Reported in BZ #1454292

Closes: #1010
Approved by: baude
2017-05-23 14:04:19 +00:00
Brent Baude
77ef28f6b8 Re-pulling image error should exit 0
Bugzilla #1430708 recommends that if an atomic user attempts to pull
an image that is already present, we should not exit with a '1' which
indicates a failure; rather a 0.

Closes: #997
Approved by: baude
2017-05-12 14:58:32 +00:00
Brent Baude
11f6154951 Allow mount/unmount without active dockerd
As requested in BZ #1447848, if a ostree mount is desired, we should
not block on requiring an active dockerd.  Same for unmount.

Closes: #998
Approved by: baude
2017-05-09 15:55:52 +00:00
Brent Baude
35dee59096 Atomic/backends/_docker.py: Fix uninstall
For some reason when shorthand is used to add a list and str/unicode,
a type Error is not thrown where shorthand is cmd += foo versus
cmd = cmd + foo.  Reverting to the long hand appears to resolve issue
https://github.com/projectatomic/atomic/issues/986

Closes: #987
Approved by: baude
2017-05-01 19:32:29 +00:00
Tomas Tomecek
e93b8319ad implement install --storage=docker --system-package=yes
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>

Closes: #955
Approved by: baude
2017-04-28 22:52:40 +00:00
Tomas Tomecek
1938ec3108 docker,uninstall: correct cmd manipulation
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>

Closes: #955
Approved by: baude
2017-04-28 22:52:40 +00:00
Brent Baude
4eaab31ccb Add integrations tests for atomic_dbus_client.py
We need to make sure the atomic_dbus_client code works and if something
in atomic_dbus.py changes, the client should either be updated or still
work.

Closes: #975
Approved by: rhatdan
2017-04-21 20:12:06 +00:00
Giuseppe Scrivano
8edf49ebea backends: add tag_image method
and add the implementation for the Docker and the OSTree backends.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #958
Approved by: rhatdan
2017-04-12 21:33:58 +00:00
Brent Baude
d5d1eb8b4c Always use fq names for dest image
Bugzilla 1437447 has brought up an issue where if a user runs:

atomic pull rhel7

The resulting image in dockerd is docker.io/rhel7. The Atomic CLI
does tell skopeo the right information"

/usr/bin/skopeo --debug --policy=/etc/containers/policy.json --debug copy --remove-signatures docker://registry.access.redhat.com/rhel7:latest docker-daemon:rhel7:latest

But somewhere along the line, we think in skopeo, docker.io is prepending to the destination
image name.  One way to resolve this is to always use the fq name for the destination and not
what the user wanted.

This is a change in the default behaviour of atomic and I am not sure I am confortable with this.  But
given that we have several folks on PTO or travelling, I'm putting this PR together so that
if we decide this is the proper route for fixing, it will be done.

Closes: #959
Approved by: baude
2017-04-05 15:00:39 +00:00
Brent Baude
1b216a4919 Atomic/install.py: Record installs for later use
When installing an image, we now write a small bit of json
to /var/lib/atomic/install.json.  The json format is:

{
	<image_name>: {
			     id: <image_id>,
			     install_date: <install_date_in_utc
			 }
}

This will be used in update, run, etc to ensure that any image
with an INSTALL label is first installed.

Closes: #950
Approved by: giuseppe
2017-03-28 19:10:57 +00:00
Brent Baude
1f67164a96 Fix outdated container image message (BZ 1434430)
When running an image with atomic run, if the container already exists,
we were accidently displaying a message stating that the container's
image was old.  This was due to an invalid comparison between the container's
image id and the image's id.  The comparison was failing because we were
comparing two different variables and not the ids.

This was reported in bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1434430

Closes: #945
Approved by: rhatdan
2017-03-21 17:54:06 +00:00
Brent Baude
ce57e8e43d Atomic/update.py: Updating a local image
If the image is built (and updated) locally, we need to handle this
differently than if the image came from a registry.  We now
can try/except our way through things and properly handle.

Closes: #938
Approved by: rhatdan
2017-03-16 13:45:32 +00:00
Brent Baude
f836bf82c4 Re-add check latest
Prior to refactoring, we had a check_latest method that would check
to see if the image being used by container was the latest image
by simply comparing hash IDs.

Adding this back in and refactoring into docker.py.

Closes: #938
Approved by: rhatdan
2017-03-16 13:45:32 +00:00
Brent Baude
4e781bf777 Running command inside running container fails
An exception was being thrown when trying to run a command inside
an already running container.  For example:

sudo atomic run foobar echo true

The problem was a lack of a setter for user_command in the container
object as well as some mishandled string <-> list conversions.

Closes: #938
Approved by: rhatdan
2017-03-16 13:45:32 +00:00
Brent Baude
cc0919c408 Adding base dbus integration tests
The following integration tests have been added:

* ScanList
* ImagePull
* ImageUpdate
* ImageUpate when at latest
* ImagePull when already at latest
* Run
* ContainersDelete
* ContainersDelete when container doesnt exist

Closes: #904
Approved by: rhatdan
2017-02-22 15:11:40 +00:00
Brent Baude
23f4bc9143 Fix uninstall bug: BZ 1425495
The bug https://bugzilla.redhat.com/show_bug.cgi?id=1425495 demostrates
a case where atomic attempts to "add" a list and str resulting in a
TypeError exception.  This should resolve that BZ.

Closes: #903
Approved by: rhatdan
2017-02-21 21:57:26 +00:00
Brent Baude
8fafc5feeb Account for API Changes in docker-py-2
The new 2.x version of the docker python API has non-backward
compatible changes.  These changes are described here:

https://docker-py.readthedocs.io/en/stable/change-log.html#breaking-changes

We need to account for docker.Client and docker.APIClient as well
as changes in the way kwargs are handled.  Also, it appears the
AutoVersion method is deprecated.

Closes: #894
Approved by: rhatdan
2017-02-21 14:17:51 +00:00
Brent Baude
ed9eaf2e55 Fix Stop Regression: BZ #1422448
BZ #1422448 actually points out one regression and one
bug related to atomic stop. The BZ itself points out
a TypeError exception in the code when trying to glue
together a python list and str.

Then the atomic stop command was failling in the case where a
STOP label was defined and it uses the variable $NAME resulting
in a subprocess exception.

The self.name variable was not being set by set_args after
refactoring occured.  Ideally, this should all be moved
into the image|container object handling but for now we
just handle it in set_args.

Also added a test in test_display to catch any future
regressions.

Closes: #899
Approved by: rhatdan
2017-02-20 20:37:38 +00:00
Giuseppe Scrivano
26df3c1296 docker: do not raise exception if the image is not found
Solves this issue:

Namespace(_class=<class 'Atomic.install.Install'>, args=[], assumeyes=False, debug=True, display=False, func='install', image='localhost:5000/busybox', name=None, opt1=None, opt2=None, opt3=None, remote=None, setvalues=None, storage=None, system=False, user=False)
'NoneType' object has no attribute '__getitem__'
Traceback (most recent call last):
  File "./atomic", line 188, in <module>
    sys.exit(_func())
  File "/home/gscrivano/src/atomic/Atomic/install.py", line 112, in install
    img_obj = be.has_image(self.image)
  File "/home/gscrivano/src/atomic/Atomic/backends/_docker.py", line 75, in has_image
    return self._make_image(img, self._inspect_image(img), deep=True)
  File "/home/gscrivano/src/atomic/Atomic/backends/_docker.py", line 127, in _make_image
    img_obj.id = img_struct['Id']
TypeError: 'NoneType' object has no attribute '__getitem__'

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #889
Approved by: rhatdan
2017-02-16 14:36:05 +00:00
Brent Baude
5cd25b9076 Refactor uninstall and add options
Refactor the uninstall class to use the backends, container and image
objects.

Add --display so one can run atomic uninstall --display <image>
and see what the outcome would be. This will be helpful in integration
testing and was discussed in BZ https://bugzilla.redhat.com/show_bug.cgi?id=1248038.

Add --storage option so users can dictate priority when uninstalling
an image.  This also mimics the newest install class as well.

Closes: #888
Approved by: giuseppe
2017-02-15 09:50:55 +00:00
Brent Baude
ca09ee877c Atomic/update.py: Bug fix and enable dbus
There was a bug in the update code where passing the
kwargs and the named variable force resulted in a TypeError
for multiple values existing.

Fixed by not passing the force keyword to _docker.py and
extracting the keyword from the kwargs.

Closes: #881
Approved by: rhatdan
2017-02-12 16:06:00 +00:00
Brent Baude
71735cb6af Ensure dbus diff works
Closes: #873
Approved by: rhatdan
2017-02-12 05:59:20 +00:00
Brent Baude
b9119dd037 dbus: Ensure Run() and ContainersDelete() work
Closes: #873
Approved by: rhatdan
2017-02-12 05:59:20 +00:00
Brent Baude
2ebeb1decd Fix run behavior
There were bugs in the run behavior in several scenarios:

* running an image with a command
* running a container that is stopped with and without a command
* running a container that is running with and without a command

Closes: #880
Approved by: rhatdan
2017-02-08 00:38:38 +00:00
Brent Baude
02bd134f1c Add --storage to install|run
To have parity function with pull, we need to add --storage
to install and run.  This allows for overriding when atomic.type
is defined.  For example, if you pull an image that has
atomic.type=system but you really want to store it
on the docker backend.

Closes: #861
Approved by: baude
2017-02-04 17:05:24 +00:00
Brent Baude
3d2acc23e8 Detect and install systemcontainer images
If an image from a registry has a label like:

    atomic.type=system

the Atomic CLI will now detect that prior to pulling
the image.  It will then switch the backend storage
to ostree.  In the case of install, it will both
pull to ostree and install it.

If the backend is switched, a message informing the user
as such will be shown.

The detection and switch of the backend can be overriden
 with the --storage option.

The following is an example of install:

$ sudo atomic install atomic-registry.usersys.redhat.com:5000/brentbaude/helloworld:latest

Note: Switching from the 'docker' backend to the 'ostree' backend based on the 'atomic.type' label in the image.  You can use --storage to override this behaviour.

Extracting to /var/lib/containers/atomic/helloworld.0
systemctl daemon-reload
systemctl enable helloworld

$ sudo ./atomic images list
   REPOSITORY                                                      TAG      IMAGE ID       CREATED            VIRTUAL SIZE   TYPE
   atomic-registry.usersys.redhat.com:5000/brentbaude/helloworld   latest   0056366e4ebd   2017-02-01 18:04                  ostree

$ sudo ./atomic containers list -a
   CONTAINER ID IMAGE                COMMAND              CREATED          STATE     BACKEND    RUNTIME
   helloworld   atomic-registry.user /usr/bin/run.sh      2017-02-01 18:04 failed    ostree     runc

Closes: #861
Approved by: baude
2017-02-04 17:05:24 +00:00
Brent Baude
048fced244 Fix Delete errors with images and containers
Fix a slew of issues related to deletion of images and containers.  Also
added --assume_yes to be consistent with other commands.  This will benefit
dbus interaction as well given that we do not want confirmation occuring
over dbus.

Issues that were fixed:
 * Proper catch and error for trying to delete all images|containers when no images|containers exist
 * Catch and error when no image|container is given by user and no --all
 * when --storage and --all are used, only images|containers in that backend are now deleted
 * when --all is given but not --storage, all images|containers from all backends are now deleted.
 * Fixed logical error when deleting containers
 * Deletion of images|containers now is consistent in its confirm and abort messages.

Added unittests.

Closes: #864
Approved by: rhatdan
2017-02-04 11:18:49 +00:00
Dharmit Shah
29c53498a3 Atomic/backends/_docker.py: Modify check_args to check for '--security-opt label=disable'
`docker-run` man page on Fedora 25 and CentOS 7 states `label=disable`
as one of the security options. However, we check for `label:disable`
only. This commit should help us check for both

Closes: #863
Approved by: rhatdan
2017-02-04 10:47:06 +00:00
Brent Baude
b564751c01 Atomic/pull.py: Pull by Digest
Users wish to be able to pull images by digest.  This can be
done by docker and therefore parity is preferred.  The request
is described in https://github.com/projectatomic/atomic/issues/691.

$ atomic pull busybox@sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912
Pulling docker.io/busybox@sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912 ...
Copying blob sha256:56bec22e355981d8ba0878c6c2f23b21f422f30ab0aba188b54f1ffeff59c190
 495.23 KB / 652.49 KB [=========================================>-------------]
Copying config sha256:e02e811dd08fd49e7f6032625495118e63f597eb150403d02e3238af1df240ba
 0 B / 1.43 KB [---------------------------------------------------------------]
Writing manifest to image destination
Storing signatures
 1.43 KB / 1.43 KB [===========================================================]
$ docker images
REPOSITORY                         TAG                                                                IMAGE ID            CREATED             SIZE
docker.io/busybox                  29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912   e02e811dd08f        3 months ago        1.093 MB

Note how the tag is populated with the digest.  Docker's default behaviour is
to populate the tag with nothing.  We cannot currently replicate that exactly.

Closes: #856
Approved by: baude
2017-02-01 20:02:00 +00:00
Brent Baude
f79d56bd13 Disconnect backends
Ideally, the atomic CLI should be able to operate independently
of the backends it supports.  For example, if dockerd is inactive,
the ostree backend and atomic cli should still work.

This requires some tweaking to the backendutils code and the work
flow.  We also need to specifically know if the user passes
--storage so that we treat that as an explicit override.  The work
flow is now roughly:

* a default storage can be defined in atomic.conf (was always this way)
* if not defined, defaults to docker.
* if --storage is passed, treat explictly and fail if cannot execute
* if no --storage is specified, use default.  if default is not available, move
 onto the next backend.
2017-01-25 19:07:20 -06:00
Brent Baude
c05fd38a58 Atomic/backends/_docker.py: Fix regression
Fix regression related to atomic run <image> in the case the image
has already been run and a container is still around with the same
name as <image>.

Closes: #843
Approved by: rhatdan
2017-01-20 15:11:37 +00:00
Brent Baude
623e57c8a6 Atomic/backends/_docker.py: Throw better error when dockerd not running
When using the Atomic CLI and dockerd wasn't running, the error was
not informative enough.

https://github.com/projectatomic/atomic/issues/831

Closes: #841
Approved by: rhatdan
2017-01-19 16:07:24 +00:00
Brent Baude
c7aafb3314 Refactor Pull, Update, Install, Run
Refactor several of the atomic verbs and subverbs to take advantage
of object refactoring.

Also, do not pull images with skopeo if the local image is already
at the latest.

$ sudo python ./atomic --debug pull busybox
Namespace(_class=<class 'Atomic.pull.Pull'>, assumeyes=False, debug=True, func='pull_image', image='busybox', reg_type=None, storage='docker')
Latest version of busybox already present.

Closes: #825
Approved by: baude
2017-01-17 22:16:36 +00:00
Brent Baude
9f6612a9a2 Refactor atomic stop
Refactoring of atomic stop to use container objects and the new backend
methods.

Closes: #798
Approved by: rhatdan
2016-12-14 15:45:39 +00:00