Commit Graph

26512 Commits

Author SHA1 Message Date
Nalin Dahyabhai 4867edfac1 Drop our dependency on github.com/containers/image
Drop our dependency on the image library's manifest package by requiring
that callers pass its Digest() function to us as a callback.  This makes
our CLI test/diagnostic tool calculate digests of s1 manifests
incorrectly, but that's not something that we were testing.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-03-06 15:06:34 -05:00
Nalin Dahyabhai 8caea6f790 imageStore: remove compatibity hacks for adding digests
Remove compatibility hacks for older versions which didn't track size or
digest information for big data items, hopefully without any impact.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-03-06 15:03:26 -05:00
Daniel J Walsh e894bc99f4 Merge pull request #291 from nalind/locktest
lockfile: add some unit tests, don't return ENOSPC from Modified()
2019-02-28 15:19:34 -05:00
Nalin Dahyabhai 9b7711f6e5 lockfile: add some unit tests
These aren't exhaustive, but they're something.

Also change Modified() to not return an ENOSPC error when the length of
the last-writer ID doesn't match the one we'd use, since it's enough
that it's different from the one we'd use, whatever its length.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-28 13:03:18 -05:00
Daniel J Walsh 170c44b9bb Merge pull request #289 from nalind/rlock2
Clarify Locker.Locked(), and switch some locks to read-only
2019-02-27 21:40:40 -05:00
Nalin Dahyabhai 07291d4599 lockfile_unix: add a couple of additional safety checks
Panic in Touch() if we're not holding a write lock in one of our
threads.  Hopefully that's the one we're being called from, but we
don't guarantee that.

Panic in Modified() if we're not holding some kind of lock.

As with Locked(), this doesn't keep us from getting a false positive
when it's a different thread that holds the lock, but it's better than
nothing.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 15:51:48 -05:00
Nalin Dahyabhai 1e477d7670 Lock the mounts list with its own lockfile
Separate loading and saving the mountpoints.json table out of the main
layer load/save paths so that they can be called independently, so that
we can mount and unmount layers (which requires that we update that
information) when the layer list itself may only be held with a read
lock.

The new loadMounts() and saveMounts() methods need to be called only for
read-write layer stores.  Callers that just refer to the mount
information can take a read lock on the mounts information, but callers
that modify the mount information need to acquire a write lock.

Break the unwritten "stores don't manage their own locks" rule and have
the layer store handle managing the lock for the mountpoints list, with
the understanding that the layer store's lock will always have been
acquired before we try to take the mounts lock.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 14:19:53 -05:00
Nalin Dahyabhai a94e9f082c Update a comment
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 14:19:53 -05:00
Nalin Dahyabhai d05040c6f8 layers/images: don't try to clean up with just a read-only lock
Don't attempt to remove conflicting names or finish layer cleanups if we
only have a read-only lock on layer or image stores, since doing either
means we'd have to modify the list of layers or images, and our lock
that we've obtained doesn't allow us to do that.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 14:19:53 -05:00
Nalin Dahyabhai 8f82704478 Switch to read-only locks in some places
In Store methods that don't expect to change state, use a read lock.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 14:19:53 -05:00
Nalin Dahyabhai 53047554b5 Locker.Locked(): clarify that we're checking for write locks
Clarify that Locker.Locked() checks if we have a write lock, since
that's what we care about whenever we check it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 14:19:50 -05:00
Nalin Dahyabhai 6275d3a46a CLI helper: print backtraces with errors
Print backtrace information when displaying an error returned by our
API, to make troubleshooting tests a bit easier.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 14:19:15 -05:00
Nalin Dahyabhai 21b224ad35 abs.bats: don't forget to shut things down after the test
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 14:19:15 -05:00
Nalin Dahyabhai 728ecb57b7 stores.bats: hard fail if we unexpected can't use read-only stores
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 14:19:15 -05:00
Nalin Dahyabhai e67527b100 Bump GITVALIDATE_EPOCH
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-26 14:19:15 -05:00
Valentin Rothberg 87dccb39cf lockfile: use a sync.RWMutex
Use a `sync.RWMutex` to synchronize the lockfile within the same process
space.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-02-26 14:19:15 -05:00
Daniel J Walsh fd807855f5 Merge pull request #288 from nalind/abs
GetStore(): resolve passed-in paths to absolute paths
2019-02-18 17:00:56 -05:00
Nalin Dahyabhai eea5437dd6 GetStore(): resolve passed-in paths to absolute paths
Resolve passed-in locations to absolute paths at startup.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-18 11:23:05 -05:00
Daniel J Walsh a5c9fca23e Merge pull request #287 from vrothberg/bump-to-1.10
Bump to 1.10
2019-02-17 08:21:38 -05:00
Valentin Rothberg 7e967a4f77 Move to v1.11-dev
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-02-16 10:04:19 +01:00
Valentin Rothberg 597826a67f Bump to v1.10
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-02-16 10:02:48 +01:00
Daniel J Walsh 991142152b Merge pull request #278 from vrothberg/rw-lock
reader-writer file locks
2019-02-15 12:05:53 -05:00
Valentin Rothberg 9edc133e83 enable parallel blob reads
Enable executing parallel `GetBlob()` executions in containers/image by
using reader-lock acquisitions in `ImageBigData()` and `Diff()`.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-02-15 15:00:37 +01:00
Valentin Rothberg a1db08dcd3 lockfile: implement reader-writer locks
Implement reader-writer locks to allow allow multiple readers to hold
the lock in parallel.

* The locks are still based on fcntl(2).

* Changing the lock from a reader to a writer and vice versa will block
  on the syscall.

* A writer lock can be held only by one process.  To protect against
  concurrent accesses by gourtines within the same process space, use a
  writer mutex.

