Fix vetshadow issues

Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
Madhu Rajanna 2019-01-17 12:19:35 +05:30
parent 75beccd8c0
commit 5eb1974e38
5 changed files with 15 additions and 14 deletions

View File

@ -114,7 +114,7 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
) )
ce := &controllerCacheEntry{} 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()) 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()) 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()) return nil, status.Error(codes.Internal, err.Error())
} }

View File

@ -36,7 +36,6 @@ type nodeServer struct {
func getCredentialsForVolume(volOptions *volumeOptions, volID volumeID, req *csi.NodeStageVolumeRequest) (*credentials, error) { func getCredentialsForVolume(volOptions *volumeOptions, volID volumeID, req *csi.NodeStageVolumeRequest) (*credentials, error) {
var ( var (
userCr *credentials userCr *credentials
err error
) )
secret := req.GetSecrets() secret := req.GetSecrets()
if volOptions.ProvisionVolume { if volOptions.ProvisionVolume {
@ -64,13 +63,14 @@ func getCredentialsForVolume(volOptions *volumeOptions, volID volumeID, req *csi
} else { } else {
// The volume is pre-made, credentials are in node stage secrets // The volume is pre-made, credentials are in node stage secrets
userCr, err = getUserCredentials(secret) uCr, err := getUserCredentials(req.GetSecrets())
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get user credentials from node stage secrets: %v", err) 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) return nil, fmt.Errorf("failed to store ceph user credentials: %v", err)
} }

View File

@ -141,7 +141,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
return nil, err return nil, err
} }
} else { } else {
err := createRBDImage(rbdVol, volSizeGB, rbdVol.AdminID, req.GetSecrets()) err = createRBDImage(rbdVol, volSizeGB, rbdVol.AdminID, req.GetSecrets())
if err != nil { if err != nil {
glog.Warningf("failed to create volume: %v", err) glog.Warningf("failed to create volume: %v", err)
return nil, 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) 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) 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) glog.V(3).Infof("failed to delete rbd image: %s/%s with error: %v", rbdVol.Pool, rbdVol.VolName, err)
return nil, 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) glog.V(4).Infof("create volume %s from snapshot %s", req.GetName(), rbdSnap.SnapName)
return nil return nil
} }
func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) { 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 { if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil {
glog.Warningf("invalid delete volume req: %v", req) 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() 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) glog.Warningf("rbd: failed to store snapInfo with error: %v", err)
// Unprotect snapshot // Unprotect snapshot
err := unprotectSnapshot(rbdSnap, rbdSnap.AdminID, req.GetSecrets()) err = unprotectSnapshot(rbdSnap, rbdSnap.AdminID, req.GetSecrets())
if err != nil { 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) 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 // Deleting snapshot
glog.V(4).Infof("deleting Snaphot %s", rbdSnap.SnapName) 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, 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 return nil, err

View File

@ -246,8 +246,8 @@ func getRBDVolumeOptions(volOptions map[string]string) (*rbdVolume, error) {
if rbdVol.ImageFormat == rbdImageFormat2 { if rbdVol.ImageFormat == rbdImageFormat2 {
// if no image features is provided, it results in empty string // if no image features is provided, it results in empty string
// which disable all RBD image format 2 features as we expected // which disable all RBD image format 2 features as we expected
imageFeatures, ok := volOptions["imageFeatures"] imageFeatures, found := volOptions["imageFeatures"]
if ok { if found {
arr := strings.Split(imageFeatures, ",") arr := strings.Split(imageFeatures, ",")
for _, f := range arr { for _, f := range arr {
if !supportedFeatures.Has(f) { if !supportedFeatures.Has(f) {

View File

@ -104,7 +104,7 @@ func (k8scm *K8sCMCache) ForAll(pattern string, destObj interface{}, f ForAllFun
if !match { if !match {
continue 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") return errors.Wrap(err, "k8s-cm-cache: unmarshal error")
} }
if err = f(cm.ObjectMeta.Name); err != nil { if err = f(cm.ObjectMeta.Name); err != nil {