Commit Graph

44 Commits

Author SHA1 Message Date
Nalin Dahyabhai 945adfcd8d Check read-only stores when Putting new layers
When we try to Store.Put() a new layer, also check read-only layer
stores as part of verifying that the new layer's parent is known.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-10-03 09:43:49 -04:00
Nalin Dahyabhai eace836c44 Track the digests of "big data" items
Teach image and container store types to also track the digests of "big
data" items that we have them store.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-10-02 17:50:00 -04:00
Daniel J Walsh 232429cdea Merge pull request #107 from nalind/preallocate-slices
Preallocate some slices that we build up
2017-09-30 07:07:48 -04:00
Nalin Dahyabhai 2f258f168e Initialize Flags and BigDataSizes maps
When we read itms from disk, if maps in the structures are empty, they
won't be allocated as part of the decoding process.  When we
subsequently go to read or write something from such a map, make sure
it's been initialized.

Add some validation of names that we convert to file names, and of
digest values, so that we can be more precise about the error code we
return when there's a problem with the values.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-29 17:58:47 -04:00
Daniel J Walsh 64bf27465d Merge pull request #112 from rhatdan/config
Specify OverrideKernelCheck and Size in /etc/containers/storage.conf
2017-09-29 16:22:06 -04:00
Daniel J Walsh 5d183eb658 Specify OverrideKernelCheck and Size in /etc/containers/storage.conf
Allow users to specify the maximum size of a containers in the
/etc/containers/storage.conf file.  This will enable quota checking
in the drivers that support it.

Allowe users to OverrideKernelCheck to tell drivers to ignore kernel
version checks that indicate whether the driver is supported on that
kernel.  These checks do not make sense on older RHEL kernels, since
the driver support was back ported.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-29 16:16:59 -04:00
Nalin Dahyabhai 84922714d2 Merge pull request #108 from nalind/layerless-images
Stop rejecting creation of images with no layers
2017-09-29 16:16:54 -04:00
Nalin Dahyabhai 7ccd1bdeb2 Stop rejecting creation of images with no layers
We need to be able to create images which consist of just a list of
manifests, and those don't contain layers, so relax CreateImage()'s
requirement that a layer be specified.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-29 15:01:26 -04:00
Nalin Dahyabhai 1289ff09a7 Preallocate some slices that we build up
Take a guess at the final size of some slices that we build up item by
item, and try to allocate enough capacity for them before starting to
build them.  It's probably not a big speedup, though.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-29 15:00:59 -04:00
Nalin Dahyabhai a546c6d7a4 Also dedupe layer/image/container names at create
We already deduplicated names in Store.SetNames(), but we weren't also
doing that when creating layers, images, and containers, or in the
individual store SetNames() methods.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-29 15:00:09 -04:00
Daniel J Walsh 04c9124148 Start using drivers.Options for passing date to graphdrivers
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-19 21:15:29 +00:00
Nalin Dahyabhai 681e0e8d18 Update searching of read-only stores
Update searches of read-only layer and image stores to match naming
conventions in the updated Names() method.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-12 17:38:09 -04:00
Nalin Dahyabhai 6ca203850d Add a note about deduplication in SetNames()
The SetNames() method actually deduplicates the name list that it's
given, so make a note of that in the godoc.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-12 17:26:19 -04:00
Nalin Dahyabhai 63c2227dd7 Teach Store.Lookup() about read-only stores
The Store's Lookup() method didn't check for layers and images in
read-only locations, which it should have.  Correct that.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-12 17:26:19 -04:00
Nalin Dahyabhai 50a2d28674 Fix a locking error in Store.Names()
umohnani noticed that Store.Names() was hitting a deadlock - when
attempting to iterate through the concatenated list of read-write and
read-only image stores, the method was actually walking the list of
read-write and read-only layer stores a second time, so when it
attempted to obtain a lock on the first layer store, it would deadlock.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-12 17:26:19 -04:00
Daniel J Walsh f39066fe1b Update packages to match latest code in moby/pkg
Had to vendor in a new version of golang.org/x/net to build
Also had to make some changes to drivers to handle
archive.Reader -> io.Reader
archive.Archive -> io.ReadCloser

Also update .gitingore to ignore emacs files, containers-storage.*
and generated man pages.

Also no longer test travis against golang 1.7, cri-o, moby have also
done this.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-12 18:00:29 +00:00
Daniel J Walsh b4b03f3e95 Revert "RunRoot directory should be mounted private"
This reverts commit 05e45e0b08.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-11 19:41:23 +00:00
Daniel J Walsh 939210769a Merge pull request #93 from nalind/hide-substores
Remove direct access to substores from Store()
2017-09-01 17:31:34 -04:00
Nalin Dahyabhai 6986edce00 Create errors using "errors"
Use the standard library's "errors" package to create errors so that
backtraces in wrapped errors terminate at the point where the error was
first wrapped, and not at the line where we created the error, which
isn't as useful for troubleshooting.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-01 17:04:56 -04:00
Nalin Dahyabhai 1cfe27ed82 Remove direct access to substores from Store()
Remove methods that fetch the underlying layer, image, and container
store objects from the public Store interface.  They're still accessible
via type assertions, but ideally that's never going to be necessary.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-01 15:47:24 -04:00
Daniel J Walsh 05e45e0b08 RunRoot directory should be mounted private
We are leaking files into other mount namespaces, making the
runroot private might also improve performance.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-08-16 20:40:08 +00:00
Daniel J Walsh 7250a23f36 Do not default to overlay
We should default to "" and then allow the library to pick the
best driver for the particular distribution.  Picking overlay is
currently breaking cri-o on Centos and RHEL, since they don't
support overlay driver until 7.4 release.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-08-02 15:32:01 -04:00
Nalin Dahyabhai 30d40e3e57 Add godoc notes on locking and reexec
Add notes about the Store methods that return read-only and read-write
layer, image, and container stores, and how using the values they return
bypasses locking and synchronization.

