Bug 2060554

Summary: pvc source-cr includes a storageclass annotation that overrides user config in PVC spec.storageClassName
Product: OpenShift Container Platform Reporter: yliu1
Component: Telco EdgeAssignee: melserng
Telco Edge sub component: ZTP QA Contact: yliu1
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: urgent CC: melserng
Version: 4.10   
Target Milestone: ---   
Target Release: 4.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Known Issue
Doc Text:
Cause: Processing of StoragePVC CR during GitOps ZTP flow does not exclude volume.beta.kubernetes.io/storage-class annotation when user does not include a value for it. Consequence: The spec.storageClassName field is ignored due to the annotation. Workaround (if any): Set the desired StorageClass name in the volume.beta.kubernetes.io/storage-class annotation within your PolicyGenTemplate when using StoragePVC. Result: The StorageClass name specified in the metadata annotation is used as desired.
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-26 16:43:57 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:    
Bug Blocks: 2062492, 2062493    

Description yliu1 2022-03-03 18:46:31 UTC
Description of problem:

PVC source-cr has an annotation with storageclass set to $storageclass, if user uses spec.storageClassName to specify the storage class, then it will be overridden by an invalid storage class - "$storageclass". 

This annotation should be commented out or document that we only support specifying storageclass via pvc annotation.

https://github.com/openshift-kni/cnf-features-deploy/blob/f949a6f296a78d2579d809a329c30d9dd91026b3/ztp/source-crs/StoragePVC.yaml#L8

  annotations:
    ran.openshift.io/ztp-deploy-wave: "10"
    volume.beta.kubernetes.io/storage-class: $storageclass


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

How reproducible:
Always


Steps to Reproduce:
1. Deploy a cluster via ZTP with storage class specified via PVC spec. 
http://registry.kni-qe-0.lab.eng.rdu2.redhat.com:3000/kni-qe/ztp-site-configs/src/b35e3bd01e76825fc77de68924e23b61025fcadf/policygentemplates/group-du-sno-ranGen.yaml#L109

2. Check created PVC post deployment
3.

Actual results:
2. PVC points to an non-existed storage class.

[kni@ran-vcl01-installer ~]$ oc describe pvc -n  openshift-image-registry registry-storage
Name:          registry-storage
Namespace:     openshift-image-registry
StorageClass:  $storageclass
Status:        Pending
Volume:        
Labels:        <none>
Annotations:   ran.openshift.io/ztp-deploy-wave: 10
               volume.beta.kubernetes.io/storage-class: $storageclass
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      
Access Modes:  
VolumeMode:    Filesystem
Used By:       image-registry-674bbcc9f6-6646n
...
Events:
  Type     Reason              Age                    From                         Message
  ----     ------              ----                   ----                         -------
  Warning  ProvisioningFailed  80m                    persistentvolume-controller  storageclass.storage.k8s.io "$storageclass" not found
  Warning  ProvisioningFailed  74m (x7 over 76m)      persistentvolume-controller  storageclass.storage.k8s.io "$storageclass" not found
  Warning  ProvisioningFailed  66m (x14 over 69m)     persistentvolume-controller  storageclass.storage.k8s.io "$storageclass" not found
  Warning  ProvisioningFailed  62m (x7 over 63m)      persistentvolume-controller  storageclass.storage.k8s.io "$storageclass" not found
  Warning  ProvisioningFailed  45m (x21 over 50m)     persistentvolume-controller  storageclass.storage.k8s.io "$storageclass" not found
  Warning  ProvisioningFailed  5m22s (x144 over 40m)  persistentvolume-controller  storageclass.storage.k8s.io "$storageclass" not found


Expected results:
StorageClass:  fs-lso


Additional info:

Comment 3 yliu1 2022-03-10 19:04:07 UTC
Mark as verified by reviewing the code to unblock backport.