mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 11:00:25 +00:00
rbd: dont generate OMAP data for static volume
if the user has created a static PV for a RBD image which is not created by CSI driver, dont generate the OMAP data. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
c40872df00
commit
e243c0006b
@ -19,6 +19,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
ctrl "github.com/ceph/ceph-csi/internal/controller"
|
ctrl "github.com/ceph/ceph-csi/internal/controller"
|
||||||
"github.com/ceph/ceph-csi/internal/rbd"
|
"github.com/ceph/ceph-csi/internal/rbd"
|
||||||
@ -94,6 +95,18 @@ func (r *ReconcilePersistentVolume) getCredentials(name, namespace string) (map[
|
|||||||
return credentials, nil
|
return credentials, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkStaticVolume(staticVol string) (bool, error) {
|
||||||
|
static := false
|
||||||
|
var err error
|
||||||
|
if staticVol != "" {
|
||||||
|
static, err = strconv.ParseBool(staticVol)
|
||||||
|
if err != nil {
|
||||||
|
return false, fmt.Errorf("failed to parse preProvisionedVolume: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return static, nil
|
||||||
|
}
|
||||||
|
|
||||||
// reconcilePV will extract the image details from the pv spec and regenerates
|
// reconcilePV will extract the image details from the pv spec and regenerates
|
||||||
// the omap data.
|
// the omap data.
|
||||||
func (r ReconcilePersistentVolume) reconcilePV(obj runtime.Object) error {
|
func (r ReconcilePersistentVolume) reconcilePV(obj runtime.Object) error {
|
||||||
@ -109,7 +122,15 @@ func (r ReconcilePersistentVolume) reconcilePV(obj runtime.Object) error {
|
|||||||
volumeHandler := pv.Spec.CSI.VolumeHandle
|
volumeHandler := pv.Spec.CSI.VolumeHandle
|
||||||
secretName := ""
|
secretName := ""
|
||||||
secretNamespace := ""
|
secretNamespace := ""
|
||||||
|
// check static volume
|
||||||
|
static, err := checkStaticVolume(pv.Spec.CSI.VolumeAttributes["staticVolume"])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// if the volume is static, dont generate OMAP data
|
||||||
|
if static {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if pv.Spec.CSI.ControllerExpandSecretRef != nil {
|
if pv.Spec.CSI.ControllerExpandSecretRef != nil {
|
||||||
secretName = pv.Spec.CSI.ControllerExpandSecretRef.Name
|
secretName = pv.Spec.CSI.ControllerExpandSecretRef.Name
|
||||||
secretNamespace = pv.Spec.CSI.ControllerExpandSecretRef.Namespace
|
secretNamespace = pv.Spec.CSI.ControllerExpandSecretRef.Namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user