Skip to content

Commit

Permalink
Merge pull request containers#13329 from mheon/bump_401
Browse files Browse the repository at this point in the history
Bump to v4.0.1
  • Loading branch information
openshift-merge-robot authored Feb 23, 2022
2 parents 172b745 + cfcc0d6 commit 49d511b
Show file tree
Hide file tree
Showing 32 changed files with 313 additions and 171 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ MANDIR ?= ${PREFIX}/share/man
SHAREDIR_CONTAINERS ?= ${PREFIX}/share/containers
ETCDIR ?= ${PREFIX}/etc
TMPFILESDIR ?= ${PREFIX}/lib/tmpfiles.d
MODULESLOADDIR ?= ${PREFIX}/lib/modules-load.d
SYSTEMDDIR ?= ${PREFIX}/lib/systemd/system
USERSYSTEMDDIR ?= ${PREFIX}/lib/systemd/user
REMOTETAGS ?= remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp
Expand Down Expand Up @@ -779,6 +780,11 @@ install.bin:
install ${SELINUXOPT} -m 755 -d ${DESTDIR}${TMPFILESDIR}
install ${SELINUXOPT} -m 644 contrib/tmpfile/podman.conf ${DESTDIR}${TMPFILESDIR}/podman.conf

.PHONY: install.modules-load
install.modules-load: # This should only be used by distros which might use iptables-legacy, this is not needed on RHEL
install ${SELINUXOPT} -m 755 -d ${DESTDIR}${MODULESLOADDIR}
install ${SELINUXOPT} -m 644 contrib/modules-load.d/podman-iptables.conf ${DESTDIR}${MODULESLOADDIR}/podman-iptables.conf

.PHONY: install.man
install.man:
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man1
Expand Down
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Notes