Add notes to the methods which require that the reexec package was
initialized that the reexec package needs to be initialized from main().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-07-07 17:19:49 -04:00
Nalin Dahyabhai 17284cc062 When creating images, options are optional
Since ImageOptions are optional when calling a store's CreateImage()
method, we can't assume that there's a value there.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-06-23 14:13:16 -04:00
Daniel J Walsh 74bc9c18a3 Merge pull request #68 from nalind/creation-time-2
Allow setting the creation-date on images
2017-06-22 08:26:31 -04:00
Nalin Dahyabhai 1f7a56c869 Cache the digests, sizes, and compression type
Cache the digests and sizes of a diff, both compressed and uncompressed,
along with the type of compression detected for it, that's supplied to
ApplyDiff() or Put() in the layer structure, and add methods to find a
list of layers that match one or the other digest.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-06-20 12:30:28 -04:00
Nalin Dahyabhai a4c52f3316 Allow setting the creation-date on images
Add a field to ImageOptions that allows a caller to specify a date of
creation when calling CreateImage(), if there's a value in the image
metadata that would be more useful than the default (which is "now" at
the time CreateImage() is called).

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-06-20 11:59:28 -04:00
Nalin Dahyabhai fb0b0e7cfe Make Diff() methods take an optional *DiffOptions
Add an optional *DiffOptions parameter to Diff() methods (which can be
nil), to allow overriding of default behaviors.

At this time, that's just what type of compression is applied, if we
want something other than what was recorded when the diff was applied,
but we can add more later if needed.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-06-16 10:50:08 -04:00
Nalin Dahyabhai e84b264992 Use read-only interfaces for read-only stores
Use the read-only interfaces for accessing read-only layer and image
stores.  Mount, Unmount, and ApplyDiff modify the contents of the store,
so revert changes that made them inadvertently attempt to modify
read-only stores.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-06-12 16:31:19 -04:00
Nalin Dahyabhai a9b1fe6241 Add read-only layer/image/container stores
Implement read-only versions of layer and image store interfaces which
allocate read-only locks and which return errors whenever a write
function is called (which should only be possible after a type
assertion, since they're not part of the read-only interfaces).

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-06-12 16:31:19 -04:00
Nalin Dahyabhai 198f752fb5 Split layer and image stores into RO and RW kinds
Split the LayerStore and ImageStore interfaces into read-only and
write-only subset interfaces, and make the proper stores into unions of
the read-only and write-only method sets.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-06-12 10:44:36 -04:00
Dan Walsh bde1adc9b6 Some error return codes were accidently changed
Changes from ErrImageUnknown to  ErrIsNotImage is breaking protocol and has changed the
behaviour of buildah, Breaking previous behaviour.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2017-06-09 08:58:15 -04:00
Dan Walsh 2e359caf5a Support for additional roLayers and roImages
We are now allowing users to specify additional container storage directories in the
configuration.  We need to create a roLayer and roImage object for each additional
storage driver.  These stores are treated as reaonly.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2017-06-06 16:16:00 -04:00
Nalin Dahyabhai 29f53da34e Merge pull request #56 from rhatdan/LayerID
Add new function to return ContainerLayerID
2017-06-06 16:09:19 -04:00
Nalin Dahyabhai 235bf4b5ec Merge pull request #55 from rhatdan/save
Only touch when images, containers, layers save function called
2017-06-06 16:06:02 -04:00
Dan Walsh ae965ad5b5 Add better error reporting when layers are in use
We need to inform user what object is using a layer when returning and
error.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2017-06-06 15:53:27 -04:00
Dan Walsh ed2c381d8d Add new function to return ContainerLayerID
In order to get ROLayers to merge, we need to break
some functions into smaller subsets to not hold the locks long.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2017-06-03 07:26:04 -04:00
Dan Walsh 828ab642c8 We are not using rlstore in SetBigImageStore
So don't use it and take locks out on it.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2017-06-03 07:22:30 -04:00
Dan Walsh c496eac6c3 Only touch when images, containers, layers save function called
Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2017-06-02 16:20:00 -04:00
Nalin Dahyabhai 91a49bd8d2 Mark stores as modified by SetNames()
Use the lockfile to mark that a store's contents need to be reloaded by
other consumers whenever we call SetNames() to update a by-name index.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-06-02 13:23:01 -04:00
Nalin Dahyabhai 230b9ab91a Replace the build system
Replace the bundle-targeted build system with simpler Makefile targets
and fewer helper scripts.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-05-25 15:50:33 -04:00
Dan Walsh 119beac58d Add support for a toml config file
Container Storage is going to be shared by multiple tools.  Therefore
we don't want each one of these tools setting up its own container
storage.  This storage config can be shared between multiple users.
Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2017-05-24 15:14:38 -04:00
Dan Walsh 730fdd5893 Remove layer,image, container code that is not used
Lots of cut and pasted code that ends up doing nothing, but takes time
to process.
Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2017-05-17 07:42:46 -04:00
Dan Walsh 5531c8da65 Move storage/storage go objects to storage.
There is no reason for the extra directory level.

Also fixup some go lint issues
Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2017-05-16 17:25:11 -04:00