mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 06:20:11 +01:00
feat(zfspv): pvc should be bound only if volume has been created.
The controller does not check whether the volume has been created or not and return successful. Which in turn binds the pvc to the pv. The PVC should not bound until corresponding zfs volume has been created. Now controller will check the ZFSVolume CR state to be "Ready" before returning successful. The CSI will retry the CreateVolume request when it will get a error reply and when the ZFS node agent creates the ZFS volume and sets the ZFSVolume CR state to be "Ready", the controller will return success for the CreateVolume Request and then PVC will be bound. Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
parent
9118f56600
commit
25d1f1a413
13 changed files with 150 additions and 5 deletions
|
|
@ -157,6 +157,21 @@ func GetZFSVolume(volumeID string) (*apis.ZFSVolume, error) {
|
|||
return vol, err
|
||||
}
|
||||
|
||||
// GetZFSVolumeState returns ZFSVolume OwnerNode and State for
|
||||
// the given volume. CreateVolume request may call it again and
|
||||
// again until volume is "Ready".
|
||||
func GetZFSVolumeState(volID string) (string, string, error) {
|
||||
getOptions := metav1.GetOptions{}
|
||||
vol, err := volbuilder.NewKubeclient().
|
||||
WithNamespace(OpenEBSNamespace).Get(volID, getOptions)
|
||||
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
return vol.Spec.OwnerNodeID, vol.Status.State, nil
|
||||
}
|
||||
|
||||
// UpdateZvolInfo updates ZFSVolume CR with node id and finalizer
|
||||
func UpdateZvolInfo(vol *apis.ZFSVolume) error {
|
||||
finalizers := []string{ZFSFinalizer}
|
||||
|
|
@ -168,6 +183,7 @@ func UpdateZvolInfo(vol *apis.ZFSVolume) error {
|
|||
|
||||
newVol, err := volbuilder.BuildFrom(vol).
|
||||
WithFinalizer(finalizers).
|
||||
WithVolumeStatus(ZFSStatusReady).
|
||||
WithLabels(labels).Build()
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue