diff --git a/core/semver/semver.go b/core/semver/semver.go index 98878dc..74bba84 100644 --- a/core/semver/semver.go +++ b/core/semver/semver.go @@ -71,7 +71,7 @@ func main() { var w io.Writer = os.Stdout if len(output) > 0 { - fout, err := os.Create(output) + fout, err := os.Create(filepath.Clean(output)) if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) os.Exit(1) diff --git a/dell-csi-helm-installer/verify.sh b/dell-csi-helm-installer/verify.sh index 556f263..9269e75 100755 --- a/dell-csi-helm-installer/verify.sh +++ b/dell-csi-helm-installer/verify.sh @@ -147,7 +147,12 @@ function verify_fc_installation() { # verify secrets exist function verify_required_secrets() { - log step "Verifying that required secrets have been created" + if [[ "${@}" == *"-certs"* ]]; then + log step "Verifying that required secrets for certs have been created" + fi + if [[ "${@}" == *"-creds"* ]]; then + log step "Verifying that required secrets for creds have been created" + fi error=0 for N in "${@}"; do diff --git a/go.mod b/go.mod index 4cd75a2..4b482ab 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 go.uber.org/atomic v1.7.0 - golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 + golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f google.golang.org/grpc v1.38.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b @@ -27,7 +27,69 @@ require ( k8s.io/kubernetes v1.21.5 ) +require ( + github.com/akutz/gosync v0.1.0 // indirect + github.com/coreos/go-semver v0.3.0 // indirect + github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/cucumber/gherkin-go/v11 v11.0.0 // indirect + github.com/cucumber/messages-go/v10 v10.0.3 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-logr/logr v0.4.0 // indirect + github.com/gofrs/uuid v3.2.0+incompatible // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/mock v1.4.4 // indirect + github.com/google/gofuzz v1.1.0 // indirect + github.com/google/uuid v1.1.2 // indirect + github.com/googleapis/gnostic v0.4.1 // indirect + github.com/hashicorp/go-immutable-radix v1.2.0 // indirect + github.com/hashicorp/go-memdb v1.2.1 // indirect + github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/imdario/mergo v0.3.5 // indirect + github.com/json-iterator/go v1.1.11 // indirect + github.com/magiconair/properties v1.8.1 // indirect + github.com/mitchellh/mapstructure v1.1.2 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/pelletier/go-toml v1.2.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/spf13/afero v1.2.2 // indirect + github.com/spf13/cast v1.3.0 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/subosito/gotenv v1.2.0 // indirect + go.etcd.io/etcd/api/v3 v3.5.0 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.0 // indirect + go.etcd.io/etcd/client/v3 v3.5.0 // indirect + go.uber.org/multierr v1.6.0 // indirect + go.uber.org/zap v1.17.0 // indirect + golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect + golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect + golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect + golang.org/x/text v0.3.7 // indirect + golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect + google.golang.org/appengine v1.6.5 // indirect + google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect + google.golang.org/protobuf v1.27.1 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/ini.v1 v1.51.0 // indirect + k8s.io/api v0.22.2 // indirect + k8s.io/apiserver v0.20.2 // indirect + k8s.io/component-base v0.20.2 // indirect + k8s.io/klog v1.0.0 // indirect + k8s.io/klog/v2 v2.9.0 // indirect + k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7 // indirect + k8s.io/mount-utils v0.0.0 // indirect + k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect + sigs.k8s.io/yaml v1.2.0 // indirect +) + replace ( + github.com/dell/gounity => github.com/dell/gounity v1.8.1-0.20220117113341-b5ac52a19020 k8s.io/api => k8s.io/api v0.20.2 k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.20.2 k8s.io/apimachinery => k8s.io/apimachinery v0.20.2 diff --git a/go.sum b/go.sum index 17b7750..ec130e5 100644 --- a/go.sum +++ b/go.sum @@ -163,8 +163,8 @@ github.com/dell/gofsutil v1.6.0/go.mod h1:98Wpcg7emz4iGgY16fd4MKpnal2SX2hBiwP5gh github.com/dell/goiscsi v1.1.0/go.mod h1:MfuMjbKWsh/MOb0VDW20C+LFYRIOfWKGiAxWkeM5TKo= github.com/dell/goiscsi v1.2.0 h1:ocQs4pz2Fw2vr73RVAQBKwpN468SK4TZHPLhU7/FB9A= github.com/dell/goiscsi v1.2.0/go.mod h1:MfuMjbKWsh/MOb0VDW20C+LFYRIOfWKGiAxWkeM5TKo= -github.com/dell/gounity v1.8.0 h1:lhzocqNT9/kmrVYadNo3o3U/khExnOzdrcuyeykkr8w= -github.com/dell/gounity v1.8.0/go.mod h1:ZFe4e0oPHaN4nF6QLGqxBSGpKETuaGH4WGYGLkSthMU= +github.com/dell/gounity v1.8.1-0.20220117113341-b5ac52a19020 h1:rQTo2CRhN9LhVI7bsdFCcWMdFnoEfznpDENNjtjmtlI= +github.com/dell/gounity v1.8.1-0.20220117113341-b5ac52a19020/go.mod h1:/pJuIzJHLh0icQcJftVsfmKAv/Y4c5tKMIpVN/pfV0c= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= @@ -599,6 +599,7 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1: github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= @@ -681,6 +682,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -719,8 +721,8 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 h1:ADo5wSpq2gqaCGQWzk7S5vd//0iyyLeAratkEoG5dLE= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -797,8 +799,9 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= @@ -810,8 +813,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -865,6 +869,7 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/service/controller.go b/service/controller.go index 2393f02..932dd43 100644 --- a/service/controller.go +++ b/service/controller.go @@ -182,7 +182,7 @@ func (s *service) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest filesystem, _ := fileAPI.FindFilesystemByName(ctx, volName) if filesystem != nil { content := filesystem.FileContent - if int64(content.SizeTotal) == size && content.NASServer.Id == nasServer && content.Pool.Id == storagePool { + if int64(content.SizeTotal) == size && content.NASServer.ID == nasServer && content.Pool.ID == storagePool { log.Info("Filesystem exists in the requested state with same size, NAS server and storage pool") filesystem.FileContent.SizeTotal -= AdditionalFilesystemSize return utils.GetVolumeResponseFromFilesystem(filesystem, arrayID, protocol, preferredAccessibility), nil @@ -234,7 +234,7 @@ func (s *service) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest return nil, status.Error(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "HostIOLimitName %s not found. Error: %v", hostIOLimitName, err)) } - hostIOLimitID = hostIOLimit.IoLimitPolicyContent.Id + hostIOLimitID = hostIOLimit.IoLimitPolicyContent.ID } //Idempotency check @@ -306,7 +306,7 @@ func (s *service) DeleteVolume( if err == nil { log.Debugf("DeleteVolume successful for volid: [%s]", req.VolumeId) return deleteVolumeResp, nil - } else if err == gounity.FilesystemNotFoundError || err == gounity.VolumeNotFoundError || snapErr == gounity.SnapshotNotFoundError { + } else if err == gounity.ErrorFilesystemNotFound || err == gounity.ErrorVolumeNotFound || snapErr == gounity.ErrorSnapshotNotFound { log.Debug("Volume not found on array") log.Debugf("DeleteVolume successful for volid: [%s]", req.VolumeId) return deleteVolumeResp, nil @@ -393,11 +393,11 @@ func (s *service) ControllerUnpublishVolume( if protocol != NFS { volumeAPI := gounity.NewVolume(unity) - vol, err := volumeAPI.FindVolumeById(ctx, volID) + vol, err := volumeAPI.FindVolumeByID(ctx, volID) if err != nil { // If the volume isn't found, k8s will retry Controller Unpublish forever so... // There is no way back if volume isn't found and so considering this scenario idempotent - if err == gounity.VolumeNotFoundError { + if err == gounity.ErrorVolumeNotFound { log.Debugf("Volume %s not found on the array %s during Controller Unpublish. Hence considering the call to be idempotent", volID, arrayID) return &csi.ControllerUnpublishVolumeResponse{}, nil } @@ -454,7 +454,7 @@ func (s *service) ValidateVolumeCapabilities(ctx context.Context, req *csi.Valid } volumeAPI := gounity.NewVolume(unity) - _, err = volumeAPI.FindVolumeById(ctx, volID) + _, err = volumeAPI.FindVolumeByID(ctx, volID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Volume not found. Error: %v", err)) } @@ -538,7 +538,7 @@ func (s *service) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotReq snapAPI := gounity.NewSnapshot(unity) //Idempotency check - snap, err := snapAPI.FindSnapshotById(ctx, snapID) + snap, err := snapAPI.FindSnapshotByID(ctx, snapID) //snapshot exists, continue deleting the snapshot if err != nil { log.Info("Snapshot doesn't exists") @@ -752,10 +752,10 @@ func (s *service) ControllerExpandVolume(ctx context.Context, req *csi.Controlle capacity += AdditionalFilesystemSize filesystemAPI := gounity.NewFilesystem(unity) - filesystem, err := filesystemAPI.FindFilesystemById(ctx, volID) + filesystem, err := filesystemAPI.FindFilesystemByID(ctx, volID) if err != nil { snapshotAPI := gounity.NewSnapshot(unity) - _, err = snapshotAPI.FindSnapshotById(ctx, volID) + _, err = snapshotAPI.FindSnapshotByID(ctx, volID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find filesystem %s failed with error: %v", volID, err)) } @@ -777,7 +777,7 @@ func (s *service) ControllerExpandVolume(ctx context.Context, req *csi.Controlle return nil, status.Error(codes.Unknown, utils.GetMessageWithRunID(rid, "Expand filesystem failed with error: %v", err)) } - filesystem, err = filesystemAPI.FindFilesystemById(ctx, volID) + filesystem, err = filesystemAPI.FindFilesystemByID(ctx, volID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find filesystem failed with error: %v", err)) } @@ -787,7 +787,7 @@ func (s *service) ControllerExpandVolume(ctx context.Context, req *csi.Controlle } volumeAPI := gounity.NewVolume(unity) //Idempotency check - volume, err := volumeAPI.FindVolumeById(ctx, volID) + volume, err := volumeAPI.FindVolumeByID(ctx, volID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find volume failed with error: %v", err)) } @@ -812,7 +812,7 @@ func (s *service) ControllerExpandVolume(ctx context.Context, req *csi.Controlle return nil, status.Error(codes.Unknown, utils.GetMessageWithRunID(rid, "Expand volume failed with error: %v", err)) } - volume, err = volumeAPI.FindVolumeById(ctx, volID) + volume, err = volumeAPI.FindVolumeByID(ctx, volID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find volume failed with error: %v", err)) } @@ -829,11 +829,11 @@ func (s *service) getCSIVolumes(volumes []types.Volume) ([]*csi.ListVolumesRespo "Name": vol.VolumeContent.Name, "Type": strconv.Itoa(vol.VolumeContent.Type), "Wwn": vol.VolumeContent.Wwn, - "StoragePoolID": vol.VolumeContent.Pool.Id, + "StoragePoolID": vol.VolumeContent.Pool.ID, } //Create CSI volume vi := &csi.Volume{ - VolumeId: vol.VolumeContent.ResourceId, + VolumeId: vol.VolumeContent.ResourceID, CapacityBytes: int64(vol.VolumeContent.SizeTotal), VolumeContext: attributes, } @@ -858,7 +858,7 @@ func (s *service) getCSISnapshots(snaps []types.Snapshot, volID, protocol, array timestamp, _ = ptypes.TimestampProto(snap.SnapshotContent.CreationTime) } - snapID := fmt.Sprintf("%s-%s-%s-%s", snap.SnapshotContent.Name, protocol, arrayID, snap.SnapshotContent.ResourceId) + snapID := fmt.Sprintf("%s-%s-%s-%s", snap.SnapshotContent.Name, protocol, arrayID, snap.SnapshotContent.ResourceID) size := snap.SnapshotContent.Size if protocol == NFS { @@ -889,11 +889,11 @@ func (s *service) getFilesystemByResourceID(ctx context.Context, resourceID, arr } filesystemAPI := gounity.NewFilesystem(unity) - filesystemID, err := filesystemAPI.GetFilesystemIdFromResId(ctx, resourceID) + filesystemID, err := filesystemAPI.GetFilesystemIDFromResID(ctx, resourceID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Storage resource: %s filesystem Id not found. Error: %v", resourceID, err)) } - sourceFilesystemResp, err := filesystemAPI.FindFilesystemById(ctx, filesystemID) + sourceFilesystemResp, err := filesystemAPI.FindFilesystemByID(ctx, filesystemID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Filesystem: %s not found. Error: %v", filesystemID, err)) } @@ -935,15 +935,15 @@ func (s *service) createIdempotentSnapshot(ctx context.Context, snapshotName, so var filesystemResp *types.Filesystem if protocol == NFS { fileAPI := gounity.NewFilesystem(unity) - filesystemResp, err = fileAPI.FindFilesystemById(ctx, sourceVolID) + filesystemResp, err = fileAPI.FindFilesystemByID(ctx, sourceVolID) if err != nil { snapshotAPI := gounity.NewSnapshot(unity) - snapResp, err = snapshotAPI.FindSnapshotById(ctx, sourceVolID) + snapResp, err = snapshotAPI.FindSnapshotByID(ctx, sourceVolID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find source filesystem: %s failed with error: %v", sourceVolID, err)) } isSnapshot = true - filesystemResp, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.Id, arrayID) + filesystemResp, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.ID, arrayID) if err != nil { return nil, err } @@ -951,12 +951,12 @@ func (s *service) createIdempotentSnapshot(ctx context.Context, snapshotName, so } if protocol == NFS && !isSnapshot { - sourceVolID = filesystemResp.FileContent.StorageResource.Id + sourceVolID = filesystemResp.FileContent.StorageResource.ID } snap, _ := snapshotAPI.FindSnapshotByName(ctx, snapshotName) if snap != nil { - if snap.SnapshotContent.StorageResource.Id == sourceVolID || (isSnapshot && snap.SnapshotContent.StorageResource.Id == filesystemResp.FileContent.StorageResource.Id) { + if snap.SnapshotContent.StorageResource.ID == sourceVolID || (isSnapshot && snap.SnapshotContent.StorageResource.ID == filesystemResp.FileContent.StorageResource.ID) { //Subtract AdditionalFilesystemSize for Filesystem snapshots if protocol == NFS { snap.SnapshotContent.Size -= AdditionalFilesystemSize @@ -964,7 +964,7 @@ func (s *service) createIdempotentSnapshot(ctx context.Context, snapshotName, so log.Infof("Snapshot already exists with same name %s for same storage resource %s", snapshotName, sourceVolID) return snap, nil } - return nil, status.Error(codes.AlreadyExists, utils.GetMessageWithRunID(rid, "Snapshot with same name %s already exists for storage resource %s", snapshotName, snap.SnapshotContent.StorageResource.Id)) + return nil, status.Error(codes.AlreadyExists, utils.GetMessageWithRunID(rid, "Snapshot with same name %s already exists for storage resource %s", snapshotName, snap.SnapshotContent.StorageResource.ID)) } var newSnapshot *types.Snapshot @@ -973,9 +973,9 @@ func (s *service) createIdempotentSnapshot(ctx context.Context, snapshotName, so if err != nil { return nil, status.Error(codes.Unknown, utils.GetMessageWithRunID(rid, "Create Snapshot error: %v", err)) } - err = snapshotAPI.ModifySnapshot(ctx, newSnapshot.SnapshotContent.ResourceId, description, retentionDuration) + err = snapshotAPI.ModifySnapshot(ctx, newSnapshot.SnapshotContent.ResourceID, description, retentionDuration) if err != nil { - log.Infof("Unable to modify description and retention duration in created snapshot %s. Error: %s", newSnapshot.SnapshotContent.ResourceId, err) + log.Infof("Unable to modify description and retention duration in created snapshot %s. Error: %s", newSnapshot.SnapshotContent.ResourceID, err) } } else { if isClone { @@ -1009,12 +1009,12 @@ func (s *service) getHostID(ctx context.Context, arrayID, shortHostname, longHos hostAPI := gounity.NewHost(unity) host, err := hostAPI.FindHostByName(ctx, shortHostname) if err != nil { - if err != gounity.HostNotFoundError { + if err != gounity.ErrorHostNotFound { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find Host Failed %v", err)) } } if host != nil { - for _, hostIPPort := range host.HostContent.IpPorts { + for _, hostIPPort := range host.HostContent.IPPorts { if hostIPPort.Address == longHostname { return host, nil } @@ -1025,7 +1025,7 @@ func (s *service) getHostID(ctx context.Context, arrayID, shortHostname, longHos if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find Host Failed %v", err)) } - for _, hostIPPort := range host.HostContent.IpPorts { + for _, hostIPPort := range host.HostContent.IPPorts { if hostIPPort.Address == longHostname { return host, nil } @@ -1064,19 +1064,19 @@ func (s *service) createVolumeClone(ctx context.Context, crParams *CRParams, sou snapAPI := gounity.NewSnapshot(unity) fileAPI := gounity.NewFilesystem(unity) - filesystem, err := fileAPI.FindFilesystemById(ctx, sourceVolID) + filesystem, err := fileAPI.FindFilesystemByID(ctx, sourceVolID) isSnapshot := false var snapResp *types.Snapshot var snapErr error if err != nil { //Filesystem not found - Check if PVC exists as a snapshot [Cloned volume in case of NFS] - snapResp, snapErr = snapAPI.FindSnapshotById(ctx, sourceVolID) + snapResp, snapErr = snapAPI.FindSnapshotByID(ctx, sourceVolID) if snapErr != nil { log.Debugf("Tried to check if PVC exists as a snapshot: %v", snapErr) return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find source filesystem: %s Failed. Error: %v ", sourceVolID, err)) } isSnapshot = true - filesystem, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.Id, arrayID) + filesystem, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.ID, arrayID) if err != nil { return nil, err } @@ -1126,7 +1126,7 @@ func (s *service) createVolumeClone(ctx context.Context, crParams *CRParams, sou //If protocol is FC or iSCSI volumeAPI := gounity.NewVolume(unity) - sourceVolResp, err := volumeAPI.FindVolumeById(ctx, sourceVolID) + sourceVolResp, err := volumeAPI.FindVolumeByID(ctx, sourceVolID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Source volume not found: %s. Error: %v", sourceVolID, err)) } @@ -1139,7 +1139,7 @@ func (s *service) createVolumeClone(ctx context.Context, crParams *CRParams, sou volResp, _ := volumeAPI.FindVolumeByName(ctx, volName) if volResp != nil { //Idempotency Check - if volResp.VolumeContent.IsThinClone && len(volResp.VolumeContent.ParentVolume.Id) > 0 && volResp.VolumeContent.ParentVolume.Id == sourceVolID && + if volResp.VolumeContent.IsThinClone && len(volResp.VolumeContent.ParentVolume.ID) > 0 && volResp.VolumeContent.ParentVolume.ID == sourceVolID && volResp.VolumeContent.SizeTotal == sourceVolResp.VolumeContent.SizeTotal { log.Infof("Volume %s exists in the requested state as a clone of volume %s", volName, sourceVolResp.VolumeContent.Name) csiVolResp := utils.GetVolumeResponseFromVolume(volResp, arrayID, protocol, preferredAccessibility) @@ -1152,9 +1152,9 @@ func (s *service) createVolumeClone(ctx context.Context, crParams *CRParams, sou //Perform volume cloning volResp, err = volumeAPI.CreateCloneFromVolume(ctx, volName, sourceVolID) if err != nil { - if err == gounity.CreateSnapshotFailedError { + if err == gounity.ErrorCreateSnapshotFailed { return nil, status.Error(codes.Unknown, utils.GetMessageWithRunID(rid, "Unable to Create Snapshot for Volume Cloning for source volume: %s", sourceVolID)) - } else if err == gounity.CloningFailedError { + } else if err == gounity.ErrorCloningFailed { return nil, status.Error(codes.Unknown, utils.GetMessageWithRunID(rid, "Volume cloning for source volume: %s failed.", sourceVolID)) } } @@ -1195,14 +1195,14 @@ func (s *service) createVolumeFromSnap(ctx context.Context, crParams *CRParams, hostIoSize := crParams.HostIoSize snapAPI := gounity.NewSnapshot(unity) - snapResp, err := snapAPI.FindSnapshotById(ctx, snapshotID) + snapResp, err := snapAPI.FindSnapshotByID(ctx, snapshotID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Source snapshot not found: %s", snapshotID)) } if protocol == NFS { - sourceFilesystemResp, err := s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.Id, arrayID) + sourceFilesystemResp, err := s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.ID, arrayID) if err != nil { return nil, err } @@ -1220,7 +1220,7 @@ func (s *service) createVolumeFromSnap(ctx context.Context, crParams *CRParams, snapResp, err := snapAPI.FindSnapshotByName(ctx, volName) if snapResp != nil { //Idempotency check - if snapResp.SnapshotContent.ParentSnap.Id == snapshotID && snapResp.SnapshotContent.AccessType == int(gounity.ProtocolAccessType) { + if snapResp.SnapshotContent.ParentSnap.ID == snapshotID && snapResp.SnapshotContent.AccessType == int(gounity.ProtocolAccessType) { log.Infof("Filesystem %s exists in the requested state as a volume from snapshot(snapshot on array) %s", volName, snapshotID) snapResp.SnapshotContent.Size -= AdditionalFilesystemSize csiVolResp := utils.GetVolumeResponseFromSnapshot(snapResp, arrayID, protocol, preferredAccessibility) @@ -1246,9 +1246,9 @@ func (s *service) createVolumeFromSnap(ctx context.Context, crParams *CRParams, } //If protocol is FC or iSCSI - volID := snapResp.SnapshotContent.StorageResource.Id + volID := snapResp.SnapshotContent.StorageResource.ID volumeAPI := gounity.NewVolume(unity) - sourceVolResp, err := volumeAPI.FindVolumeById(ctx, volID) + sourceVolResp, err := volumeAPI.FindVolumeByID(ctx, volID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Source volume not found: %s", volID)) } @@ -1266,7 +1266,7 @@ func (s *service) createVolumeFromSnap(ctx context.Context, crParams *CRParams, volResp, _ := volumeAPI.FindVolumeByName(ctx, volName) if volResp != nil { //Idempotency Check - if volResp.VolumeContent.IsThinClone == true && len(volResp.VolumeContent.ParentSnap.Id) > 0 && volResp.VolumeContent.ParentSnap.Id == snapshotID { + if volResp.VolumeContent.IsThinClone == true && len(volResp.VolumeContent.ParentSnap.ID) > 0 && volResp.VolumeContent.ParentSnap.ID == snapshotID { log.Info("Volume exists in the requested state") csiVolResp := utils.GetVolumeResponseFromVolume(volResp, arrayID, protocol, preferredAccessibility) csiVolResp.Volume.ContentSource = contentSource @@ -1305,14 +1305,14 @@ func (s *service) deleteFilesystem(ctx context.Context, volID string, unity *gou fileAPI := gounity.NewFilesystem(unity) var filesystemResp *types.Filesystem var snapErr error - filesystemResp, err := fileAPI.FindFilesystemById(ctx, volID) + filesystemResp, err := fileAPI.FindFilesystemByID(ctx, volID) if err == nil { //Validate if filesystem has any NFS or SMB shares or snapshots attached if len(filesystemResp.FileContent.NFSShare) > 0 || len(filesystemResp.FileContent.CIFSShare) > 0 { return nil, nil, status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Filesystem %s can not be deleted as it has associated NFS or SMB shares.", volID)) } snapshotAPI := gounity.NewSnapshot(unity) - snapsResp, _, snapshotErr := snapshotAPI.ListSnapshots(ctx, 0, 0, filesystemResp.FileContent.StorageResource.Id, "") + snapsResp, _, snapshotErr := snapshotAPI.ListSnapshots(ctx, 0, 0, filesystemResp.FileContent.StorageResource.ID, "") if snapshotErr != nil { return nil, nil, status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "List snapshots for filesystem %s failed with error: %v", volID, snapshotErr)) } @@ -1326,20 +1326,20 @@ func (s *service) deleteFilesystem(ctx context.Context, volID string, unity *gou } else { //Do not reuse err as it is used for idempotency check snapshotAPI := gounity.NewSnapshot(unity) - snapResp, fsSnapErr := snapshotAPI.FindSnapshotById(ctx, volID) + snapResp, fsSnapErr := snapshotAPI.FindSnapshotByID(ctx, volID) snapErr = fsSnapErr if fsSnapErr == nil { //Validate if snapshot has any NFS or SMB shares - sourceVolID, err := fileAPI.GetFilesystemIdFromResId(ctx, snapResp.SnapshotContent.StorageResource.Id) + sourceVolID, err := fileAPI.GetFilesystemIDFromResID(ctx, snapResp.SnapshotContent.StorageResource.ID) if err != nil { - return nil, nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Source storage resource: %s filesystem Id not found. Error: %v", snapResp.SnapshotContent.StorageResource.Id, err)) + return nil, nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Source storage resource: %s filesystem Id not found. Error: %v", snapResp.SnapshotContent.StorageResource.ID, err)) } - filesystemResp, err = fileAPI.FindFilesystemById(ctx, sourceVolID) + filesystemResp, err = fileAPI.FindFilesystemByID(ctx, sourceVolID) if err != nil { return nil, nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find source filesystem: %s failed with error: %v", sourceVolID, err)) } for _, nfsShare := range filesystemResp.FileContent.NFSShare { - if nfsShare.ParentSnap.Id == volID { + if nfsShare.ParentSnap.ID == volID { return nil, nil, status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Snapshot %s can not be deleted as it has associated NFS or SMB shares.", volID)) } } @@ -1364,7 +1364,7 @@ func (s *service) deleteBlockVolume(ctx context.Context, volID string, unity *go snapshotName := snapResp.SnapshotContent.Name if strings.Contains(snapshotName, gounity.SnapForClone) { reqDeleteSnapshot := new(csi.DeleteSnapshotRequest) - reqDeleteSnapshot.SnapshotId = snapResp.SnapshotContent.ResourceId + reqDeleteSnapshot.SnapshotId = snapResp.SnapshotContent.ResourceID _, snapshotErr = s.DeleteSnapshot(ctx, reqDeleteSnapshot) if snapshotErr != nil { return nil, status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Volume %s can not be deleted as it has associated snapshots.", volID)) @@ -1388,18 +1388,18 @@ func (s *service) exportFilesystem(ctx context.Context, volID, hostID, nodeID, a pinfo["filesystem"] = volID fileAPI := gounity.NewFilesystem(unity) isSnapshot := false - filesystemResp, err := fileAPI.FindFilesystemById(ctx, volID) + filesystemResp, err := fileAPI.FindFilesystemByID(ctx, volID) var snapResp *types.Snapshot if err != nil { snapshotAPI := gounity.NewSnapshot(unity) - snapResp, err = snapshotAPI.FindSnapshotById(ctx, volID) + snapResp, err = snapshotAPI.FindSnapshotByID(ctx, volID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find filesystem: %s failed with error: %v", volID, err)) } isSnapshot = true - filesystemResp, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.Id, arrayID) + filesystemResp, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.ID, arrayID) if err != nil { return nil, err } @@ -1413,16 +1413,16 @@ func (s *service) exportFilesystem(ctx context.Context, volID, hostID, nodeID, a var nfsShareID string for _, nfsShare := range filesystemResp.FileContent.NFSShare { if isSnapshot { - if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.Id == volID { + if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.ID == volID { nfsShareExist = true nfsShareName = nfsShare.Name - nfsShareID = nfsShare.Id + nfsShareID = nfsShare.ID } } else { - if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.Id == "" { + if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.ID == "" { nfsShareExist = true nfsShareName = nfsShare.Name - nfsShareID = nfsShare.Id + nfsShareID = nfsShare.ID } } } @@ -1432,7 +1432,7 @@ func (s *service) exportFilesystem(ctx context.Context, volID, hostID, nodeID, a if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Create NFS Share failed. Error: %v", err)) } - nfsShareID = nfsShareResp.NFSShareContent.Id + nfsShareID = nfsShareResp.NFSShareContent.ID } else { filesystemResp, err = fileAPI.CreateNFSShare(ctx, nfsShareName, NFSShareLocalPath, volID, gounity.NoneDefaultAccess) if err != nil { @@ -1441,13 +1441,13 @@ func (s *service) exportFilesystem(ctx context.Context, volID, hostID, nodeID, a } for _, nfsShare := range filesystemResp.FileContent.NFSShare { if nfsShare.Name == nfsShareName { - nfsShareID = nfsShare.Id + nfsShareID = nfsShare.ID } } } //Allocate host access to NFS Share with appropriate access mode - nfsShareResp, err := fileAPI.FindNFSShareById(ctx, nfsShareID) + nfsShareResp, err := fileAPI.FindNFSShareByID(ctx, nfsShareID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find NFS Share: %s failed. Error: %v", nfsShareID, err)) } @@ -1551,7 +1551,7 @@ func (s *service) exportVolume(ctx context.Context, protocol, volID, hostID, nod } volumeAPI := gounity.NewVolume(unity) - vol, err := volumeAPI.FindVolumeById(ctx, volID) + vol, err := volumeAPI.FindVolumeByID(ctx, volID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find volume Failed %v", err)) } @@ -1592,22 +1592,22 @@ func (s *service) unexportFilesystem(ctx context.Context, volID, hostID, nodeID, ctx, log, rid := GetRunidLog(ctx) fileAPI := gounity.NewFilesystem(unity) isSnapshot := false - filesystem, err := fileAPI.FindFilesystemById(ctx, volID) + filesystem, err := fileAPI.FindFilesystemByID(ctx, volID) var snapResp *types.Snapshot if err != nil { snapshotAPI := gounity.NewSnapshot(unity) - snapResp, err = snapshotAPI.FindSnapshotById(ctx, volID) + snapResp, err = snapshotAPI.FindSnapshotByID(ctx, volID) if err != nil { - // If the filesysten isn't found, k8s will retry Controller Unpublish forever so... + // If the filesystem isn't found, k8s will retry Controller Unpublish forever so... // There is no way back if filesystem isn't found and so considering this scenario idempotent - if err == gounity.FilesystemNotFoundError || err == gounity.SnapshotNotFoundError { + if err == gounity.ErrorFilesystemNotFound || err == gounity.ErrorSnapshotNotFound { log.Debugf("Filesystem %s not found on the array %s during Controller Unpublish. Hence considering the call to be idempotent", volID, arrayID) return nil } return status.Error(codes.Internal, utils.GetMessageWithRunID(rid, "Find filesystem %s failed with error: %v", volID, err)) } isSnapshot = true - filesystem, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.Id, arrayID) + filesystem, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.ID, arrayID) if err != nil { return err } @@ -1622,24 +1622,24 @@ func (s *service) unexportFilesystem(ctx context.Context, volID, hostID, nodeID, var nfsShareID string for _, nfsShare := range filesystem.FileContent.NFSShare { if isSnapshot { - if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.Id == volID { + if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.ID == volID { shareExists = true if nfsShare.Name != nfsShareName { //This means that share was created manually on array, hence don't delete via driver deleteShare = false nfsShareName = nfsShare.Name } - nfsShareID = nfsShare.Id + nfsShareID = nfsShare.ID } } else { - if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.Id == "" { + if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.ID == "" { shareExists = true if nfsShare.Name != nfsShareName { //This means that share was created manually on array, hence don't delete via driver deleteShare = false nfsShareName = nfsShare.Name } - nfsShareID = nfsShare.Id + nfsShareID = nfsShare.ID } } } @@ -1648,7 +1648,7 @@ func (s *service) unexportFilesystem(ctx context.Context, volID, hostID, nodeID, return nil } - nfsShareResp, err := fileAPI.FindNFSShareById(ctx, nfsShareID) + nfsShareResp, err := fileAPI.FindNFSShareByID(ctx, nfsShareID) if err != nil { return status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find NFS Share: %s failed. Error: %v", nfsShareID, err)) } @@ -1731,7 +1731,7 @@ func (s *service) unexportFilesystem(ctx context.Context, volID, hostID, nodeID, if isSnapshot { err = fileAPI.DeleteNFSShareCreatedFromSnapshot(ctx, nfsShareID) } else { - err = fileAPI.DeleteNFSShare(ctx, filesystem.FileContent.Id, nfsShareID) + err = fileAPI.DeleteNFSShare(ctx, filesystem.FileContent.ID, nfsShareID) } if err != nil { return status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Delete NFS Share: %s Failed with error: %v", nfsShareID, err)) @@ -1799,9 +1799,9 @@ func (s *service) ControllerGetVolume(ctx context.Context, if protocol != NFS { volumeAPI := gounity.NewVolume(unity) - vol, err := volumeAPI.FindVolumeById(ctx, volID) + vol, err := volumeAPI.FindVolumeByID(ctx, volID) if err != nil { - if err != gounity.VolumeNotFoundError { + if err != gounity.ErrorVolumeNotFound { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find volume failed with error: %v", err)) } abnormal = true @@ -1828,14 +1828,14 @@ func (s *service) ControllerGetVolume(ctx context.Context, } else { fileAPI := gounity.NewFilesystem(unity) isSnapshot := false - filesystem, err := fileAPI.FindFilesystemById(ctx, volID) + filesystem, err := fileAPI.FindFilesystemByID(ctx, volID) if err != nil { var snapResp *types.Snapshot snapshotAPI := gounity.NewSnapshot(unity) - snapResp, err = snapshotAPI.FindSnapshotById(ctx, volID) + snapResp, err = snapshotAPI.FindSnapshotByID(ctx, volID) if err != nil { - if err != gounity.SnapshotNotFoundError { + if err != gounity.ErrorSnapshotNotFound { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find filesystem: %s failed with error: %v", volID, err)) } abnormal = true @@ -1844,7 +1844,7 @@ func (s *service) ControllerGetVolume(ctx context.Context, isSnapshot = true if !abnormal { - filesystem, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.Id, arrayID) + filesystem, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.ID, arrayID) if err != nil { return nil, err } @@ -1855,18 +1855,18 @@ func (s *service) ControllerGetVolume(ctx context.Context, nfsShareID := "" for _, nfsShare := range filesystem.FileContent.NFSShare { if isSnapshot { - if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.Id == volID { - nfsShareID = nfsShare.Id + if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.ID == volID { + nfsShareID = nfsShare.ID } } else { - if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.Id == "" { - nfsShareID = nfsShare.Id + if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.ID == "" { + nfsShareID = nfsShare.ID } } } if nfsShareID != "" { - nfsShareResp, err := fileAPI.FindNFSShareById(ctx, nfsShareID) + nfsShareResp, err := fileAPI.FindNFSShareByID(ctx, nfsShareID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find NFS Share: %s failed. Error: %v", nfsShareID, err)) } diff --git a/service/csi_extension_server.go b/service/csi_extension_server.go index a283e92..c1784a6 100644 --- a/service/csi_extension_server.go +++ b/service/csi_extension_server.go @@ -291,7 +291,7 @@ func (s *service) checkIfNodeIsConnected(ctx context.Context, arrayID string, no if host != nil && len(host.HostContent.FcInitiators) != 0 { log.Infof("Got FC Initiators, Checking health of initiators:%s", host.HostContent.FcInitiators) for _, initiator := range host.HostContent.FcInitiators { - initiatorID := initiator.Id + initiatorID := initiator.ID hostInitiator, err := FindHostInitiatorByID(ctx, unity, initiatorID) if err != nil { log.Infof("Unable to get initiators: %s", err) @@ -316,7 +316,7 @@ func (s *service) checkIfNodeIsConnected(ctx context.Context, arrayID string, no if host != nil && len(host.HostContent.IscsiInitiators) != 0 && !fcConnectivity { log.Infof("Got iSCSI Initiators, Checking health of initiators:%s", host.HostContent.IscsiInitiators) for _, initiator := range host.HostContent.IscsiInitiators { - initiatorID := initiator.Id + initiatorID := initiator.ID hostInitiator, err := FindHostInitiatorByID(ctx, unity, initiatorID) if err != nil { log.Infof("Unable to get initiators: %s", err) @@ -527,7 +527,7 @@ func (s *service) getMetrics(ctx context.Context, arrayID string, metrics []stri return nil, createErr } - log.Infof("Metrics collection %d created for %s", collection.Content.Id, arrayID) + log.Infof("Metrics collection %d created for %s", collection.Content.ID, arrayID) // Wait a bit before trying the first query time.Sleep(time.Duration(CollectionWait) * time.Millisecond) @@ -536,16 +536,16 @@ func (s *service) getMetrics(ctx context.Context, arrayID string, metrics []stri getMetricCtx, getMetricCancel := context.WithTimeout(context.Background(), MetricsTimeout) defer getMetricCancel() // Cache the collection Id for subsequent use (above, when there is a cache hit) - results, getErr := GetMetricsCollection(getMetricCtx, s, arrayID, collection.Content.Id) + results, getErr := GetMetricsCollection(getMetricCtx, s, arrayID, collection.Content.ID) if getErr != nil { return nil, getErr } - metricsCollectionCache.Store(cacheKey, collection.Content.Id) + metricsCollectionCache.Store(cacheKey, collection.Content.ID) // Reset this counter so that we can continue to "keep-alive" collections for some time. refreshCount.Store(0) - log.Infof("Successfully queried metrics collection %d for %s", collection.Content.Id, arrayID) + log.Infof("Successfully queried metrics collection %d for %s", collection.Content.ID, arrayID) return results, nil } @@ -638,7 +638,7 @@ func getUnityClient(ctx context.Context, s *service, arrayID string) (*gounity.C func findHostInitiatorByID(ctx context.Context, unity *gounity.Client, wwnOrIqn string) (*types.HostInitiator, error) { hostAPI := gounity.NewHost(unity) - return hostAPI.FindHostInitiatorById(ctx, wwnOrIqn) + return hostAPI.FindHostInitiatorByID(ctx, wwnOrIqn) } func getMetricsCollection(ctx context.Context, s *service, arrayID string, id int) (*types.MetricQueryResult, error) { diff --git a/service/csi_extension_test.go b/service/csi_extension_test.go index 505aee2..0b1bc12 100644 --- a/service/csi_extension_test.go +++ b/service/csi_extension_test.go @@ -370,7 +370,7 @@ func TestValidateVolumeHostConnectivityISCSI(t *testing.T) { GetHostID = func(ctx context.Context, s *service, arrayId, shortHostname, longHostname string) (*types.Host, error) { return mockHost, nil } - mockBadInitiator = mockHost.HostContent.IscsiInitiators[0].Id + mockBadInitiator = mockHost.HostContent.IscsiInitiators[0].ID }, cleanup: func() { testConf.service.arrays.Delete("array1") @@ -393,7 +393,7 @@ func TestValidateVolumeHostConnectivityISCSI(t *testing.T) { GetHostID = func(ctx context.Context, s *service, arrayId, shortHostname, longHostname string) (*types.Host, error) { return mockHost, nil } - mockBadInitiator = mockHost.HostContent.IscsiInitiators[0].Id + mockBadInitiator = mockHost.HostContent.IscsiInitiators[0].ID }, cleanup: func() { testConf.service.arrays.Delete("array1") @@ -416,7 +416,7 @@ func TestValidateVolumeHostConnectivityISCSI(t *testing.T) { GetHostID = func(ctx context.Context, s *service, arrayId, shortHostname, longHostname string) (*types.Host, error) { return mockHost, nil } - mockFindInitatorFail = mockHost.HostContent.IscsiInitiators[0].Id + mockFindInitatorFail = mockHost.HostContent.IscsiInitiators[0].ID mockFindHostInitiatorErr = fmt.Errorf("induced FindHostInitiatorByID error") }, cleanup: func() { @@ -475,7 +475,7 @@ func TestValidateVolumeHostConnectivityFC(t *testing.T) { GetHostID = func(ctx context.Context, s *service, arrayId, shortHostname, longHostname string) (*types.Host, error) { return mockHost, nil } - mockBadInitiator = mockHost.HostContent.FcInitiators[0].Id + mockBadInitiator = mockHost.HostContent.FcInitiators[0].ID }, cleanup: func() { testConf.service.arrays.Delete("array1") @@ -498,7 +498,7 @@ func TestValidateVolumeHostConnectivityFC(t *testing.T) { GetHostID = func(ctx context.Context, s *service, arrayId, shortHostname, longHostname string) (*types.Host, error) { return mockHost, nil } - mockBadInitiator = mockHost.HostContent.FcInitiators[0].Id + mockBadInitiator = mockHost.HostContent.FcInitiators[0].ID }, cleanup: func() { testConf.service.arrays.Delete("array1") @@ -521,7 +521,7 @@ func TestValidateVolumeHostConnectivityFC(t *testing.T) { GetHostID = func(ctx context.Context, s *service, arrayId, shortHostname, longHostname string) (*types.Host, error) { return mockHost, nil } - mockFindInitatorFail = mockHost.HostContent.FcInitiators[0].Id + mockFindInitatorFail = mockHost.HostContent.FcInitiators[0].ID mockFindHostInitiatorErr = fmt.Errorf("induced FindHostInitiatorByID error") }, cleanup: func() { @@ -711,7 +711,7 @@ func TestVolumeIOCheck(t *testing.T) { return mockGetMetricsCollection(ctx, s, arrayId, id) } result := types.MetricResult{ - QueryId: id, + QueryID: id, Path: "sp.*.storage.filesystemSummary.clientReadBytes", Timestamp: time.Now().String(), Values: map[string]interface{}{ @@ -999,7 +999,7 @@ func TestFileSystemIOCheck(t *testing.T) { return mockNfsMetricResult(id, read, write), nil } result := types.MetricResult{ - QueryId: id, + QueryID: id, Path: "sp.*.storage.lun.*.currentIOs", Timestamp: time.Now().String(), Values: map[string]interface{}{ @@ -1419,7 +1419,7 @@ func TestParallelIOCheck(t *testing.T) { Expiration: "mockExpiration", Interval: interval, Paths: metricPaths, - Id: 2, + ID: 2, }, }, nil } @@ -1528,7 +1528,7 @@ func TestMetricsRefresher(t *testing.T) { Expiration: "mockExpiration", Interval: interval, Paths: metricPaths, - Id: 2, + ID: 2, }, }, nil } @@ -1739,11 +1739,11 @@ func mockStorage(ctx context.Context) *StorageArrayConfig { func mockAHost(name string, iScsiPorts, fcPorts int) *types.Host { mockISCSI := make([]types.Initiators, 0) for i := 0; i < iScsiPorts; i++ { - mockISCSI = append(mockISCSI, types.Initiators{Id: fmt.Sprintf("mock_%s_iscsi_initiator_%d", name, i)}) + mockISCSI = append(mockISCSI, types.Initiators{ID: fmt.Sprintf("mock_%s_iscsi_initiator_%d", name, i)}) } mockFC := make([]types.Initiators, 0) for i := 0; i < fcPorts; i++ { - mockFC = append(mockFC, types.Initiators{Id: fmt.Sprintf("mock_%s_fc_initiator_%d", name, i)}) + mockFC = append(mockFC, types.Initiators{ID: fmt.Sprintf("mock_%s_fc_initiator_%d", name, i)}) } mockHost := &types.Host{ HostContent: types.HostContent{ @@ -1752,7 +1752,7 @@ func mockAHost(name string, iScsiPorts, fcPorts int) *types.Host { Description: fmt.Sprintf("Mock test host %s", name), FcInitiators: mockFC, IscsiInitiators: mockISCSI, - IpPorts: nil, + IPPorts: nil, Address: fmt.Sprintf("%s.host.name", name), }, } @@ -1774,12 +1774,12 @@ func mockAnInitiator(id string) *types.HostInitiator { return &types.HostInitiator{ HostInitiatorContent: types.HostInitiatorContent{ - Id: id, + ID: id, Health: types.HealthContent{ DescriptionIDs: descriptions, }, Type: 0, - InitiatorId: id, + InitiatorID: id, IsIgnored: false, Paths: nil, }, @@ -1803,7 +1803,7 @@ func mockCreateMetricsCollection(ctx context.Context, s *service, arrayID string Expiration: "mockExpiration", Interval: interval, Paths: metricPaths, - Id: mockMetricsCollectionID, + ID: mockMetricsCollectionID, }, } return mockCollection, mockCreateMetricsCollectionError @@ -1811,7 +1811,7 @@ func mockCreateMetricsCollection(ctx context.Context, s *service, arrayID string func mockVolMetricResult(id int, currentIOs map[string]interface{}) *types.MetricQueryResult { result := types.MetricResult{ - QueryId: id, + QueryID: id, Path: "sp.*.storage.lun.*.currentIOs", Timestamp: time.Now().String(), Values: currentIOs, @@ -1836,14 +1836,14 @@ func mockVolMetricResult(id int, currentIOs map[string]interface{}) *types.Metri func mockNfsMetricResult(id int, read, write map[string]interface{}) *types.MetricQueryResult { resultR := types.MetricResult{ - QueryId: id, + QueryID: id, Path: "sp.*.storage.filesystem.*.clientReads", Timestamp: time.Now().String(), Values: read, } resultW := types.MetricResult{ - QueryId: id, + QueryID: id, Path: "sp.*.storage.filesystem.*.clientWrites", Timestamp: time.Now().String(), Values: write, diff --git a/service/node.go b/service/node.go index 2da98e6..05a30f3 100644 --- a/service/node.go +++ b/service/node.go @@ -103,7 +103,7 @@ func (s *service) NodeStageVolume( exportPaths := nfsShare.NFSShareContent.ExportPaths if len(exportPaths) == 0 { - return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Export paths not exist on NFS Share: %s", nfsShare.NFSShareContent.Id)) + return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Export paths not exist on NFS Share: %s", nfsShare.NFSShareContent.ID)) } err = stagePublishNFS(ctx, req, exportPaths, arrayID, nfsv3, nfsv4) @@ -116,7 +116,7 @@ func (s *service) NodeStageVolume( //Protocol if FC or iSCSI volumeAPI := gounity.NewVolume(unity) - volume, err := volumeAPI.FindVolumeById(ctx, volID) + volume, err := volumeAPI.FindVolumeByID(ctx, volID) if err != nil { // If the volume isn't found, we cannot stage it return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Volume not found. [%v]", err)) @@ -142,7 +142,7 @@ func (s *service) NodeStageVolume( useFC := false if protocol == ISCSI { - ipInterfaceAPI := gounity.NewIpInterface(unity) + ipInterfaceAPI := gounity.NewIPInterface(unity) ipInterfaces, err := ipInterfaceAPI.ListIscsiIPInterfaces(ctx) if err != nil { return nil, status.Error(codes.Internal, utils.GetMessageWithRunID(rid, "Error retrieving iScsi Interface IPs from the array: [%v]", err)) @@ -165,18 +165,18 @@ func (s *service) NodeStageVolume( } for _, initiator := range host.HostContent.FcInitiators { - hostInitiator, err := hostAPI.FindHostInitiatorById(ctx, initiator.Id) + hostInitiator, err := hostAPI.FindHostInitiatorByID(ctx, initiator.ID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find Host Initiator Failed [%v]", err)) } for _, initiatorPath := range hostInitiator.HostInitiatorContent.Paths { - hostInitiatorPath, err := hostAPI.FindHostInitiatorPathById(ctx, initiatorPath.Id) + hostInitiatorPath, err := hostAPI.FindHostInitiatorPathByID(ctx, initiatorPath.ID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find Host Initiator Path Failed [%v]", err)) } - fcPort, err := hostAPI.FindFcPortById(ctx, hostInitiatorPath.HostInitiatorPathContent.FcPortID.Id) + fcPort, err := hostAPI.FindFcPortByID(ctx, hostInitiatorPath.HostInitiatorPathContent.FcPortID.ID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find Fc port Failed [%v]", err)) } @@ -242,7 +242,7 @@ func (s *service) NodeUnstageVolume( if err != nil { // If the filesysten isn't found, k8s will retry NodeUnstage forever so... // There is no way back if filesystem isn't found and so considering this scenario idempotent - if err == gounity.FilesystemNotFoundError { + if err == gounity.ErrorFilesystemNotFound { log.Debugf("Filesystem %s not found on the array %s during Node Unstage. Hence considering the call to be idempotent", volID, arrayID) return &csi.NodeUnstageVolumeResponse{}, nil } @@ -251,7 +251,7 @@ func (s *service) NodeUnstageVolume( exportPaths := nfsShare.NFSShareContent.ExportPaths if len(exportPaths) == 0 { - return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Export paths not exist on NFS Share: %s", nfsShare.NFSShareContent.Id)) + return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Export paths not exist on NFS Share: %s", nfsShare.NFSShareContent.ID)) } err = unpublishNFS(ctx, stageTgt, arrayID, exportPaths) @@ -280,11 +280,11 @@ func (s *service) NodeUnstageVolume( } volumeAPI := gounity.NewVolume(unity) - volume, err := volumeAPI.FindVolumeById(ctx, volID) + volume, err := volumeAPI.FindVolumeByID(ctx, volID) if err != nil { // If the volume isn't found, k8s will retry NodeUnstage forever so... // There is no way back if volume isn't found and so considering this scenario idempotent - if err == gounity.VolumeNotFoundError { + if err == gounity.ErrorVolumeNotFound { log.Debugf("Volume %s not found on the array %s during Node Unstage. Hence considering the call to be idempotent", volID, arrayID) return &csi.NodeUnstageVolumeResponse{}, nil } @@ -406,7 +406,7 @@ func (s *service) NodePublishVolume( } exportPaths := nfsShare.NFSShareContent.ExportPaths if len(exportPaths) == 0 { - return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Export paths not exist on NFS Share: %s", nfsShare.NFSShareContent.Id)) + return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Export paths not exist on NFS Share: %s", nfsShare.NFSShareContent.ID)) } err = publishNFS(ctx, req, exportPaths, arrayID, s.opts.Chroot, nfsv3, nfsv4, s.opts.AllowRWOMultiPodAccess) if err != nil { @@ -425,7 +425,7 @@ func (s *service) NodePublishVolume( } volumeAPI := gounity.NewVolume(unity) - volume, err := volumeAPI.FindVolumeById(ctx, volID) + volume, err := volumeAPI.FindVolumeByID(ctx, volID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "volume with ID '%s' not found", volID)) } @@ -531,7 +531,7 @@ func (s *service) ephemeralNodePublishVolume( } log.Debug("Ephemeral Node Publish Successful") - f, err := os.Create(path.Join(stagingMountPath, "id")) + f, err := os.Create(filepath.Clean(path.Join(stagingMountPath, "id"))) if err != nil { //Call Ephemeral Node Unpublish for recovery _, _ = s.ephemeralNodeUnpublish(ctx, nodeUnpublishRequest, req.VolumeId) @@ -693,7 +693,7 @@ func (s *service) NodeUnpublishVolume( if err != nil { // If the filesysten isn't found, k8s will retry NodeUnpublish forever so... // There is no way back if filesystem isn't found and so considering this scenario idempotent - if err == gounity.FilesystemNotFoundError { + if err == gounity.ErrorFilesystemNotFound { log.Debugf("Filesystem %s not found on the array %s during Node Unpublish. Hence considering the call to be idempotent", volID, arrayID) return &csi.NodeUnpublishVolumeResponse{}, nil } @@ -701,7 +701,7 @@ func (s *service) NodeUnpublishVolume( } exportPaths := nfsShare.NFSShareContent.ExportPaths if len(exportPaths) == 0 { - return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Export paths not exist on NFS Share: %s", nfsShare.NFSShareContent.Id)) + return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Export paths not exist on NFS Share: %s", nfsShare.NFSShareContent.ID)) } err = unpublishNFS(ctx, target, arrayID, exportPaths) @@ -713,11 +713,11 @@ func (s *service) NodeUnpublishVolume( } volumeAPI := gounity.NewVolume(unity) - _, err = volumeAPI.FindVolumeById(ctx, volID) + _, err = volumeAPI.FindVolumeByID(ctx, volID) if err != nil { // If the volume isn't found, k8s will retry NodeUnpublish forever so... // There is no way back if volume isn't found and so considering this scenario idempotent - if err == gounity.VolumeNotFoundError { + if err == gounity.ErrorVolumeNotFound { log.Debugf("Volume %s not found on the array %s during Node Unpublish. Hence considering the call to be idempotent", volID, arrayID) return &csi.NodeUnpublishVolumeResponse{}, nil } @@ -941,9 +941,9 @@ func (s *service) NodeGetVolumeStats( if protocol == NFS { fileAPI := gounity.NewFilesystem(unity) - _, err := fileAPI.FindFilesystemById(ctx, volumeID) + _, err := fileAPI.FindFilesystemByID(ctx, volumeID) if err != nil { - if err == gounity.FilesystemNotFoundError { + if err == gounity.ErrorFilesystemNotFound { resp := &csi.NodeGetVolumeStatsResponse{ VolumeCondition: &csi.VolumeCondition{ Abnormal: true, @@ -956,9 +956,9 @@ func (s *service) NodeGetVolumeStats( } } else { volumeAPI := gounity.NewVolume(unity) - _, err := volumeAPI.FindVolumeById(ctx, volumeID) + _, err := volumeAPI.FindVolumeByID(ctx, volumeID) if err != nil { - if err == gounity.VolumeNotFoundError { + if err == gounity.ErrorVolumeNotFound { resp := &csi.NodeGetVolumeStatsResponse{ VolumeCondition: &csi.VolumeCondition{ Abnormal: true, @@ -1056,7 +1056,7 @@ func (s *service) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolum } volumeAPI := gounity.NewVolume(unity) - volume, err := volumeAPI.FindVolumeById(ctx, volID) + volume, err := volumeAPI.FindVolumeByID(ctx, volID) if err != nil { return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find volume Failed %v", err)) } @@ -1168,16 +1168,16 @@ func (s *service) getNFSShare(ctx context.Context, filesystemID, arrayID string) isSnapshot := false fileAPI := gounity.NewFilesystem(unity) - filesystem, err := fileAPI.FindFilesystemById(ctx, filesystemID) + filesystem, err := fileAPI.FindFilesystemByID(ctx, filesystemID) var snapResp *types.Snapshot if err != nil { snapshotAPI := gounity.NewSnapshot(unity) - snapResp, err = snapshotAPI.FindSnapshotById(ctx, filesystemID) + snapResp, err = snapshotAPI.FindSnapshotByID(ctx, filesystemID) if err != nil { return nil, false, false, err } isSnapshot = true - filesystem, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.Id, arrayID) + filesystem, err = s.getFilesystemByResourceID(ctx, snapResp.SnapshotContent.StorageResource.ID, arrayID) if err != nil { return nil, false, false, err } @@ -1187,12 +1187,12 @@ func (s *service) getNFSShare(ctx context.Context, filesystemID, arrayID string) for _, nfsShare := range filesystem.FileContent.NFSShare { if isSnapshot { - if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.Id == filesystemID { - nfsShareID = nfsShare.Id + if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.ID == filesystemID { + nfsShareID = nfsShare.ID } } else { - if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.Id == "" { - nfsShareID = nfsShare.Id + if nfsShare.Path == NFSShareLocalPath && nfsShare.ParentSnap.ID == "" { + nfsShareID = nfsShare.ID } } } @@ -1201,18 +1201,18 @@ func (s *service) getNFSShare(ctx context.Context, filesystemID, arrayID string) return nil, false, false, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "NFS Share for filesystem: %s not found. Error: %v", filesystemID, err)) } - nfsShare, err := fileAPI.FindNFSShareById(ctx, nfsShareID) + nfsShare, err := fileAPI.FindNFSShareByID(ctx, nfsShareID) if err != nil { return nil, false, false, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "NFS Share: %s not found. Error: %v", nfsShareID, err)) } - nasServer, err := fileAPI.FindNASServerById(ctx, filesystem.FileContent.NASServer.Id) + nasServer, err := fileAPI.FindNASServerByID(ctx, filesystem.FileContent.NASServer.ID) if err != nil { - return nil, false, false, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "NAS Server: %s not found. Error: %v", filesystem.FileContent.NASServer.Id, err)) + return nil, false, false, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "NAS Server: %s not found. Error: %v", filesystem.FileContent.NASServer.ID, err)) } if !nasServer.NASServerContent.NFSServer.NFSv3Enabled && !nasServer.NASServerContent.NFSServer.NFSv4Enabled { - return nil, false, false, status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Nas Server: %s does not support NFSv3 and NFSv4. At least one of the versions should be supported", nasServer.NASServerContent.Id)) + return nil, false, false, status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Nas Server: %s does not support NFSv3 and NFSv4. At least one of the versions should be supported", nasServer.NASServerContent.ID)) } return nfsShare, nasServer.NASServerContent.NFSServer.NFSv3Enabled, nasServer.NASServerContent.NFSServer.NFSv4Enabled, nil @@ -1252,7 +1252,7 @@ func (s *service) checkFilesystemMapping(ctx context.Context, nfsShare *types.NF } } if !hostHasAccess { - return status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Host: %s does not have access: %s on NFS Share: %s", host.HostContent.Name, accessType, nfsShare.NFSShareContent.Id)) + return status.Error(codes.FailedPrecondition, utils.GetMessageWithRunID(rid, "Host: %s does not have access: %s on NFS Share: %s", host.HostContent.Name, accessType, nfsShare.NFSShareContent.ID)) } return nil } @@ -1315,12 +1315,12 @@ func (s *service) getArrayHostInitiators(ctx context.Context, host *types.Host, hostAPI := gounity.NewHost(unity) hostInitiators := append(hostContent.FcInitiators, hostContent.IscsiInitiators...) for _, initiator := range hostInitiators { - initiatorID := initiator.Id - hostInitiator, err := hostAPI.FindHostInitiatorById(ctx, initiatorID) + initiatorID := initiator.ID + hostInitiator, err := hostAPI.FindHostInitiatorByID(ctx, initiatorID) if err != nil { return nil, err } - hostInitiatorWwns = append(hostInitiatorWwns, strings.ToLower(hostInitiator.HostInitiatorContent.InitiatorId)) + hostInitiatorWwns = append(hostInitiatorWwns, strings.ToLower(hostInitiator.HostInitiatorContent.InitiatorID)) } return hostInitiatorWwns, nil } @@ -1610,13 +1610,13 @@ func (s *service) addNodeInformationIntoArray(ctx context.Context, array *Storag //Find Host on the Array host, err := hostAPI.FindHostByName(ctx, s.opts.NodeName) if err != nil { - if err == gounity.HostNotFoundError { + if err == gounity.ErrorHostNotFound { host, err = hostAPI.FindHostByName(ctx, s.opts.LongNodeName) if err == nil { fqdnHost = true } else { var addHostErr error - if err == gounity.HostNotFoundError { + if err == gounity.ErrorHostNotFound { addHostErr = s.addNewNodeToArray(ctx, array, nodeIps, iqns, wwns) } else { return status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Unable to add host. Error: %v", err)) @@ -1639,7 +1639,7 @@ func (s *service) addNodeInformationIntoArray(ctx context.Context, array *Storag if fqdnHost { host, err = hostAPI.FindHostByName(ctx, s.opts.LongNodeName) if err != nil { - if err == gounity.HostNotFoundError { + if err == gounity.ErrorHostNotFound { addHostErr := s.addNewNodeToArray(ctx, array, nodeIps, iqns, wwns) if addHostErr != nil { return addHostErr @@ -1675,18 +1675,18 @@ func (s *service) addNodeInformationIntoArray(ctx context.Context, array *Storag } //Check Ip of the host with Host IP Port findHostNamePort := false - for _, ipPort := range hostContent.IpPorts { - hostIPPort, err := hostAPI.FindHostIpPortById(ctx, ipPort.Id) + for _, ipPort := range hostContent.IPPorts { + hostIPPort, err := hostAPI.FindHostIPPortByID(ctx, ipPort.ID) if err != nil { continue } - if hostIPPort != nil && hostIPPort.HostIpContent.Address == s.opts.LongNodeName { + if hostIPPort != nil && hostIPPort.HostIPContent.Address == s.opts.LongNodeName { findHostNamePort = true continue } if hostIPPort != nil { for i, nodeIP := range nodeIps { - if hostIPPort.HostIpContent.Address == nodeIP { + if hostIPPort.HostIPContent.Address == nodeIP { nodeIps[i] = nodeIps[len(nodeIps)-1] nodeIps = nodeIps[:len(nodeIps)-1] break @@ -1697,13 +1697,13 @@ func (s *service) addNodeInformationIntoArray(ctx context.Context, array *Storag var ipFormat = regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`) if findHostNamePort == false { //Create Host Ip Port - _, err = hostAPI.CreateHostIpPort(ctx, hostContent.ID, s.opts.LongNodeName) + _, err = hostAPI.CreateHostIPPort(ctx, hostContent.ID, s.opts.LongNodeName) if err != nil { return err } } for _, nodeIP := range nodeIps { - _, err = hostAPI.CreateHostIpPort(ctx, hostContent.ID, nodeIP) + _, err = hostAPI.CreateHostIPPort(ctx, hostContent.ID, nodeIP) if err != nil && !ipFormat.MatchString(s.opts.NodeName) { return err } @@ -1715,7 +1715,7 @@ func (s *service) addNodeInformationIntoArray(ctx context.Context, array *Storag if err != nil { log.Infof("Error copying multipath config file: %v", err) } - ipInterfaceAPI := gounity.NewIpInterface(unity) + ipInterfaceAPI := gounity.NewIPInterface(unity) ipInterfaces, err := ipInterfaceAPI.ListIscsiIPInterfaces(ctx) if err != nil { return status.Error(codes.Internal, utils.GetMessageWithRunID(rid, "Error retrieving iScsi Interface IPs from the array: %v", err)) @@ -1774,7 +1774,7 @@ func (s *service) addNewNodeToArray(ctx context.Context, array *StorageArrayConf } for eachtenant := range tenants.Entries { if tenants.Entries[eachtenant].Content.Name == tenantName { - tenantID = tenants.Entries[eachtenant].Content.Id + tenantID = tenants.Entries[eachtenant].Content.ID } } } else { @@ -1794,13 +1794,13 @@ func (s *service) addNewNodeToArray(ctx context.Context, array *StorageArrayConf log.Debugf("New Host Id: %s", hostContent.ID) //Create Host Ip Port - _, err = hostAPI.CreateHostIpPort(ctx, hostContent.ID, s.opts.LongNodeName) + _, err = hostAPI.CreateHostIPPort(ctx, hostContent.ID, s.opts.LongNodeName) if err != nil { return err } var ipFormat = regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`) for _, nodeIP := range nodeIps { - _, err = hostAPI.CreateHostIpPort(ctx, hostContent.ID, nodeIP) + _, err = hostAPI.CreateHostIPPort(ctx, hostContent.ID, nodeIP) if err != nil && !ipFormat.MatchString(s.opts.NodeName) { return err } @@ -1936,8 +1936,8 @@ func (s *service) validateProtocols(ctx context.Context, arraysList []*StorageAr if host != nil && len(host.HostContent.FcInitiators) != 0 { log.Infof("Got FC Initiators, Checking health of initiators:%s", host.HostContent.FcInitiators) for _, initiator := range host.HostContent.FcInitiators { - initiatorID := initiator.Id - hostInitiator, err := hostAPI.FindHostInitiatorById(ctx, initiatorID) + initiatorID := initiator.ID + hostInitiator, err := hostAPI.FindHostInitiatorByID(ctx, initiatorID) if err != nil { log.Infof("Unable to get initiators: %s", err) } @@ -1955,8 +1955,8 @@ func (s *service) validateProtocols(ctx context.Context, arraysList []*StorageAr if host != nil && len(host.HostContent.IscsiInitiators) != 0 { log.Infof("Got iSCSI Initiators, Checking health of initiators:%s", host.HostContent.IscsiInitiators) for _, initiator := range host.HostContent.IscsiInitiators { - initiatorID := initiator.Id - hostInitiator, err := hostAPI.FindHostInitiatorById(ctx, initiatorID) + initiatorID := initiator.ID + hostInitiator, err := hostAPI.FindHostInitiatorByID(ctx, initiatorID) if err != nil { log.Infof("Unable to get initiators: %s", err) } diff --git a/service/utils/emcutils.go b/service/utils/emcutils.go index 6e9ee36..d76b280 100644 --- a/service/utils/emcutils.go +++ b/service/utils/emcutils.go @@ -30,22 +30,22 @@ import ( //GetVolumeResponseFromVolume Utility method to convert Unity Rest type Volume to CSI standard Volume Response func GetVolumeResponseFromVolume(volume *types.Volume, arrayID, protocol string, preferredAccessibility []*csi.Topology) *csi.CreateVolumeResponse { content := volume.VolumeContent - return getVolumeResponse(content.Name, protocol, arrayID, content.ResourceId, content.SizeTotal, preferredAccessibility) + return getVolumeResponse(content.Name, protocol, arrayID, content.ResourceID, content.SizeTotal, preferredAccessibility) } //GetVolumeResponseFromFilesystem Utility method to convert Unity rest Filesystem response to CSI standard Volume Response func GetVolumeResponseFromFilesystem(filesystem *types.Filesystem, arrayID, protocol string, preferredAccessibility []*csi.Topology) *csi.CreateVolumeResponse { content := filesystem.FileContent - return getVolumeResponse(content.Name, protocol, arrayID, content.Id, content.SizeTotal, preferredAccessibility) + return getVolumeResponse(content.Name, protocol, arrayID, content.ID, content.SizeTotal, preferredAccessibility) } // GetVolumeResponseFromSnapshot - Get volumd from snapshot func GetVolumeResponseFromSnapshot(snapshot *types.Snapshot, arrayID, protocol string, preferredAccessibility []*csi.Topology) *csi.CreateVolumeResponse { - volID := fmt.Sprintf("%s-%s-%s-%s", snapshot.SnapshotContent.Name, protocol, arrayID, snapshot.SnapshotContent.ResourceId) + volID := fmt.Sprintf("%s-%s-%s-%s", snapshot.SnapshotContent.Name, protocol, arrayID, snapshot.SnapshotContent.ResourceID) VolumeContext := make(map[string]string) VolumeContext["protocol"] = protocol VolumeContext["arrayId"] = arrayID - VolumeContext["volumeId"] = snapshot.SnapshotContent.ResourceId + VolumeContext["volumeId"] = snapshot.SnapshotContent.ResourceID volumeReq := &csi.Volume{ VolumeId: volID, @@ -175,7 +175,7 @@ func GetHostIP() ([]string, error) { // GetSnapshotResponseFromSnapshot - Utility method to convert Unity Rest type Snapshot to CSI standard Snapshot Response func GetSnapshotResponseFromSnapshot(snap *types.Snapshot, protocol, arrayID string) *csi.CreateSnapshotResponse { content := snap.SnapshotContent - snapID := fmt.Sprintf("%s-%s-%s-%s", content.Name, protocol, arrayID, content.ResourceId) + snapID := fmt.Sprintf("%s-%s-%s-%s", content.Name, protocol, arrayID, content.ResourceID) var timestamp *timestamp.Timestamp if !snap.SnapshotContent.CreationTime.IsZero() { timestamp, _ = ptypes.TimestampProto(snap.SnapshotContent.CreationTime) @@ -185,7 +185,7 @@ func GetSnapshotResponseFromSnapshot(snap *types.Snapshot, protocol, arrayID str SizeBytes: snap.SnapshotContent.Size, ReadyToUse: true, SnapshotId: snapID, - SourceVolumeId: content.StorageResource.Id, + SourceVolumeId: content.StorageResource.ID, CreationTime: timestamp, } diff --git a/service/validator.go b/service/validator.go index 8f49f5b..49390e1 100644 --- a/service/validator.go +++ b/service/validator.go @@ -125,9 +125,9 @@ func validateCreateFsFromSnapshot(ctx context.Context, sourceFilesystemResp *typ rid, _ := utils.GetRunidAndLogger(ctx) // Validate the storagePool parameter - if sourceFilesystemResp.FileContent.Pool.Id != storagePool { + if sourceFilesystemResp.FileContent.Pool.ID != storagePool { return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source filesystem storage pool %s is different than the requested storage pool %s", - sourceFilesystemResp.FileContent.Pool.Id, storagePool)) + sourceFilesystemResp.FileContent.Pool.ID, storagePool)) } //Validate the thinProvisioned parameter @@ -163,9 +163,9 @@ func validateCreateVolumeFromSource(ctx context.Context, sourceVolResp *types.Vo rid, _ := utils.GetRunidAndLogger(ctx) // Validate the storagePool parameter - if sourceVolResp.VolumeContent.Pool.Id != storagePool { + if sourceVolResp.VolumeContent.Pool.ID != storagePool { return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source volume storage pool %s is different than the requested storage pool %s", - sourceVolResp.VolumeContent.Pool.Id, storagePool)) + sourceVolResp.VolumeContent.Pool.ID, storagePool)) } //Validate the tieringPolicy parameter if int64(sourceVolResp.VolumeContent.TieringPolicy) != tieringPolicy {