Bug 1655894 - The same access mode show multiple times when show detail of persistent volume
Summary: The same access mode show multiple times when show detail of persistent volume
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Storage
Version: 4.1.0
Hardware: Unspecified
OS: Unspecified
medium
low
Target Milestone: ---
: 4.1.0
Assignee: Bradley Childs
QA Contact: Liang Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-12-04 08:34 UTC by Liang Xia
Modified: 2019-04-29 15:01 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-04-29 15:01:11 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Liang Xia 2018-12-04 08:34:12 UTC
Description of problem:
Create several persistent volume(pv) with multiple access mode,
some of the access mode are same, some of them are not.
Check the pv in detail. The same access mode show multiple times.


Version-Release number of selected component (if applicable):
oc v4.0.0-0.81.0
kubernetes v1.11.0+ba8f89f8f9
features: Basic-Auth GSSAPI Kerberos SPNEGO
Server https://preserve-qe-lxia-master-etcd-1:8443
openshift v4.0.0-0.81.0
kubernetes v1.11.0+ba8f89f8f9


How reproducible:
Always

Steps to Reproduce:
1. Create persistent volume with content.
---
  apiVersion: v1
  kind: PersistentVolume
  metadata:
    name: pv-45tb1
  spec:
    capacity:
      storage: 1Gi
    accessModes:
    - ReadWriteOnce
    - ReadWriteOnce
    - ReadWriteOnce
    hostPath:
      path: "/tmp/data"
    persistentVolumeReclaimPolicy: Delete

2. Check the detail.
# oc get pv
NAME       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM     STORAGECLASS   REASON    AGE
pv-45tb1   1Gi        RWO            Delete           Available                                      11m
pv-45tb2   1Gi        RWO,ROX,RWX    Delete           Available                                      5m

# oc get pv -o yaml
apiVersion: v1
items:
- apiVersion: v1
  kind: PersistentVolume
  metadata:
    creationTimestamp: 2018-12-04T08:09:57Z
    finalizers:
    - kubernetes.io/pv-protection
    name: pv-45tb1
    namespace: ""
    resourceVersion: "38967"
    selfLink: /api/v1/persistentvolumes/pv-45tb1
    uid: fd00be21-f79b-11e8-857b-fa163e58f808
  spec:
    accessModes:
    - ReadWriteOnce
    - ReadWriteOnce
    - ReadWriteOnce
    capacity:
      storage: 1Gi
    hostPath:
      path: /tmp/data
      type: ""
    persistentVolumeReclaimPolicy: Delete
  status:
    phase: Available
- apiVersion: v1
  kind: PersistentVolume
  metadata:
    creationTimestamp: 2018-12-04T08:16:05Z
    finalizers:
    - kubernetes.io/pv-protection
    name: pv-45tb2
    namespace: ""
    resourceVersion: "39561"
    selfLink: /api/v1/persistentvolumes/pv-45tb2
    uid: d89c5f00-f79c-11e8-857b-fa163e58f808
  spec:
    accessModes:
    - ReadWriteOnce
    - ReadWriteMany
    - ReadOnlyMany
    capacity:
      storage: 1Gi
    hostPath:
      path: /tmp/data
      type: ""
    persistentVolumeReclaimPolicy: Delete
  status:
    phase: Available
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""


Actual results:
 spec:
    accessModes:
    - ReadWriteOnce
    - ReadWriteOnce
    - ReadWriteOnce


Expected results:
 spec:
    accessModes:
    - ReadWriteOnce

Comment 1 Jan Safranek 2019-04-16 15:18:46 UTC
That's unfortunate result of insufficient validation of PVs / PVCs. We cannot harden the validation now because it could refuse objects that are working today and existing applications could fail.

Comment 2 Liang Xia 2019-04-23 05:40:16 UTC
We already have that check in k8s, https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/util/storage/storage.go#L65

Fixing in the describe command will not break anything that is working today.

Comment 3 Jan Safranek 2019-04-29 15:01:11 UTC
(In reply to Liang Xia from comment #2)
> We already have that check in k8s,
> https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/util/
> storage/storage.go#L65


removeDuplicateAccessModes() linked above affects only `kubectl get pv` (without -o yaml) and `kubectl describe pv`. We already have that code in `oc get/describe pv`.

Upstream `kubectl get pv -o yaml` prints full object as it is in API server, with three access modes:

    accessModes:
    - ReadWriteOnce
    - ReadWriteOnce
    - ReadWriteOnce


Note You need to log in before you can comment on or make changes to this bug.