Bug 1464036

Summary: [DOCS] Could not use label selector to pvc and pv when there is default storageclass
Product: OpenShift Container Platform Reporter: Chao Yang <chaoyang>
Component: DocumentationAssignee: Gaurav Nelson <gnelson>
Status: CLOSED CURRENTRELEASE QA Contact: Jianwei Hou <jhou>
Severity: medium Docs Contact: Vikram Goyal <vigoyal>
Priority: medium    
Version: 3.6.0CC: aos-bugs, jokerman, lxia, mmccomas
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-19 00:00:53 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:

Description Chao Yang 2017-06-22 10:18:47 UTC
Description of problem:
Could not use label selector to pvc and pv when there is default storageclass
Version-Release number of selected component (if applicable):
oc v3.6.121
kubernetes v1.6.1+5115d708d7
features: Basic-Auth GSSAPI Kerberos SPNEGO

How reproducible:
Always

Steps to Reproduce:
1.Check default storageclas
[root@ip-172-18-9-120 ~]# oc get storageclass
NAME            TYPE
gp2 (default)   kubernetes.io/aws-ebs 

2.Create a pv with labels
kind: PersistentVolume
apiVersion: v1
metadata:
  name: ebs1
  labels:
    type: local
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  claimRef:
    name: ebs1
  awsElasticBlockStore:
    volumeID: "aws://us-east-1d/vol-069b4699ba83241a0"
    fsType: "ext4"

3.Create a pvc
{
    "apiVersion": "v1",
    "kind": "PersistentVolumeClaim",
    "metadata": {
        "name": "ebs1"
    },
    "spec": {
        "accessModes": [ "ReadWriteOnce" ],
        "resources": {
            "requests": {
                "storage": "1Gi"
            }
        },
       "selector": {
           "matchLabels": {
             "type": "local"
           }
        },
      "persistentVolumeReclaimPolicy": "Retain"
   }
}

[root@ip-172-18-9-120 ~]# oc get pvc
NAME      STATUS    VOLUME    CAPACITY   ACCESSMODES   STORAGECLASS   AGE
ebs1      Pending                                      gp2            3s
[root@ip-172-18-9-120 ~]# oc describe pvc
Name:		ebs1
Namespace:	default
StorageClass:	gp2
Status:		Pending
Volume:		
Labels:		<none>
Annotations:	volume.beta.kubernetes.io/storage-provisioner=kubernetes.io/aws-ebs
Capacity:	
Access Modes:	
Events:
  FirstSeen	LastSeen	Count	From				SubObjectPath	Type		Reason			Message
  ---------	--------	-----	----				-------------	--------	------			-------
  15s		14s		2	persistent-volume-controller			Warning		ProvisioningFailed	Failed to provision volume with StorageClass "gp2": claim.Spec.Selector is not supported for dynamic provisioning on AWS

Actual results:
PV and pvc is not bond

Expected results:
PV and pvc should bond, there should be a method to avoid default storageclass
Master Log:

Node Log (of failed PODs):

PV Dump:

PVC Dump:

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

Additional info:

Comment 1 Bradley Childs 2017-06-22 17:52:07 UTC
This is currently expected behavior.  Labels, selectors and storage-class are mutually exclusive by design currently.

There is RFE to change this behavior in 3.8 (the title is a little off, but the feature is here):

https://trello.com/c/lbxSAqUb/406-list-allowed-selectors-in-storageclass-list-allowed-keys13

Closing this bug for now.

Comment 2 Matthew Wong 2017-06-22 17:53:12 UTC
When a default storage class is configured, the PVC must explicitly ask for storage class "" via annotation or storageclassname field in order to get bound to PV with blank storage class. This is documented upstream but maybe missing from openshift docs.

Comment 3 Liang Xia 2017-06-23 03:45:48 UTC
We need to document this behavior.

Comment 4 Gaurav Nelson 2017-07-13 01:52:40 UTC
Changes are in PR https://github.com/openshift/openshift-docs/pull/4749

Comment 5 openshift-github-bot 2017-07-13 02:42:48 UTC
Commit pushed to master at https://github.com/openshift/openshift-docs

https://github.com/openshift/openshift-docs/commit/d287bf46653b4c0fe46d291fde5dfc31bb136b74
Merge pull request #4749 from gaurav-nelson/Bug1464036-fixes

BZ#1464036-added information about getting a pv with blank storage class