1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-06 21:45:24 +01:00
Commit Graph

150 Commits

Author SHA1 Message Date
Giuseppe Scrivano
ef871e7147 util: change RUNC and BWRAP_OCI env variable
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1171
Approved by: baude
2018-02-01 18:15:15 +00:00
Giuseppe Scrivano
7378da5ac4 util: look for runc under /usr/bin
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1171
Approved by: baude
2018-02-01 18:15:15 +00:00
Giuseppe Scrivano
38a2e54bd6 util: do not expect Registries in Docker info
upstream Docker has no support for additional registries, if that is
the case hardcode to ['docker.io'].

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

Closes: #1171
Approved by: baude
2018-02-01 18:15:15 +00:00
Alex Jia
772b8c9dc7 Atomic.util: delete extra comma in the skopeo_delete()
Signed-off-by: Alex Jia <ajia@redhat.com>

Closes: #1168
Approved by: giuseppe
2018-02-01 13:26:04 +00:00
Giuseppe Scrivano
e98ca9f929 util: ensure SkopeoError has msg
if skopeo doesn't include "msg=" in its error message, atomic fails
returning the wrong message.

Easily reproducible with:

SKOPEO_PATH=/bin/false atomic run foo

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2017-12-11 12:16:33 +01:00
Giuseppe Scrivano
50b0df1646 util: add list of capabilities
the capsh approach doesn't work on RHEL as the version of libcap is not
updated and doesn't know all the possible capabilities available on the
system.  This is the output I get with getpcaps on RHELAH 7.4.2:

