mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
cleanup: simplify checkStaticVolume function and remove unwanted vars
checkStaticVolume() in the reconcilePV function has been unwantedly introducing variables to confirm the pv spec is static or not. This patch simplify it and make a smaller footprint of the functions. Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
parent
1b64a0a505
commit
4efcc5bf97
@ -19,7 +19,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
ctrl "github.com/ceph/ceph-csi/internal/controller"
|
||||
"github.com/ceph/ceph-csi/internal/rbd"
|
||||
@ -126,19 +125,8 @@ func (r *ReconcilePersistentVolume) getCredentials(
|
||||
return cr, nil
|
||||
}
|
||||
|
||||
func checkStaticVolume(pv *corev1.PersistentVolume) (bool, error) {
|
||||
static := false
|
||||
var err error
|
||||
|
||||
staticVol := pv.Spec.CSI.VolumeAttributes["staticVolume"]
|
||||
if staticVol != "" {
|
||||
static, err = strconv.ParseBool(staticVol)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to parse preProvisionedVolume: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return static, nil
|
||||
func checkStaticVolume(pv *corev1.PersistentVolume) bool {
|
||||
return pv.Spec.CSI.VolumeAttributes["staticVolume"] == "true"
|
||||
}
|
||||
|
||||
// storeVolumeIDInPV stores the new volumeID in PV object.
|
||||
@ -178,10 +166,7 @@ func (r ReconcilePersistentVolume) reconcilePV(ctx context.Context, obj runtime.
|
||||
secretName := ""
|
||||
secretNamespace := ""
|
||||
// check static volume
|
||||
static, err := checkStaticVolume(pv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
static := checkStaticVolume(pv)
|
||||
// if the volume is static, dont generate OMAP data
|
||||
if static {
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user