summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-03-31 07:30:46 -0400
committerGitHub <noreply@github.com>2022-03-31 07:30:46 -0400
commit4ba71f955a944790edda6e007e6d074009d437a7 (patch)
treedc654d918cd0fb947670f44769a57e0faac62fed /pkg
parentc08e8c30a1069acab69bd5704c6362c7c90252d6 (diff)
parentdaeea48df5061d1d7a7207995fa166c2106ba3ae (diff)
downloadpodman-4ba71f955a944790edda6e007e6d074009d437a7.tar.gz
podman-4ba71f955a944790edda6e007e6d074009d437a7.tar.bz2
podman-4ba71f955a944790edda6e007e6d074009d437a7.zip
Merge pull request #13732 from flouthoc/reuse-configmap-volume
kube: `configmap` volume should be reused if already exists
Diffstat (limited to 'pkg')
-rw-r--r--pkg/domain/infra/abi/play.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go
index 1423ab06e..c3f6bb17d 100644
--- a/pkg/domain/infra/abi/play.go
+++ b/pkg/domain/infra/abi/play.go
@@ -290,7 +290,16 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
if v.Type == kube.KubeVolumeTypeConfigMap && !v.Optional {
vol, err := ic.Libpod.NewVolume(ctx, libpod.WithVolumeName(v.Source))
if err != nil {
- return nil, errors.Wrapf(err, "cannot create a local volume for volume from configmap %q", v.Source)
+ if errors.Is(err, define.ErrVolumeExists) {
+ // Volume for this configmap already exists do not
+ // error out instead reuse the current volume.
+ vol, err = ic.Libpod.GetVolume(v.Source)
+ if err != nil {
+ return nil, errors.Wrapf(err, "cannot re-use local volume for volume from configmap %q", v.Source)
+ }
+ } else {
+ return nil, errors.Wrapf(err, "cannot create a local volume for volume from configmap %q", v.Source)
+ }
}
mountPoint, err := vol.MountPoint()
if err != nil || mountPoint == "" {