Capabilities for `1': = cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,35,36+ep

Fallback to the capsh method if there will be more capabilities that we
know of, and hopefully libcap does.

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

Closes: #1130
Approved by: rhatdan
2017-12-05 13:15:54 +00:00
baude
e5124cc67f Atomic/util.py: Handle TOML
Make sure that when TOML input for registries is used,
it is parsed correctly.  Also, remain able to parse
YAML if still being used.

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

Closes: #1137
Approved by: rhatdan
2017-11-29 18:57:38 +00:00
baude
de599a72ee Atomic/util.py: Make image_by_name more specific
In image_by_name, if a given image has a registry name in it,
do not consider it equal to another image with the same name and
tag.

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

Closes: #1112
Approved by: baude
2017-11-29 16:41:32 +00:00
Giuseppe Scrivano
0435127de3 util: skopeo_copy supports src_creds
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1120
Approved by: ashcrow
2017-10-26 16:49:44 +00:00
Giuseppe Scrivano
25a5a15a31 util.py: add function for retrieving the known proc capabilities
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1119
Approved by: ashcrow
2017-10-26 13:38:40 +00:00
Steve Milner
b15a6668fe syscontainers: Remove skopeo prefixes
http: is now required by skopeo when working with insecure registries.
However, having the prefix causes other calls/tools problems. This
change strips off http:/https: from the image uri outside of skopeo
usage.

Signed-off-by: Steve Milner <smilner@redhat.com>

Closes: #1114
Approved by: giuseppe
2017-10-13 14:20:45 +00:00
baude
9cbe70c73f Typo fix on concatenation
Closes: #1088
Approved by: rhatdan
2017-09-01 14:09:24 +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
Giuseppe Scrivano
6ea8ea98da syscontainers: use Skopeo copy to pull images
New versions of Skopeo support "ostree" as a destination for copy.  The
missing layers are written directly to the OSTree storage without any
additional handling from atomic.

Check if the used version of Skopeo has support for ostree and use
"skopeo copy" in this case.  In future we might drop completely the
other code path and assume ostree is always supported.

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

Closes: #1082
Approved by: baude
2017-08-30 14:03:40 +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
69b5d607bc Atomic/util.py: Use tls-verify on skopeo subcommands
In order to avoid warnings from skopeo, we should be using
tls-verify on the skopeo subcommand (like copy) rather than
skopeo itself.

This was reported in issue #1067.

Closes: #1072
Approved by: rhatdan
2017-08-17 17:59:05 +00:00
baude
a8cb3861df Honor --gnupghome on push
The command switch for --gnupghome was not being honored when an atomic
push was being done.  We now export it to an os.environ so that skopeo
can use it.

Closes: #1071
Approved by: rhatdan
2017-08-17 14:24:23 +00:00
Giuseppe Scrivano
3e5c8f99e1 util: allow to override gomtree|bwrap_oci|runc|skopeo paths
It is easier to test different versions if we can override the
program used by an env variable.

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

Closes: #1043
Approved by: baude
2017-08-01 21:45:07 +00:00
Giuseppe Scrivano
e738c8d5ac util: fix typo
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1050
Approved by: rhatdan
2017-07-18 21:48:46 +00:00
Brent Baude
aa6356bf1e Atomic/util.py: decode registries information to utf-8
In Python3, we need to decode the data to utf-8 to produce
a string and a note a byte type.

Closes: #1011
Approved by: baude
2017-05-24 15:16:00 +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
3c0cbc69ea Incorporate registries parsing tool
Ideally atomic will be able to run multiple container
runtimes.  In and effort to do so, we must have a concept
of a global registries configuration file which will allow
us to pull images with atomic and skopeo. The tooling
that parses the global configuration file is:

https://github.com/projectatomic/registries

This is step one in the implementation of this tooling
and direction.

Closes: #1003
Approved by: rhatdan
2017-05-17 15:19:53 +00:00
Steve Milner
2760e30296 Atomic/util.py: Add no_proxy
http_proxy and https_proxy are currently supported in /etc/atomic.conf.
This change adds no_proxy support. no_proxy is for urls which should
not go through a proxy.

Closes: #999
Approved by: baude
2017-05-13 00:47:55 +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
6c047bac1a Atomic/syscontainers.py: Supress Error output
The syscontainers mount procedure follows a try and fallback approach.  If the
first attemp fails, it displays an error message to the user but then the
fallback attempt works.  This makes the user think the attempts failed.  So
not we supress the error message of the first attemp unless --debug is
provided.

Closes: #998
Approved by: baude
2017-05-09 15:55:52 +00:00
Brent Baude
5967f59efc Fix mount for ostree backends. Needed to make sure the cmd
threw a CalledProcessError.

Closes: #998
Approved by: baude
2017-05-09 15:55:52 +00:00
Tomas Tomecek
532787bcbe help: prefer help file over label
Fixes #939

Reference: https://pagure.io/atomic-wg/issue/256#comment-436537

* The command now prefers files over "help" label.
 * Help files can be one of:
  * help.1, README.md

Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>

Closes: #941
Approved by: rhatdan
2017-05-09 15:00:50 +00:00
Brent Baude
4a70354b6b Atomic/util.py: Check install against FQ name
In cases where a short-hand name is provided to run and the image
was installed under its fq_name, we should check againt the
fq_name as well when determining if it has been installed.

This was reported as issue #995

Closes: #996
Approved by: baude
2017-05-08 19:33:14 +00:00
Tomas Tomecek
a6d74441ad correct parameter name for InstallData
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>

Closes: #990
Approved by: giuseppe
2017-05-04 07:04:10 +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
Brent Baude
12d674f26e util: Don't try to create directories at module import time
We shouldn't do anything at module import time, as that happens during builds,
where we don't want to touch the host system (and may not have privileges to do
so).

This required some refactoring of the locking code too, as simply
instantiating the decorator was creating files too.

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

Closes: #966
Approved by: rhatdan
2017-04-13 19:29:39 +00:00
Brent Baude
2b744bfdbb Honor proxy usage
If HTTP[S]_PROXY is defined, honor it in python requests usage
as well as pass it on to skopeo.

If http[s]_proxy is defined in atomic.conf, use it; however, environment
variables will override these if defined.

Added --insecure to Atomic push so the user can override the logic
(or lack thereof) around deducing if a registry is insecure.  Also
needed for integration tests.

Closes: #964
Approved by: rhatdan
2017-04-13 16:13:07 +00:00
Giuseppe Scrivano
c9f0e9737b rpm_host_install.py: new file
Refactor the RPM generation code for system containers in a new file so
that it can be shared with the Docker backend.

For fully supporting the same /exports structure we will need to add the
support for reading the manifest.json file as well, but since the Docker
backend doesn't use --set for settings of the container, preprocessing
files won't be very useful.

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
153f4b077f Atomic/storage.py: Reduce number of times NoDockerDaemon is called
Instead of calling the default_docker_lib function a bunch of times
in the arg parser, we call it one and use the result in the parser.

Also, tighten up some exit conditions where self.d.close() is being
called when dockerd is not running.

Closes: #921
Approved by: rhatdan
2017-03-01 16:22:03 +00:00
Brent Baude
312685882d Atomic/util.py Fix Try/Catch exceptions for dockerd
Fix a cirucular dependancy in atomic storage reset where certain
functions require a dockerd but storage reset requires dockerd to
be stopped.
2017-02-28 14:11:32 -06:00
Brent Baude
7047b63d2b Atomic/util.py: default_docker detects wrong library BZ# 1381696
When Atomic unmount is called on an overlayfs based dockerd,
the default docker library is incorrectly determined resulting in
failures to unmount.

We now first ask the running dockerd what its root library directory
is and use that if dockerd is running.

This resolves https://bugzilla.redhat.com/show_bug.cgi?id=1381696

Closes: #912
Approved by: rhatdan
2017-02-24 17:41:59 +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
Aaron Weitekamp
df95392e3b fix re module bug
Closes: #891
Approved by: rhatdan
2017-02-14 15:14:13 +00:00
Giuseppe Scrivano
e14343b1fa syscontainers: allow --system without runc installed
Also change --user to work without bwrap-oci being installed

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

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

Closes: #868
Approved by: rhatdan
2017-02-12 17:13:07 +00:00
Brent Baude
b0cd19353e dbus: Add convenience method for scan results lookup
In the case of cockpit, it would be preferable to be able
to lookup scan results by a container or image's id.  If the
container or image has not been scanned, we throw an exception;
otherwise we return the resulting json file as a str.

One other possible exception can be thrown when attempting to read
the desired file from the filesystem.  If the file cannot be read,
an exception will be thrown.  Either way, it is a clear indicator
that the object needs to be scanned for fresh results.

The following is a simple *python* example:

from atomic_dbus_client import AtomicDBus
ad = AtomicDBus()
results = ad.GetScanResultsById('6858a846fb6b557331e068252fd910b5dc93f8e6341e641400bf4582dc34e10d')

Note the use of the full ID.  As of now, we only look up against the full id
as opposed to the short id form which is often used.

Closes: #874
Approved by: baude
2017-02-09 14:26:08 +00:00
Brent Baude
1bdd84a507 Improve pull error messaging
When a fq image name is used, the error messages contained the full
stderr formed by skopeo.  It was preferable to only show the msg
portion of the error.

Closes: #862
Approved by: baude
2017-02-02 22:36:06 +00:00
Brent Baude
167986a809 Add pull by digest unittests
Added two tests for pull by digest: one where the image is not
present and the other when it is.

Also, addressed review comments.

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
Aaron Weitekamp
ef8b07ef79 update default trust policy file
Signed-off-by: Aaron Weitekamp <aweiteka@redhat.com>

Closes: #822
Approved by: rhatdan
2017-01-16 14:27:00 +00:00
Aaron Weitekamp
8df71d7c6a extend image URI validation
Closes: #819
Approved by: rhatdan
2017-01-10 15:49:28 +00:00
Aaron Weitekamp
6dfc3ccd87 Validate reg input to trust add cmd
Signed-off-by: Aaron Weitekamp <aweiteka@redhat.com>

Closes: #816
Approved by: rhatdan
2017-01-09 13:58:16 +00:00
Dan Walsh
d6bdd78c8d Atomic storage reset does not work on docker-latest
This patch will allow user to specify the graphdriver on atomic reset

If /var/lib/docker or /var/lib/docker-latest is the only thing installed
it will reset the correct path.  If both exists or the user as chosen
a different location, the --graph option must be specified.

Closes: #745
Approved by: rhatdan
2016-12-12 19:17:19 +00:00
Brent Baude
e405c6a048 Refactor containers verb
With the exception of fstrim, the containers verb has now been
refactored.  It primarily now uses the containers object in its
implementation.

Closes: #792
Approved by: rhatdan
2016-12-09 14:05:49 +00:00
Brent Baude
dc30815599 Unify and refactor atomic verify
Using our refactoring model, verify is now streamlined. We no longer
compare base images as that is not currently possible for both
V1 and V2 schemas.

Verify will now always look at the release and version labels for
comparison.  Should those labels not exist, it will use the
manifest digest for ostree; and it will use the image IDs for
docker.

Closes: #785
Approved by: rhatdan
2016-12-07 15:18:22 +00:00