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

80 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
Ruixin Bao
6a3bb3fb46 syscontainer: let uninstall fail when name specified
Based on discussion https://github.com/projectatomic/atomic/issues/1199#issuecomment-369153184,
we want to disallow user to specify --name option for uninstalling system containers.

Instead, we should encourage user to delete container using atomic
containers delete or atomic uninstall NAME.

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

Closes: #1202
Approved by: giuseppe
2018-03-02 08:45:26 +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
6ce83c45e5 syscontainers: raise an error when run --name= is used
It is not supported by the OSTree storage.

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

Closes: #1186
Approved by: baude
2018-02-19 16:03:47 +00:00
Giuseppe Scrivano
71c258af4f syscontainers, run: automatically pull the image if missing
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1186
Approved by: baude
2018-02-19 16:03:47 +00:00
Giuseppe Scrivano
6eebb86402 atomic, run: implement --set option
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1186
Approved by: baude
2018-02-19 16:03:47 +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
Giuseppe Scrivano
1c877c5860 syscontainers: support credentials for accessing the source registry
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1505744

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

Closes: #1120
Approved by: ashcrow
2017-10-26 16:49:44 +00:00
baude
90bb2a02f4 Atomic/backends/_containers_storage.py: stop
Implement stop for a container.

Closes: #1100
Approved by: baude
2017-09-22 23:51:14 +00:00
Giuseppe Scrivano
e339dca935 ostree: image Size is the same as VirtualSize
Now "images list" reports the size again.

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

Closes: #1095
Approved by: ashcrow
2017-09-08 19:39:33 +00:00
baude
8323e9df07 Atomic/backends/_containers_storage.py: backend functions for containers
More advanced functions in the atomic cli need to have the backend functions
for things like has_container and inspect_container working correctly.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1093
Approved by: rhatdan
2017-09-07 22:19:45 +00:00
baude
f00b49b12e Atomic/backends/_containers_storage.py: Ensure size is reported correctly
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1094
Approved by: baude
2017-09-07 14:25:59 +00:00
baude
7d18f18849 Add prune for containers-storage
Add the ability to delete unneeded images across all
storage backends

Closes: #1091
Approved by: baude
2017-09-06 13:43:05 +00:00
baude
f2d77056f9 Atomic/backends/_containers_storage.py: Enable tagging
Enable tagging as a function on the backend.  This gives c-s parity
with the other backends where needed.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1092
Approved by: rhatdan
2017-09-06 10:17:30 +00:00
baude
5f4d4f7ff0 Delete: Add ability to delete images from container-storage
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1089
Approved by: baude
2017-09-05 14:11:43 +00:00
baude
057536cab4 Pull image to containers-storage
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1089
Approved by: baude
2017-09-05 14:11:43 +00:00
baude
93445eeb24 Atomic integration with kpod images and kpod ps
This allows you to see your images and containers across the
containers-storage backend and runc front-end. For example:

   CONTAINER ID IMAGE                NAME       COMMAND    CREATED          STATE      BACKEND    RUNTIME
   d6e7089cd9bc 15bc1f81701b0f19cacf adoring_bh /bin/true  2017-08-01 08:44 created    docker     docker
   3e8d4ab73739 15bc1f81701b0f19cacf awesome_wi /bin/true  2017-08-01 08:44 created    docker     docker
   061a9ca5d75d microsoft/azure-cli  reverent_e bash       2017-07-13 13:11 exited     docker     docker
   7ec00efa0138 babe9f398328af8bb1f6 dazzling_s /container 2017-07-06 09:07 exited     docker     docker
   2f6139e272fb babe9f398328af8bb1f6 kind_allen /container 2017-07-06 09:07 exited     docker     docker
   foobar       foobar:latest        foobar     /usr/bin/r 2017-08-08 15:04 running    ostree     runc
   foo          foo:latest           foo        /usr/bin/r 2017-08-08 15:16 failed     ostree     runc
   4261d79d6056 docker.io/library/re k8s_podsan ['/bin/sh' 2017-08-28 18:02 running    containers runc

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1084
Approved by: baude
2017-08-30 15:13:39 +00:00
Steve Milner
8ba150955a syscontainers: Give user info when run can not find the image
Originally an AttributeError was raised:

   Unable to find an image named net-snmpp in ostree
   Traceback (most recent call last):
     File "./atomic/Atomic/backends/_ostree.py", line 168, in run
       name = iobject.name
   AttributeError: 'NoneType' object has no attribute 'name'

Now the user is told why run failed:

   $ sudo atomic run --name=test --storage ostree --display net-snmp true
   $ sudo atomic run --name=test --storage ostree --display idontexist true
   Unable to find an image named idontexist in ostree
   $

Closes: #1075
Approved by: ashcrow
2017-08-29 07:11:54 +00:00
Giuseppe Scrivano
057d8a0aad syscontainers: add support for run
Differently than the Docker implementation, it allows
to run commands even if the container is not running yet.

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

Closes: #1075
Approved by: ashcrow
2017-08-29 07:11:54 +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
8028c33e00 Introduction of ContainersStorage backend
A new backend is being added to the Atomic CLI called "Containers Storage".  This commit
covers the addition of the backend itself.  The backend is only made available in the
atomic CLI if an export variable called 'DEV' is found.  For example:

sudo DEV=true atomic images list -a

Each method in the backend (with the exceptionof def available) raises an
UnderDevelopment Exception.  As the methods are developed, the exceptions will be removed.

Closes: #1038
Approved by: rhatdan
2017-06-28 15:34:36 +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
Giuseppe Scrivano
d6a50753ad images: show the virtual size for system containers
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1454996

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

Closes: #1029
Approved by: baude
2017-06-14 16:51:23 +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
Giuseppe Scrivano
eee8824bdf syscontainers: fix containers list --json
Regression introduced with commit 1f67164a96

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

Closes: #949
Approved by: baude
2017-03-29 13:44:47 +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