Bug 1555911

Summary: [3.8] Mounting file in a subpath fails if file was created in initContainer
Product: OpenShift Container Platform Reporter: Hemant Kumar <hekumar>
Component: StorageAssignee: Hemant Kumar <hekumar>
Status: CLOSED CURRENTRELEASE QA Contact: Liang Xia <lxia>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.8.0CC: aos-bugs, aos-storage-staff, bchilds, bleanhar, jhou, jsafrane, lxia
Target Milestone: ---   
Target Release: 3.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1555910 Environment:
Last Closed: 2019-11-21 18:37:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1555910, 1556782, 1556796, 1556838    
Bug Blocks:    

Description Hemant Kumar 2018-03-14 19:55:07 UTC
+++ This bug was initially created as a clone of Bug #1555910 +++

Description of problem:

Originally reported bug : https://github.com/kubernetes/kubernetes/issues/61178

By creating a deployment where an init container creates a file in an emptydir and then the container tries to mount this file as a subpath will reproduce it.

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: subpath
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: subpath
    spec:
      initContainers:
        - name: init
          image: busybox
          command:
            - touch
            - /mount/test
          volumeMounts:
            - name: mount
              mountPath: /mount
      containers:
      - name: subtest
        image: busybox
        command:
          - ls
          - -l
          - /mount/test
        volumeMounts:
          - name: mount
            mountPath: /mount/test
            subPath: test
      volumes:
      - name: mount
        emptyDir: {}



Version-Release number of selected component (if applicable): 3.9




Description of problem:

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:

Master Log:

Node Log (of failed PODs):

PV Dump:

PVC Dump:

StorageClass Dump (if StorageClass used by PV/PVC):

Additional info:

Comment 1 Hemant Kumar 2018-03-14 19:55:56 UTC
We need to cherry-pick upstream fix 
https://github.com/kubernetes/kubernetes/pull/61193

Comment 2 Hemant Kumar 2018-03-14 20:06:16 UTC
https://github.com/openshift/ose/pull/1136

Comment 4 Wenqi He 2018-03-22 08:09:59 UTC
Tested on below version:
openshift v3.8.36
kubernetes v1.8.5+440f8d36da

This bug is fixed on 3.8
# oc get pods -n kube-system
NAME                       READY     STATUS             RESTARTS   AGE
subpath-6cc544864b-8b2wf   0/1       CrashLoopBackOff   1          22m
# oc describe pods subpath-6cc544864b-8b2wf -n kube-system
Events:
  Type     Reason                 Age               From                             Message
  ----     ------                 ----              ----                             -------
  Normal   Scheduled              22m                default-scheduler                Successfully assigned subpath-6cc544864b-8b2wf to wehe-master-etcd-nfs-1
  Normal   SuccessfulMountVolume  22m                kubelet, wehe-master-etcd-nfs-1  MountVolume.SetUp succeeded for volume "mount"
  Normal   SuccessfulMountVolume  22m                kubelet, wehe-master-etcd-nfs-1  MountVolume.SetUp succeeded for volume "default-token-jfd5w"
  Normal   Pulling                22m                kubelet, wehe-master-etcd-nfs-1  pulling image "busybox"
  Normal   Pulled                 22m                kubelet, wehe-master-etcd-nfs-1  Successfully pulled image "busybox"
  Normal   Created                22m                kubelet, wehe-master-etcd-nfs-1  Created container
  Normal   Started                22m                kubelet, wehe-master-etcd-nfs-1  Started container