mirror of
https://github.com/containers/podman.git
synced 2025-06-22 01:48:54 +08:00
Fix bind-mount-option annotation in gen/play kube
The format used for setting the bind-mount-options annotations in the kube yaml was incorrect and caused k8s to throw an error when trying to play the generated kube yaml. Fix the annotation format to match the rules of k8s. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
This commit is contained in:
@ -85,4 +85,4 @@ const PassthroughLogging = "passthrough"
|
|||||||
const RLimitDefaultValue = uint64(1048576)
|
const RLimitDefaultValue = uint64(1048576)
|
||||||
|
|
||||||
// BindMountPrefix distinguishes its annotations from others
|
// BindMountPrefix distinguishes its annotations from others
|
||||||
const BindMountPrefix = "bind-mount-options:"
|
const BindMountPrefix = "bind-mount-options"
|
||||||
|
@ -385,7 +385,7 @@ func (p *Pod) podWithContainers(ctx context.Context, containers []*Container, po
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for k, v := range annotations {
|
for k, v := range annotations {
|
||||||
podAnnotations[define.BindMountPrefix+k] = TruncateKubeAnnotation(v)
|
podAnnotations[define.BindMountPrefix] = TruncateKubeAnnotation(k + ":" + v)
|
||||||
}
|
}
|
||||||
// Since port bindings for the pod are handled by the
|
// Since port bindings for the pod are handled by the
|
||||||
// infra container, wipe them here only if we are sharing the net namespace
|
// infra container, wipe them here only if we are sharing the net namespace
|
||||||
@ -529,7 +529,7 @@ func simplePodWithV1Containers(ctx context.Context, ctrs []*Container) (*v1.Pod,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for k, v := range annotations {
|
for k, v := range annotations {
|
||||||
kubeAnnotations[define.BindMountPrefix+k] = TruncateKubeAnnotation(v)
|
kubeAnnotations[define.BindMountPrefix] = TruncateKubeAnnotation(k + ":" + v)
|
||||||
}
|
}
|
||||||
if isInit {
|
if isInit {
|
||||||
kubeInitCtrs = append(kubeInitCtrs, kubeCtr)
|
kubeInitCtrs = append(kubeInitCtrs, kubeCtr)
|
||||||
|
@ -357,8 +357,11 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
|
|||||||
// a selinux mount option exists for it
|
// a selinux mount option exists for it
|
||||||
for k, v := range opts.Annotations {
|
for k, v := range opts.Annotations {
|
||||||
// Make sure the z/Z option is not already there (from editing the YAML)
|
// Make sure the z/Z option is not already there (from editing the YAML)
|
||||||
if strings.Replace(k, define.BindMountPrefix, "", 1) == volumeSource.Source && !cutil.StringInSlice("z", options) && !cutil.StringInSlice("Z", options) {
|
if k == define.BindMountPrefix {
|
||||||
options = append(options, v)
|
lastIndex := strings.LastIndex(v, ":")
|
||||||
|
if v[:lastIndex] == volumeSource.Source && !cutil.StringInSlice("z", options) && !cutil.StringInSlice("Z", options) {
|
||||||
|
options = append(options, v[lastIndex+1:])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mount := spec.Mount{
|
mount := spec.Mount{
|
||||||
|
@ -719,7 +719,7 @@ var _ = Describe("Podman generate kube", func() {
|
|||||||
pod := new(v1.Pod)
|
pod := new(v1.Pod)
|
||||||
err = yaml.Unmarshal(b, pod)
|
err = yaml.Unmarshal(b, pod)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(pod.Annotations).To(HaveKeyWithValue(define.BindMountPrefix+vol1, HaveSuffix("z")))
|
Expect(pod.Annotations).To(HaveKeyWithValue(define.BindMountPrefix, vol1+":"+"z"))
|
||||||
|
|
||||||
rm := podmanTest.Podman([]string{"pod", "rm", "-t", "0", "-f", "test1"})
|
rm := podmanTest.Podman([]string{"pod", "rm", "-t", "0", "-f", "test1"})
|
||||||
rm.WaitWithDefaultTimeout()
|
rm.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user