Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pod Preset not being applied when using 2:1 volumeMount:volume mapping #61247

Closed
mentalblock opened this issue Mar 15, 2018 · 4 comments

Comments

Projects
None yet
4 participants
@mentalblock
Copy link

commented Mar 15, 2018

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:
A pod preset which has two volumeMounts from the same volume do not get applied to pods. The volume is a hostPath volume.

What you expected to happen:
I expected the pod to get the volume and volumeMounts from the pod preset.

How to reproduce it (as minimally and precisely as possible):
Create a pod preset that has two volumeMounts that mount to the same volume. It will not get applied to a pod even if it matches the selector. Then change the pod preset to make two volumes with different names but have the same path. Then change each of the volumeMounts to use a separate volume. The preset will then get applied to a new pod. I will provide full preset and pod examples below.

Anything else we need to know?:
The context is that we have some legacy docker images that expects a file from a specific directory. We want to transition to a new directory, and therefore must have the same file in the former and new directory. This is best accommodated by having two volumeMounts to the same volume. Therefore old docker images and new docker images will work seamlessly.

Here is a YAML file creating a broken version of a preset and a working version:

---
apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
  name: preset-broken
spec:
  selector:
    matchLabels:
      preset-broken: enabled
  volumeMounts:
  - mountPath: /a
    name: cache-volume
    readOnly: true
  - mountPath: /b
    name: cache-volume
    readOnly: true
  volumes:
  - name: cache-volume
    hostPath:
      path: /tmp
      type: Directory

---
apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
  name: preset-working
spec:
  selector:
    matchLabels:
      preset-working: enabled
  volumeMounts:
  - mountPath: /a
    name: cache-volume-a
    readOnly: true
  - mountPath: /b
    name: cache-volume-b
    readOnly: true
  volumes:
  - name: cache-volume-a
    hostPath:
      path: /tmp
      type: Directory
  - name: cache-volume-b
    hostPath:
      path: /tmp
      type: Directory

Here are pods that are associated with them and a working pod without a preset:

---
apiVersion: v1
kind: Pod
metadata:
  name: pod-broken-preset
  labels:
    app: website
    role: frontend
    preset-broken: enabled
spec:
  containers:
    - name: website
      image: nginx

---
apiVersion: v1
kind: Pod
metadata:
  name: pod-no-preset
  labels:
    app: website
    role: frontend
spec:
  containers:
    - name: website
      image: nginx
      volumeMounts:
        - mountPath: /a
          name: cache-volume
          readOnly: true
        - mountPath: /b
          name: cache-volume
          readOnly: true
  volumes:
    - name: cache-volume
      hostPath:
        path: /tmp
        type: Directory

---
apiVersion: v1
kind: Pod
metadata:
  name: pod-working-preset
  labels:
    app: website
    role: frontend
    preset-working: enabled
spec:
  containers:
    - name: website
      image: nginx

Environment:

  • Kubernetes version (use kubectl version):
    Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.3", GitCommit:"d2835416544f298c919e2ead3be3d0864b52323b", GitTreeState:"archive", BuildDate:"2018-02-16T10:14:13Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
    Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.3", GitCommit:"d2835416544f298c919e2ead3be3d0864b52323b", GitTreeState:"archive", BuildDate:"2018-02-16T10:14:13Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration:
    AWS
  • OS (e.g. from /etc/os-release):
    NAME="CentOS Linux"
    VERSION="7 (Core)"
    ID="centos"
    ID_LIKE="rhel fedora"
    VERSION_ID="7"
    PRETTY_NAME="CentOS Linux 7 (Core)"
    ANSI_COLOR="0;31"
    CPE_NAME="cpe:/o:centos:centos:7"
    HOME_URL="https://www.centos.org/"
    BUG_REPORT_URL="https://bugs.centos.org/"
    CENTOS_MANTISBT_PROJECT="CentOS-7"
    CENTOS_MANTISBT_PROJECT_VERSION="7"
    REDHAT_SUPPORT_PRODUCT="centos"
    REDHAT_SUPPORT_PRODUCT_VERSION="7"
  • Kernel (e.g. uname -a):
    Linux ip-10-91-38-50.ec2.internal 3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Jan 4 01:06:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Install tools:
    None
  • Others:
@tpepper

This comment has been minimized.

Copy link
Contributor

commented Mar 19, 2018

/sig storage

@k8s-ci-robot k8s-ci-robot added sig/storage and removed needs-sig labels Mar 19, 2018

@fejta-bot

This comment has been minimized.

Copy link

commented Jun 17, 2018

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@fejta-bot

This comment has been minimized.

Copy link

commented Jul 17, 2018

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@fejta-bot

This comment has been minimized.

Copy link

commented Aug 16, 2018

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.