## 4.0.1
### Bugfixes
- Fixed a bug where the `podman play kube` command did not honor the `mountPropagation` field in Pod YAML ([#13322](https://github.com/containers/podman/issues/13322)).
- Fixed a bug where the `--build=false` option to `podman play kube` was not honored ([#13285](https://github.com/containers/podman/issues/13285)).
- Fixed a bug where a container using volumes from another container (via `--volumes-from`) could, under certain circumstances, exit with errors that it could not delete some volumes if the other container did not exit before it ([#12808](https://github.com/containers/podman/issues/12808)).
- Fixed a bug where the `CONTAINERS_CONF` environment variable was not propagated to Conmon, which could result in Podman cleanup processes being run with incorrect configurations.

## 4.0.0
### Features
- Podman has seen an extensive rewrite of its network stack to add support for Netavark, a new tool for configuring container networks, in addition to the existing CNI stack. Netavark will be default on new installations when it is available.
Expand Down
8 changes: 8 additions & 0 deletions cmd/podman/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func parseCommands() *cobra.Command {
}
parent.AddCommand(c.Command)

c.Command.SetFlagErrorFunc(flagErrorFuncfunc)

// - templates need to be set here, as PersistentPreRunE() is
// not called when --help is used.
// - rootCmd uses cobra default template not ours
Expand All @@ -84,5 +86,11 @@ func parseCommands() *cobra.Command {
os.Exit(1)
}

rootCmd.SetFlagErrorFunc(flagErrorFuncfunc)
return rootCmd
}

func flagErrorFuncfunc(c *cobra.Command, e error) error {
e = fmt.Errorf("%w\nSee '%s --help'", e, c.CommandPath())
return e
}
6 changes: 5 additions & 1 deletion cmd/podman/play/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type playKubeOptionsWrapper struct {
TLSVerifyCLI bool
CredentialsCLI string
StartCLI bool
BuildCLI bool
}

var (
Expand Down Expand Up @@ -117,7 +118,7 @@ func init() {
_ = kubeCmd.RegisterFlagCompletionFunc(configmapFlagName, completion.AutocompleteDefault)

buildFlagName := "build"
flags.BoolVar(&kubeOptions.Build, buildFlagName, false, "Build all images in a YAML (given Containerfiles exist)")
flags.BoolVar(&kubeOptions.BuildCLI, buildFlagName, false, "Build all images in a YAML (given Containerfiles exist)")
}

if !registry.IsRemote() {
Expand All @@ -138,6 +139,9 @@ func kube(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("start") {
kubeOptions.Start = types.NewOptionalBool(kubeOptions.StartCLI)
}
if cmd.Flags().Changed("build") {
kubeOptions.Build = types.NewOptionalBool(kubeOptions.BuildCLI)
}
if kubeOptions.Authfile != "" {
if _, err := os.Stat(kubeOptions.Authfile); err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions contrib/modules-load.d/podman-iptables.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# On fedora 36 ip_tables is no longer auto loaded and rootless user have no permsissions to load it.
# When we have actual nftables support in the future we might want to revisit this.
# If you use iptables-nft this is not needed.
ip_tables
ip6_tables
5 changes: 3 additions & 2 deletions docs/source/markdown/podman-play-kube.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ like:
```

The build will consider `foobar` to be the context directory for the build. If there is an image in local storage
called `foobar`, the image will not be built unless the `--build` flag is used.
called `foobar`, the image will not be built unless the `--build` flag is used. Use `--build=false` to completely
disable builds.

`Kubernetes ConfigMap`

Expand Down Expand Up @@ -115,7 +116,7 @@ environment variable. `export REGISTRY_AUTH_FILE=path`

#### **--build**

Build images even if they are found in the local storage.
Build images even if they are found in the local storage. Use `--build=false` to completely disable builds.

#### **--cert-dir**=*path*

Expand Down
11 changes: 11 additions & 0 deletions libpod/container_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ func (c *Container) Inspect(size bool) (*define.InspectContainerData, error) {
return c.inspectLocked(size)
}

func (c *Container) volumesFrom() ([]string, error) {
ctrSpec, err := c.specFromState()
if err != nil {
return nil, err
}
if ctrs, ok := ctrSpec.Annotations[define.InspectAnnotationVolumesFrom]; ok {
return strings.Split(ctrs, ","), nil
}
return nil, nil
}

func (c *Container) getContainerInspectData(size bool, driverData *define.DriverData) (*define.InspectContainerData, error) {
config := c.config
runtimeInfo := c.state
Expand Down
2 changes: 1 addition & 1 deletion libpod/networking_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (r *RootlessNetNS) Cleanup(runtime *Runtime) error {
// only if the netns is empty we know that we do not need cleanup
return c.state.NetNS != nil
}
ctrs, err := runtime.GetContainersWithoutLock(activeNetns)
ctrs, err := runtime.GetContainers(activeNetns)
if err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions libpod/oci_conmon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ func (r *ConmonOCIRuntime) configureConmonEnv(ctr *Container, runtimeDir string)
env = append(env, e)
}
}
conf, ok := os.LookupEnv("CONTAINERS_CONF")
if ok {
env = append(env, fmt.Sprintf("CONTAINERS_CONF=%s", conf))
}
env = append(env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir))
env = append(env, fmt.Sprintf("_CONTAINERS_USERNS_CONFIGURED=%s", os.Getenv("_CONTAINERS_USERNS_CONFIGURED")))
env = append(env, fmt.Sprintf("_CONTAINERS_ROOTLESS_UID=%s", os.Getenv("_CONTAINERS_ROOTLESS_UID")))
Expand Down
11 changes: 0 additions & 11 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"regexp"
"strconv"
"strings"
"sync"
"syscall"
"time"

Expand Down Expand Up @@ -109,7 +108,6 @@ type Runtime struct {
// and remains true until the runtime is shut down (rendering its
// storage unusable). When valid is false, the runtime cannot be used.
valid bool
lock sync.RWMutex

// mechanism to read and write even logs
eventer events.Eventer
Expand Down Expand Up @@ -713,9 +711,6 @@ func (r *Runtime) TmpDir() (string, error) {
// Note that the returned value is not a copy and must hence
// only be used in a reading fashion.
func (r *Runtime) GetConfigNoCopy() (*config.Config, error) {
r.lock.RLock()
defer r.lock.RUnlock()

if !r.valid {
return nil, define.ErrRuntimeStopped
}
Expand Down Expand Up @@ -810,9 +805,6 @@ func (r *Runtime) DeferredShutdown(force bool) {
// cleaning up; if force is false, an error will be returned if there are
// still containers running or mounted
func (r *Runtime) Shutdown(force bool) error {
r.lock.Lock()
defer r.lock.Unlock()

if !r.valid {
return define.ErrRuntimeStopped
}
Expand Down Expand Up @@ -1016,9 +1008,6 @@ func (r *Runtime) RunRoot() string {
// If the given ID does not correspond to any existing Pod or Container,
// ErrNoSuchCtr is returned.
func (r *Runtime) GetName(id string) (string, error) {
r.lock.RLock()
defer r.lock.RUnlock()

if !r.valid {
return "", define.ErrRuntimeStopped
}
Expand Down
12 changes: 0 additions & 12 deletions libpod/runtime_cstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ type StorageContainer struct {

// ListStorageContainers lists all containers visible to c/storage.
func (r *Runtime) ListStorageContainers() ([]*StorageContainer, error) {
r.lock.RLock()
defer r.lock.RUnlock()

finalCtrs := []*StorageContainer{}

ctrs, err := r.store.Containers()
Expand Down Expand Up @@ -61,15 +58,6 @@ func (r *Runtime) StorageContainer(idOrName string) (*storage.Container, error)
// Accepts ID or full name of container.
// If force is set, the container will be unmounted first to ensure removal.
func (r *Runtime) RemoveStorageContainer(idOrName string, force bool) error {
r.lock.Lock()
defer r.lock.Unlock()

return r.removeStorageContainer(idOrName, force)
}

// Internal function to remove the container storage without
// locking the runtime.
func (r *Runtime) removeStorageContainer(idOrName string, force bool) error {
targetID, err := r.store.Lookup(idOrName)
if err != nil {
if errors.Cause(err) == storage.ErrLayerUnknown {
Expand Down
40 changes: 9 additions & 31 deletions libpod/runtime_ctr.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ type ContainerFilter func(*Container) bool

// NewContainer creates a new container from a given OCI config.
func (r *Runtime) NewContainer(ctx context.Context, rSpec *spec.Spec, spec *specgen.SpecGenerator, infra bool, options ...CtrCreateOption) (*Container, error) {
r.lock.Lock()
defer r.lock.Unlock()
if !r.valid {
return nil, define.ErrRuntimeStopped
}
Expand Down Expand Up @@ -81,8 +79,6 @@ func (r *Runtime) PrepareVolumeOnCreateContainer(ctx context.Context, ctr *Conta

// RestoreContainer re-creates a container from an imported checkpoint
func (r *Runtime) RestoreContainer(ctx context.Context, rSpec *spec.Spec, config *ContainerConfig) (*Container, error) {
r.lock.Lock()
defer r.lock.Unlock()
if !r.valid {
return nil, define.ErrRuntimeStopped
}
Expand Down Expand Up @@ -545,8 +541,6 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
// be removed also if and only if the container is the sole user
// Otherwise, RemoveContainer will return an error if the container is running
func (r *Runtime) RemoveContainer(ctx context.Context, c *Container, force bool, removeVolume bool, timeout *uint) error {
r.lock.Lock()
defer r.lock.Unlock()
return r.removeContainer(ctx, c, force, removeVolume, false, timeout)
}

Expand Down Expand Up @@ -768,6 +762,14 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo
continue
}
if err := runtime.removeVolume(ctx, volume, false, timeout); err != nil && errors.Cause(err) != define.ErrNoSuchVolume {
if errors.Cause(err) == define.ErrVolumeBeingUsed {
// Ignore error, since podman will report original error
volumesFrom, _ := c.volumesFrom()
if len(volumesFrom) > 0 {
logrus.Debugf("Cleanup volume not possible since volume is in use (%s)", v)
continue
}
}
logrus.Errorf("Cleanup volume (%s): %v", v, err)
}
}
Expand All @@ -784,8 +786,6 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo
// If removeVolume is specified, named volumes used by the container will
// be removed also if and only if the container is the sole user.
func (r *Runtime) EvictContainer(ctx context.Context, idOrName string, removeVolume bool) (string, error) {
r.lock.RLock()
defer r.lock.RUnlock()
return r.evictContainer(ctx, idOrName, removeVolume)
}

Expand Down Expand Up @@ -894,7 +894,7 @@ func (r *Runtime) evictContainer(ctx context.Context, idOrName string, removeVol
}

// Remove container from c/storage
if err := r.removeStorageContainer(id, true); err != nil {
if err := r.RemoveStorageContainer(id, true); err != nil {
if cleanupErr == nil {
cleanupErr = err
}
Expand Down Expand Up @@ -972,9 +972,6 @@ func (r *Runtime) RemoveDepend(ctx context.Context, rmCtr *Container, force bool

// GetContainer retrieves a container by its ID
func (r *Runtime) GetContainer(id string) (*Container, error) {
r.lock.RLock()
defer r.lock.RUnlock()

if !r.valid {
return nil, define.ErrRuntimeStopped
}
Expand All @@ -984,9 +981,6 @@ func (r *Runtime) GetContainer(id string) (*Container, error) {

// HasContainer checks if a container with the given ID is present
func (r *Runtime) HasContainer(id string) (bool, error) {
r.lock.RLock()
defer r.lock.RUnlock()

if !r.valid {
return false, define.ErrRuntimeStopped
}
Expand All @@ -997,9 +991,6 @@ func (r *Runtime) HasContainer(id string) (bool, error) {
// LookupContainer looks up a container by its name or a partial ID
// If a partial ID is not unique, an error will be returned
func (r *Runtime) LookupContainer(idOrName string) (*Container, error) {
r.lock.RLock()
defer r.lock.RUnlock()

if !r.valid {
return nil, define.ErrRuntimeStopped
}
Expand All @@ -1009,9 +1000,6 @@ func (r *Runtime) LookupContainer(idOrName string) (*Container, error) {
// LookupContainerId looks up a container id by its name or a partial ID
// If a partial ID is not unique, an error will be returned
func (r *Runtime) LookupContainerID(idOrName string) (string, error) {
r.lock.RLock()
defer r.lock.RUnlock()

if !r.valid {
return "", define.ErrRuntimeStopped
}
Expand All @@ -1023,13 +1011,6 @@ func (r *Runtime) LookupContainerID(idOrName string) (string, error) {
// the output. Multiple filters are handled by ANDing their output, so only
// containers matching all filters are returned
func (r *Runtime) GetContainers(filters ...ContainerFilter) ([]*Container, error) {
r.lock.RLock()
defer r.lock.RUnlock()
return r.GetContainersWithoutLock(filters...)
}

// GetContainersWithoutLock is same as GetContainers but without lock
func (r *Runtime) GetContainersWithoutLock(filters ...ContainerFilter) ([]*Container, error) {
if !r.valid {
return nil, define.ErrRuntimeStopped
}
Expand Down Expand Up @@ -1107,9 +1088,6 @@ func (r *Runtime) GetLatestContainer() (*Container, error) {
// GetExecSessionContainer gets the container that a given exec session ID is
// attached to.
func (r *Runtime) GetExecSessionContainer(id string) (*Container, error) {
r.lock.RLock()
defer r.lock.RUnlock()

if !r.valid {
return nil, define.ErrRuntimeStopped
}
Expand Down
3 changes: 0 additions & 3 deletions libpod/runtime_img.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import (
// we can use the libpod-internal removal logic.
func (r *Runtime) RemoveContainersForImageCallback(ctx context.Context) libimage.RemoveContainerFunc {
return func(imageID string) error {
r.lock.Lock()
defer r.lock.Unlock()

if !r.valid {
return define.ErrRuntimeStopped
}
Expand Down
Loading

0 comments on commit 49d511b

Please sign in to comment.