* Extend the Locker interface with the `RLock()` method to acquire a
  reader lock.  If the lock is set to be read-only, all calls to
  `Lock()` will be redirected to `RLock()`.  A reader lock is only
  released via fcntl(2) when all gourtines within the same process space
  have unlocked it.  This is done via an internal counter which is
  protected (among other things) by an internal state mutex.

* Panic on violations of the lock protocol, namely when calling
  `Unlock()` on an unlocked lock.  This helps detecting violations in
  the code but also protects the storage from corruption.  Doing this
  has revealed some bugs fixed in ealier commits.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-02-15 09:49:44 +01:00
Valentin Rothberg 60f9bfbb4c avoid `defer x.Unlock()` pattern in loops
Deferring method calls on loop variables must be avoided by all means as
the calls will be invoked on the last item of the loop.

The intermediate fix used in this commit is to allocate a new variable
on the heap for each loop iteration.  An example transformation is:

FROM:
for _, x := range x_slice {
	x.Lock()
	defer x.Unlock()
}

TO:
for _, x_itr := range x_slice {
	x := x_itr
	x.Lock()
	defer x.Unlock()
}

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-02-15 09:49:44 +01:00
Daniel J Walsh 1a384fa95a Merge pull request #286 from nalind/override-kernel-check-legacy
Make use of overlay.override_kernel_check a warning instead of an error
2019-02-12 21:59:13 -08:00
Nalin Dahyabhai 5beb6822aa Make use of overlay.override_kernel_check a warning instead of an error
When we removed all traces of override_kernel_check, we created a
situation where older configuration files would suddenly start causing
us to emit an error at startup.  Soften that to a warning, for now at
least.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-12 13:58:36 -05:00
Nalin Dahyabhai cdad472cd1 Merge pull request #284 from nalind/always-digest
images: always set Digest if we have digests
2019-02-07 16:55:58 -05:00
Nalin Dahyabhai deccda4889 images: always set Digest if we have digests
Make sure that an Image that has at least one digest always has a
populated Digest field.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-07 14:07:16 -05:00
Daniel J Walsh 451cafb934 Merge pull request #283 from nalind/multiple-manifests
Teach images to hold multiple manifests
2019-02-07 09:38:16 -08:00
Nalin Dahyabhai 1d3cd27a15 Update generated files
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-07 10:27:36 -05:00
Nalin Dahyabhai 254fdbe4b3 Teach images to hold multiple manifests
Change how we compute digests for BigData items with names that start
with "manifest" so that we use the image library's manifest.Digest()
function, which knows how to preprocess schema1 manifests to get the
right value, instead of just trying to finesse it.

Track the digests of multiple manifest-named items for images.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-07 10:27:36 -05:00
Nalin Dahyabhai 7cf8d0e271 image-by-digest.bats: print output
Display the output from commands before we check their exit status, so
that we can see what they output if a check fails.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-06 10:04:37 -05:00
Nalin Dahyabhai 008312e079 Vendor github.com/containers/image
We use the image library's reference parser and manifest digester.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-06 10:04:37 -05:00
Daniel J Walsh f5909997b8 Merge pull request #282 from nalind/reload-errors
Don't ignore errors reloading layer/image/container lists
2019-02-05 10:44:36 -08:00
Nalin Dahyabhai 6a06c068f1 Don't ignore errors reloading layer/image/container lists
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-02-05 10:19:46 -05:00
Daniel J Walsh c6ddf3f10f Merge pull request #281 from umohnani8/config
Move structs for storage.conf to pkg/config
2019-02-04 13:54:50 -05:00
Urvashi Mohnani c109ea9158 Move structs for storage.conf to pkg/config
Need to access the storage structs in the machine-config
operator code for container runtime configuration but
with it being in store.go, it is pullng in way too many
dependencies. Moving it out to a separate package cuts down
the dependencies by a huge amount.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2019-02-03 21:21:32 -05:00
Daniel J Walsh 0324d909d7 Merge pull request #279 from rhatdan/master
Bump to v1.9
2019-02-01 10:13:25 -05:00
Daniel J Walsh 954c83a5e4 Move to v1.10-dev
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-02-01 12:50:55 +00:00
Daniel J Walsh d62efa2837 Bump to v1.9
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-02-01 12:50:38 +00:00
Daniel J Walsh f8a018cba1 Merge pull request #274 from rhatdan/copy
Move copytar functions from buildah to storage
2019-02-01 13:49:24 +01:00
Daniel J Walsh c1016b55ce Move copytar functions from buildah to storage
We want to use these functions in both podman and buildah
So move them out of buidlah into storage.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-01-31 15:26:03 +00:00
Daniel J Walsh 51738f3a5f Merge pull request #277 from rhatdan/version
Bump to version 1.8
2019-01-21 21:08:30 -05:00
Daniel J Walsh d251ec67d3 Move to v1.9-dev
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-01-21 21:07:15 -05:00
Daniel J Walsh 561c77b70e Bump to v1.8 2019-01-21 21:06:07 -05:00
Daniel J Walsh 82851b9c2f Merge pull request #273 from rhatdan/master
vndr opencontainers/selinux
2019-01-21 16:36:05 -05:00
Valentin Rothberg 31991cbed1 Merge pull request #275 from giuseppe/disable-usingmetacopy-for-rootless
overlay: do not attempt metacopyup when using a mount program
2019-01-21 15:40:26 +01:00
Giuseppe Scrivano 333d6704a2 overlay: do not attempt metacopyup when using a mount program
Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-01-21 10:10:25 +01:00
Daniel J Walsh 15a6cc9f28 vndr opencontainers/selinux
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-01-18 15:09:39 -05:00