summaryrefslogtreecommitdiff
path: root/libpod
Commit message (Collapse)AuthorAge
* Include the rejected reference when parsing it fails in pullRefPairsFromRefNamesMiloslav Trmač2018-08-01
| | | | | | | | | This will make any failures easier to attribute to the cause. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1176 Approved by: rhatdan
* Add --force to podman umount to force the unmounting of the rootfsDaniel J Walsh2018-08-01
| | | | | | | | | | | | podman umount will currently only unmount file system if not other process is using it, otherwise the umount decrements the container storage to indicate that the caller is no longer using the mount point, once the count gets to 0, the file system is actually unmounted. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #1184 Approved by: TomSweeneyRedHat
* Ensure container and pod refresh picks up a StateMatthew Heon2018-07-31
| | | | | | | | | | | | refresh() is the only major command we had that did not perform a sync before running, and thus was not guaranteed to pick up a good copy of the state. Fix this by updating the state before a refresh(). Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1186 Approved by: rhatdan
* Fix build on non-linux platformsMatthew Heon2018-07-31
| | | | | | | Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1186 Approved by: rhatdan
* Rework state testing to allow State structs to be emptyMatthew Heon2018-07-31
| | | | | | | | | | | Pod and container State structs are now allowed to be empty on first being retrieved from the database. Rework pod and container equality functions used in testing to account for this change. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1186 Approved by: rhatdan
* Add additional comments on accessing state in APIMatthew Heon2018-07-31
| | | | | | | | | | | The new state changes are potentially confusing to people writing API functions on containers or pods. Add comments to the structs on how to safely use them. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1186 Approved by: rhatdan
* Do not fetch pod and ctr State on retrieval in BoltMatthew Heon2018-07-31
| | | | | | | | | | | | | | | | | It's not necessary to fill in state immediately, as we'll be overwriting it on any API call accessing it thanks to syncContainer(). It is also causing races when we fetch it without holding the container lock (which syncContainer() does). As such, just don't retrieve the state on initial pull from the database with Bolt. Also, refactor some Linux-specific netns handling functions out of container_internal_linux.go into boltdb_linux.go. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1186 Approved by: rhatdan
* network: add support for rootless network with slirp4netnsGiuseppe Scrivano2018-07-31
| | | | | | | | | | | slirp4netns is required to setup the network namespace: https://github.com/rootless-containers/slirp4netns Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1156 Approved by: rhatdan
* podman rmi shouldn't delete named referenced imagesumohnani82018-07-28
| | | | | | | | | | | If an image is created from another and it is deleted, only delete the actual image and not the parent images if the parent images have names/references. Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #1174 Approved by: mheon
* Add pod pause/unpausehaircommander2018-07-27
| | | | | | | | | | | Added Pause() and Unpause() to libpod/pod.go Added man pages, tests and completions Signed-off-by: haircommander <pehunt@redhat.com> Closes: #1126 Approved by: rhatdan
* Fix handling of Linux network namespacesMatthew Heon2018-07-27
| | | | | | | | | | | | | | | | | | | The CNI plugins upstream removed their network namespace creation code, making it a test package only. Copy it into our repository and slightly modify it for our use (most notably, use MNT_DETACH when unmounting namespaces). This new CNI code splits closing and unmounting network namespaces, which allows us to greatly reduce the number of occasions on which we call teardownNetwork() and make more errors in that function fatal instead of warnings. Instead, we can call Close() and just close the open file descriptor in cases where the namespace has already been cleaned up. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1165 Approved by: baude
* Use the Linux version BoltState.getContainerFromDB on all platforms.Miloslav Trmač2018-07-26
| | | | | | | | | | | | | | | This just muves the Linux implementation, unchanged, to the platform-agnostic file. Should not change behavior on Linux. On non-Linux platforms, reading containers from BoltDB now works (and rejects containers with namespace data). The checkRuntimeConfig validation ensures that each BoltDB database is only used on one platform, so network namespaces should never exist in non-Linux BoltDB files. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1115 Approved by: rhatdan
* Split parseNetNSBoltData from BoltState.getContainerFromDBMiloslav Trmač2018-07-26
| | | | | | | | | | | | | | This is the actual platform-specific part of getContainerFromDB. Factor it out, unchanged, on Linux. On other platforms, introduce a stub which fails if any data exists; this stub is not yet called. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1115 Approved by: rhatdan
* Use testify/require in a few places to avoid panics in testsMiloslav Trmač2018-07-26
| | | | | | | Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1115 Approved by: rhatdan
* Skip unit tests which require storage when not running as rootMiloslav Trmač2018-07-26
| | | | | | | | | | | | | | | | On macOS NewImageRuntimeFromOptions fails with chown EPERM because the "vfs" driver tries to chown its home to root:root 0700; in fact running as root seems to be a generic requirement. So, skip the tests if not running as root. (This could maybe benefit from an extra state, maybe an environment variable like RUNNING_IN_CI, to make sure the tests are actually run often enough.) Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1115 Approved by: rhatdan
* vendor latest containers/psgoValentin Rothberg2018-07-26
| | | | | | | Signed-off-by: Valentin Rothberg <vrothberg@suse.com> Closes: #1162 Approved by: rhatdan
* Merge pull request #1158 from mheon/prevent_multiple_boltdb_connsMatthew Heon2018-07-26
|\ | | | | Add a mutex to BoltDB state to prevent lock issues
| * Add a mutex to BoltDB state to prevent lock issuesMatthew Heon2018-07-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Per https://www.sqlite.org/src/artifact/c230a7a24?ln=994-1081, POSIX file advisory locks are unsafe to use within a single process if multiple file descriptors are open for the same file. Unfortunately, this has a strong potential to happen for multithreaded usage of libpod, and could result in DB corruption. To prevent this, wrap all access to BoltDB within a single libpod instance in a mutex to ensure concurrent access cannot occur. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* | Added pod restarthaircommander2018-07-25
| | | | | | | | | | | | | | | | | | With tests, man page and completions. Signed-off-by: haircommander <pehunt@redhat.com> Closes: #1152 Approved by: rhatdan
* | Added pod.Restart() functionality to libpod.haircommander2018-07-25
|/ | | | | | | | | | | Moved contents of RestartWithTimeout to restartWithTimeout in container_internal to be able to call restart without locking in function. Refactored startNode to be able to either start or restart a node. Built pod Restart() with new startNode with refresh true. Signed-off-by: haircommander <pehunt@redhat.com> Closes: #1152 Approved by: rhatdan
* Update comments in BoltDB and In-Memory statesMatthew Heon2018-07-24
| | | | | | | Better explain the inner workings of both state types in comments to make reviews and changes easier. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Add missing runtime.go lines to set namespaceMatthew Heon2018-07-24
| | | | | | Also add namespace to inspect output to verify its presence Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Address first round of review commentsMatthew Heon2018-07-24
| | | | Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Set namespace for new pods/containers based on runtimeMatthew Heon2018-07-24
| | | | | | | | New containers and pods will default to the namespace of the runtime, but this can be overridden by With... options if desired. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Add --namespace flag to PodmanMatthew Heon2018-07-24
| | | | | | | Allows joining libpod to a specific namespace when running a Podman command. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Update documentation for the State interfaceMatthew Heon2018-07-24
| | | | | | | Include details on how namespaces interact with the state. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Ensure pods are part of the set namespace when addedMatthew Heon2018-07-24
| | | | Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Enforce namespace checks on container addMatthew Heon2018-07-24
| | | | Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Add tests for state namespacingMatthew Heon2018-07-24
| | | | Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Add namespaces to in memory stateMatthew Heon2018-07-24
| | | | Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Untested implementation of namespaced BoltDB accessMatthew Heon2018-07-24
| | | | | | | | | | | All BoltDB access and update functions now understand namespaces. Accessing containers outside of your namespace will produce errors, except for Lookup and All functions, which will perform their tasks only on containers within your namespace. The "" namespace remains a reserved, no-restrictions namespace. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Add constraint that dependencies must be in the same nsMatthew Heon2018-07-24
| | | | | | | Dependency containers must be in the same namespace, to ensure there are never problems resolving a dependency. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Add namespaces and initial constraints to databaseMatthew Heon2018-07-24
| | | | | | | | Add basic awareness of namespaces to the database. As part of this, add constraints so containers can only be added to pods in the same namespace. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Add container and pod namespaces to configsMatthew Heon2018-07-24
| | | | | | | Libpod namespaces are a way to logically separate groups of pods and containers within the state. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
* Update container Mounted() and Mountpoint() functionsMatthew Heon2018-07-24
| | | | | | | | | | | | | | | | Addresses a regression in `podman mount` due to our mount changes to allow concurrency by letting c/storage handle mounting and unmounting. Combine Mounted() and Mountpoint() into one function and query c/storage directly to ensure we get accurate information. Fixes: #1143 Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1144 Approved by: baude
* Use the result of reference.Parse when checking for digests.Miloslav Trmač2018-07-23
| | | | | | | | | | | | No need to do a separate string search when reference.Parse has already determined this. Changes behavior: non-SHA256 digest formats are now recognized as well. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Make refNamesFromPossiblyUnqualifiedName independent from ImageMiloslav Trmač2018-07-23
| | | | | | | | | | | ... which finally makes it very easy to add comprehensive tests; so do that. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Make Image.HasShaInInputName to an independent local functionMiloslav Trmač2018-07-23
| | | | | | | | | | | | The functionality only depends on Image.InputName, and we will want to make the only user of this independent of the fairly complex Image type. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Split createNamesToPull into ref{Names,Pairs}FromPossiblyUnqualifiedNameMiloslav Trmač2018-07-23
| | | | | | | | | | | | | | One part creates []*pullRefName; the other just trivially converts it into []*pullRefPair. Also use much more explicit names to explain the functionality. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Rename local variables in Runtime.pullRefPairsFromRefNamesMiloslav Trmač2018-07-23
| | | | | | | | | | | ... to be more conventional. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Split Runtime.pullRefPairsFromRefNames from Image.createNamesToPullMiloslav Trmač2018-07-23
| | | | | | | | | | | This will have another user shortly. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Rename nameToPull to pullRefNameMiloslav Trmač2018-07-23
| | | | | | | | | | | | We will use it not only in createNamesToPull, but also in getPullListFromRef soon. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Rename pullStruct to pullRefPairMiloslav Trmač2018-07-23
| | | | | | | | | | | | "Struct" is meaningless, and we will need the "reference pair" mentioned to distinguish srcRef+dstRef from srcRef+dstName. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Replace optional nameToPull.shaPullName with mandatory dstNameMiloslav Trmač2018-07-23
| | | | | | | | | | | | | This consolidates the shaPullName logic into a single place, (and eliminates the unclear shaPullName member name completely). The resulting nameToPull will shortly be more generally useful. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Introduce nameToPull, move shaPullName in thereMiloslav Trmač2018-07-23
| | | | | | | | | | | | | | | | | shaPullName is only used internally in createNamesToPull; so, introduce a nameToPull as a variant of pullStruct which has shaPullName (and does not have destRef). Eventually, we want to split pullStruct preparation into easily-testable store-independent name preparation, and a store-dependent and difficult-to-test but trivial conversion using StorageTransport.ParseStoreReference. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Split normalizeTag from Image.TagImageMiloslav Trmač2018-07-23
| | | | | | | | | | | ... so that it can be tested without side effects, and add the tests. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Remove Image.isShortNameMiloslav Trmač2018-07-23
| | | | | | | | | | | | It has no users, and it depends on the incorrect imageParts.hasRegistry. So, just drop it instead of worrying whether it is OK to change its semantics. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Inline getTags into its only userMiloslav Trmač2018-07-23
| | | | | | | | | | | | This also eliminates a duplicate call to reference.Parse() and removes an impossible erorr path. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Add unit tests for imagePartsMiloslav Trmač2018-07-23
| | | | | | | Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
* Merge pull request #1103 from haircommander/load_dockerlessMatthew Heon2018-07-20
|\ | | | | Podman load/tag/save prepends localhost when no registry is present