mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
Fix vetshadow issues
Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
parent
75beccd8c0
commit
5eb1974e38
@ -114,7 +114,7 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
)
|
||||
|
||||
ce := &controllerCacheEntry{}
|
||||
if err := cs.MetadataStore.Get(string(volID), ce); err != nil {
|
||||
if err = cs.MetadataStore.Get(string(volID), ce); err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
if err := cs.MetadataStore.Delete(string(volID)); err != nil {
|
||||
if err = cs.MetadataStore.Delete(string(volID)); err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,6 @@ type nodeServer struct {
|
||||
func getCredentialsForVolume(volOptions *volumeOptions, volID volumeID, req *csi.NodeStageVolumeRequest) (*credentials, error) {
|
||||
var (
|
||||
userCr *credentials
|
||||
err error
|
||||
)
|
||||
secret := req.GetSecrets()
|
||||
if volOptions.ProvisionVolume {
|
||||
@ -64,13 +63,14 @@ func getCredentialsForVolume(volOptions *volumeOptions, volID volumeID, req *csi
|
||||
} else {
|
||||
// The volume is pre-made, credentials are in node stage secrets
|
||||
|
||||
userCr, err = getUserCredentials(secret)
|
||||
uCr, err := getUserCredentials(req.GetSecrets())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get user credentials from node stage secrets: %v", err)
|
||||
}
|
||||
userCr = uCr
|
||||
}
|
||||
|
||||
if err = storeCephCredentials(volID, userCr); err != nil {
|
||||
if err := storeCephCredentials(volID, userCr); err != nil {
|
||||
return nil, fmt.Errorf("failed to store ceph user credentials: %v", err)
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
err := createRBDImage(rbdVol, volSizeGB, rbdVol.AdminID, req.GetSecrets())
|
||||
err = createRBDImage(rbdVol, volSizeGB, rbdVol.AdminID, req.GetSecrets())
|
||||
if err != nil {
|
||||
glog.Warningf("failed to create volume: %v", err)
|
||||
return nil, err
|
||||
@ -150,9 +150,9 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
glog.V(4).Infof("create volume %s", volName)
|
||||
}
|
||||
}
|
||||
if err := cs.MetadataStore.Create(volumeID, rbdVol); err != nil {
|
||||
if err = cs.MetadataStore.Create(volumeID, rbdVol); err != nil {
|
||||
glog.Warningf("failed to store volume metadata with error: %v", err)
|
||||
if err := deleteRBDImage(rbdVol, rbdVol.AdminID, req.GetSecrets()); err != nil {
|
||||
if err = deleteRBDImage(rbdVol, rbdVol.AdminID, req.GetSecrets()); err != nil {
|
||||
glog.V(3).Infof("failed to delete rbd image: %s/%s with error: %v", rbdVol.Pool, rbdVol.VolName, err)
|
||||
return nil, err
|
||||
}
|
||||
@ -192,6 +192,7 @@ func (cs *controllerServer) checkSnapshot(req *csi.CreateVolumeRequest, rbdVol *
|
||||
glog.V(4).Infof("create volume %s from snapshot %s", req.GetName(), rbdSnap.SnapName)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {
|
||||
if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil {
|
||||
glog.Warningf("invalid delete volume req: %v", req)
|
||||
@ -340,16 +341,16 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
|
||||
|
||||
rbdSnap.CreatedAt = time.Now().UnixNano()
|
||||
|
||||
if err := cs.MetadataStore.Create(snapshotID, rbdSnap); err != nil {
|
||||
if err = cs.MetadataStore.Create(snapshotID, rbdSnap); err != nil {
|
||||
glog.Warningf("rbd: failed to store snapInfo with error: %v", err)
|
||||
// Unprotect snapshot
|
||||
err := unprotectSnapshot(rbdSnap, rbdSnap.AdminID, req.GetSecrets())
|
||||
err = unprotectSnapshot(rbdSnap, rbdSnap.AdminID, req.GetSecrets())
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Unknown, "This Snapshot should be removed but failed to unprotect snapshot: %s/%s with error: %v", rbdSnap.Pool, rbdSnap.SnapName, err)
|
||||
}
|
||||
// Deleting snapshot
|
||||
glog.V(4).Infof("deleting Snaphot %s", rbdSnap.SnapName)
|
||||
if err := deleteSnapshot(rbdSnap, rbdSnap.AdminID, req.GetSecrets()); err != nil {
|
||||
if err = deleteSnapshot(rbdSnap, rbdSnap.AdminID, req.GetSecrets()); err != nil {
|
||||
return nil, status.Errorf(codes.Unknown, "This Snapshot should be removed but failed to delete snapshot: %s/%s with error: %v", rbdSnap.Pool, rbdSnap.SnapName, err)
|
||||
}
|
||||
return nil, err
|
||||
|
@ -246,8 +246,8 @@ func getRBDVolumeOptions(volOptions map[string]string) (*rbdVolume, error) {
|
||||
if rbdVol.ImageFormat == rbdImageFormat2 {
|
||||
// if no image features is provided, it results in empty string
|
||||
// which disable all RBD image format 2 features as we expected
|
||||
imageFeatures, ok := volOptions["imageFeatures"]
|
||||
if ok {
|
||||
imageFeatures, found := volOptions["imageFeatures"]
|
||||
if found {
|
||||
arr := strings.Split(imageFeatures, ",")
|
||||
for _, f := range arr {
|
||||
if !supportedFeatures.Has(f) {
|
||||
|
@ -104,7 +104,7 @@ func (k8scm *K8sCMCache) ForAll(pattern string, destObj interface{}, f ForAllFun
|
||||
if !match {
|
||||
continue
|
||||
}
|
||||
if err := json.Unmarshal([]byte(data), destObj); err != nil {
|
||||
if err = json.Unmarshal([]byte(data), destObj); err != nil {
|
||||
return errors.Wrap(err, "k8s-cm-cache: unmarshal error")
|
||||
}
|
||||
if err = f(cm.ObjectMeta.Name); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user