Skip to content

Commit 06de369

Browse files
committed
updated the branch to from master to regional_rfs and also i have added --signoff flag during commit
Signed-off-by: Renuka <[email protected]>
1 parent 7f25c8f commit 06de369

File tree

12 files changed

+85
-35
lines changed

12 files changed

+85
-35
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fmt:
2020

2121
.PHONY: dofmt
2222
dofmt:
23-
golangci-lint run --disable-all --enable=gofmt --fix
23+
golangci-lint run --fix --config=.golangci.yml
2424

2525
.PHONY: lint
2626
lint:
@@ -32,7 +32,7 @@ makefmt:
3232

3333
.PHONY: build
3434
build:
35-
go build -gcflags '-N -l' -o libSample samples/main.go samples/volume_operations.go
35+
go build -gcflags '-N -l' -o libSample samples/main.go
3636

3737
.PHONY: test
3838
test:

common/vpcclient/client/request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type ResponseConsumer interface {
7979
func (r *Request) path() string {
8080
path := r.operation.PathPattern
8181
for k, v := range r.pathParams {
82-
path = strings.Replace(path, "{"+k+"}", v, -1)
82+
path = strings.ReplaceAll(path, "{"+k+"}", v)
8383
}
8484
return path
8585
}

e2e/pvc_tests.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ var _ = Describe("[ics-e2e] [sc] [with-deploy] [retain] Dynamic Provisioning usi
113113
ReplicaCount: replicaCount,
114114
}
115115
test.Run(cs, ns)
116-
if _, err = fpointer.WriteString(fmt.Sprintf("VPC-FILE-CSI-TEST: VERIFYING PVC CREATE/DELETE WITH %s STORAGE CLASS : PASS\n", sc_retain)); err != nil {
116+
if _, err = fmt.Fprintf(fpointer, "VPC-FILE-CSI-TEST: VERIFYING PVC CREATE/DELETE WITH %s STORAGE CLASS : PASS\n", sc_retain); err != nil {
117117
panic(err)
118118
}
119119
})
@@ -181,7 +181,7 @@ var _ = Describe("[ics-e2e] [sc] [with-deploy] Dynamic Provisioning for dp2 SC w
181181
ReplicaCount: replicaCount,
182182
}
183183
test.Run(cs, ns)
184-
if _, err = fpointer.WriteString(fmt.Sprintf("VPC-FILE-CSI-TEST: VERIFYING PVC CREATE/DELETE WITH %s STORAGE CLASS : PASS\n", sc)); err != nil {
184+
if _, err = fmt.Fprintf(fpointer, "VPC-FILE-CSI-TEST: VERIFYING PVC CREATE/DELETE WITH %s STORAGE CLASS : PASS\n", sc); err != nil {
185185
panic(err)
186186
}
187187
})

e2e/testsuites/baseutils.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ func (t *TestPersistentVolumeClaim) ValidateProvisionedPersistentVolume() {
606606
framework.Logf("checking PV [%s]", t.persistentVolume.Name)
607607
expectedAccessModes := t.requestedPersistentVolumeClaim.Spec.AccessModes
608608
Expect(t.persistentVolume.Spec.AccessModes).To(Equal(expectedAccessModes))
609-
Expect(t.persistentVolume.Spec.ClaimRef.Name).To(Equal(t.persistentVolumeClaim.ObjectMeta.Name))
610-
Expect(t.persistentVolume.Spec.ClaimRef.Namespace).To(Equal(t.persistentVolumeClaim.ObjectMeta.Namespace))
609+
Expect(t.persistentVolume.Spec.ClaimRef.Name).To(Equal(t.persistentVolumeClaim.Name))
610+
Expect(t.persistentVolume.Spec.ClaimRef.Namespace).To(Equal(t.persistentVolumeClaim.Namespace))
611611
// If storageClass is nil, PV was pre-provisioned with these values already set
612612
if t.storageClass != nil {
613613
Expect(t.persistentVolume.Spec.PersistentVolumeReclaimPolicy).To(Equal(*t.storageClass.ReclaimPolicy))
@@ -686,12 +686,12 @@ func generatePVC(name, namespace,
686686
func (t *TestPersistentVolumeClaim) Cleanup() {
687687

688688
var volumeHandle []string
689-
if strings.Contains(t.persistentVolume.Spec.PersistentVolumeSource.CSI.VolumeHandle, VolumeIDSeperator) {
689+
if strings.Contains(t.persistentVolume.Spec.CSI.VolumeHandle, VolumeIDSeperator) {
690690
//Volume ID is in format volumeID#volumeAccessPointID
691-
volumeHandle = strings.Split(t.persistentVolume.Spec.PersistentVolumeSource.CSI.VolumeHandle, VolumeIDSeperator)
691+
volumeHandle = strings.Split(t.persistentVolume.Spec.CSI.VolumeHandle, VolumeIDSeperator)
692692
} else {
693693
//Deprecated -- Try for volumeID:volumeAccessPointID, support for old format for few releases.
694-
volumeHandle = strings.Split(t.persistentVolume.Spec.PersistentVolumeSource.CSI.VolumeHandle, DeprecatedVolumeIDSeperator)
694+
volumeHandle = strings.Split(t.persistentVolume.Spec.CSI.VolumeHandle, DeprecatedVolumeIDSeperator)
695695
}
696696

697697
getShareMountTargetOptions := &vpcbetav1.GetShareMountTargetOptions{
@@ -700,7 +700,7 @@ func (t *TestPersistentVolumeClaim) Cleanup() {
700700
}
701701

702702
By(fmt.Sprintf("Logging volumeHandle: %s", volumeHandle))
703-
By(fmt.Sprintf("Verifying if file share mount target is created"))
703+
By("Verifying if file share mount target is created")
704704
shareMountTarget, response, err := VPCService.GetShareMountTarget(getShareMountTargetOptions)
705705
if err != nil {
706706
panic(err)
@@ -711,7 +711,7 @@ func (t *TestPersistentVolumeClaim) Cleanup() {
711711
Expect(response.StatusCode).To(Equal(200))
712712
Expect(shareMountTarget).ToNot(BeNil())
713713

714-
By(fmt.Sprintf("Verifying if VNI is created"))
714+
By("Verifying if VNI is created")
715715
if *(shareMountTarget.AccessControlMode) == "security_group" {
716716

717717
getVirtualNetworkInterfaceOptions := &vpcbetav1.GetVirtualNetworkInterfaceOptions{
@@ -761,13 +761,13 @@ func (t *TestPersistentVolumeClaim) Cleanup() {
761761
ID: &volumeHandle[1],
762762
}
763763

764-
By(fmt.Sprintf("Deleting file share target"))
764+
By("Deleting file share target")
765765
shareMountTarget, response, err := VPCService.DeleteShareMountTarget(deleteShareMountTargetOptions)
766766
if err != nil {
767767
panic(err)
768768
}
769769

770-
By(fmt.Sprintf("Wating for file share target to be deleted"))
770+
By("Wating for file share target to be deleted")
771771
// end-delete_share_mount_target
772772
time.Sleep(1 * time.Minute)
773773

@@ -779,7 +779,7 @@ func (t *TestPersistentVolumeClaim) Cleanup() {
779779
ID: &volumeHandle[0],
780780
}
781781

782-
By(fmt.Sprintf("Deleting file share"))
782+
By("Deleting file share")
783783
share, response, err := VPCService.DeleteShare(deleteShareOptions)
784784
if err != nil {
785785
panic(err)
@@ -792,11 +792,11 @@ func (t *TestPersistentVolumeClaim) Cleanup() {
792792
Expect(share).ToNot(BeNil())
793793
}
794794

795-
By(fmt.Sprintf("Wating for file share to be deleted"))
795+
By("Wating for file share to be deleted")
796796
// end-delete_share_mount_target
797797
time.Sleep(30 * time.Second)
798798

799-
By(fmt.Sprintf("Verying if VNI is deleted"))
799+
By("Verying if VNI is deleted")
800800
//Verifying if VNI is deleted
801801
if *(shareMountTarget.AccessControlMode) == "security_group" {
802802

@@ -812,7 +812,7 @@ func (t *TestPersistentVolumeClaim) Cleanup() {
812812
Expect(virtualNetworkInterface).To(BeNil())
813813
}
814814

815-
By(fmt.Sprintf("Verying if shareMountTarget is deleted"))
815+
By("Verying if shareMountTarget is deleted")
816816
//Verifying if shareMountTarget is deleted
817817
shareMountTarget, response, err = VPCService.GetShareMountTarget(getShareMountTargetOptions)
818818
// end-get_share_mount_target
@@ -821,7 +821,7 @@ func (t *TestPersistentVolumeClaim) Cleanup() {
821821
Expect(response.StatusCode).To(Equal(404))
822822
Expect(shareMountTarget).To(BeNil())
823823

824-
By(fmt.Sprintf("Verying if share is deleted"))
824+
By("Verying if share is deleted")
825825
//Verifying if share is deleted
826826
getShareOptions := &vpcbetav1.GetShareOptions{
827827
ID: &volumeHandle[1],
@@ -1321,7 +1321,7 @@ func (t *TestVolumeSnapshotClass) ReadyToUse(snapshot *volumesnapshotv1.VolumeSn
13211321
}
13221322
return *vs.Status.ReadyToUse, nil
13231323
})
1324-
if snapFail == true {
1324+
if snapFail {
13251325
Expect(err).To(HaveOccurred())
13261326
} else {
13271327
framework.ExpectNoError(err)

e2e/testsuites/test_statefulset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (t *StatefulsetWithVolWRTest) Run(client clientset.Interface, namespace *v1
5050
By("checking pod exec before pod delete")
5151
tStatefulset.Exec(t.PodCheck.Cmd, t.PodCheck.ExpectedString01)
5252
}
53-
if drainNode == true {
53+
if drainNode {
5454
tStatefulset.drainNode()
5555
defer tStatefulset.uncordonNode()
5656
By("checking again that the pod(s) is/are running")

file/provider/create_volume.go

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,20 @@ const (
3333
minSize = 10 //10 GB
3434
maxSize = 16000 //16 TB
3535
customProfile = "custom-iops"
36+
<<<<<<< Updated upstream
3637
)
3738

3839
var (
3940
SupportedProfiles = []string{"dp2", "rfs"}
4041
IOPSAllowedProfiles = []string{"dp2"}
4142
BandwidthAllowedProfiles = []string{"rfs"}
43+
=======
44+
//dp2Profile = "dp2"
45+
>>>>>>> Stashed changes
4246
)
4347

48+
var Profiles = []string{"dp2", "rfs"}
49+
4450
// CreateVolume creates file share
4551
func (vpcs *VPCSession) CreateVolume(volumeRequest provider.Volume) (volumeResponse *provider.Volume, err error) {
4652
vpcs.Logger.Debug("Entry of CreateVolume method...")
@@ -65,7 +71,7 @@ func (vpcs *VPCSession) CreateVolume(volumeRequest provider.Volume) (volumeRespo
6571
AccessControlMode: volumeRequest.AccessControlMode,
6672
ResourceGroup: &resourceGroup,
6773
Profile: &models.Profile{
68-
Name: volumeRequest.VPCVolume.Profile.Name,
74+
Name: volumeRequest.Profile.Name,
6975
},
7076
Bandwidth: func() *int64 {
7177
profile := volumeRequest.VPCVolume.Profile.Name
@@ -117,8 +123,8 @@ func (vpcs *VPCSession) CreateVolume(volumeRequest provider.Volume) (volumeRespo
117123
}
118124

119125
var encryptionKeyCRN string
120-
if volumeRequest.VPCVolume.VolumeEncryptionKey != nil && len(volumeRequest.VPCVolume.VolumeEncryptionKey.CRN) > 0 {
121-
encryptionKeyCRN = volumeRequest.VPCVolume.VolumeEncryptionKey.CRN
126+
if volumeRequest.VolumeEncryptionKey != nil && len(volumeRequest.VolumeEncryptionKey.CRN) > 0 {
127+
encryptionKeyCRN = volumeRequest.VolumeEncryptionKey.CRN
122128
shareTemplate.EncryptionKey = &models.EncryptionKey{CRN: encryptionKeyCRN}
123129
}
124130

@@ -195,6 +201,7 @@ func validateVolumeRequest(volumeRequest provider.Volume) (models.ResourceGroup,
195201
if volumeRequest.Iops != nil {
196202
iops = ToInt64(*volumeRequest.Iops)
197203
}
204+
<<<<<<< Updated upstream
198205

199206
if volumeRequest.Bandwidth != nil {
200207
bandwidth = ToInt64(*volumeRequest.Bandwidth)
@@ -219,14 +226,35 @@ func validateVolumeRequest(volumeRequest provider.Volume) (models.ResourceGroup,
219226

220227
if volumeRequest.VPCVolume.ResourceGroup == nil {
221228
return resourceGroup, iops, bandwidth, userError.GetUserError("EmptyResourceGroup", nil)
229+
=======
230+
if volumeRequest.Profile == nil {
231+
return resourceGroup, iops, userError.GetUserError("VolumeProfileEmpty", nil)
232+
}
233+
// if volumeRequest.VPCVolume.Profile.Name != customProfile && volumeRequest.VPCVolume.Profile.Name != dp2Profile && iops > 0 {
234+
// return resourceGroup, iops, userError.GetUserError("VolumeProfileIopsInvalid", nil)
235+
// }
236+
237+
if volumeRequest.Profile.Name != customProfile && !contains(Profiles, volumeRequest.Profile.Name) && iops > 0 {
238+
return resourceGroup, iops, userError.GetUserError("VolumeProfileIopsInvalid", nil)
239+
}
240+
241+
// validate and add resource group ID or Name whichever is provided by user
242+
if volumeRequest.ResourceGroup == nil {
243+
return resourceGroup, iops, userError.GetUserError("EmptyResourceGroup", nil)
244+
}
245+
246+
// validate and add resource group ID or Name whichever is provided by user
247+
if len(volumeRequest.ResourceGroup.ID) == 0 && len(volumeRequest.ResourceGroup.Name) == 0 {
248+
return resourceGroup, iops, userError.GetUserError("EmptyResourceGroupIDandName", nil)
249+
>>>>>>> Stashed changes
222250
}
223251

224-
if len(volumeRequest.VPCVolume.ResourceGroup.ID) > 0 {
225-
resourceGroup.ID = volumeRequest.VPCVolume.ResourceGroup.ID
252+
if len(volumeRequest.ResourceGroup.ID) > 0 {
253+
resourceGroup.ID = volumeRequest.ResourceGroup.ID
226254
}
227-
if len(volumeRequest.VPCVolume.ResourceGroup.Name) > 0 {
255+
if len(volumeRequest.ResourceGroup.Name) > 0 {
228256
// get the resource group ID from resource group name as Name is not supported by RIaaS
229-
resourceGroup.Name = volumeRequest.VPCVolume.ResourceGroup.Name
257+
resourceGroup.Name = volumeRequest.ResourceGroup.Name
230258
}
231259

232260
return resourceGroup, iops, bandwidth, nil

file/provider/update_volume.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (vpcs *VPCSession) UpdateVolume(volumeTemplate provider.Volume) error {
6262
return userError.GetUserError("VolumeNotInValidState", err, volumeTemplate.VolumeID)
6363
}
6464

65+
<<<<<<< Updated upstream
6566
vpcs.Logger.Info("Volume got valid (stable) state", zap.Reflect("etag", etag))
6667

6768
// Tag check using new map-based tags
@@ -100,6 +101,19 @@ func (vpcs *VPCSession) UpdateVolume(volumeTemplate provider.Volume) error {
100101
if !shouldUpdate {
101102
vpcs.Logger.Info("No changes detected, skipping update call")
102103
return nil
104+
=======
105+
//If tags are equal then skip the UpdateFileShare RIAAS API call
106+
if ifTagsEqual(existShare.UserTags, volumeTemplate.Tags) {
107+
vpcs.Logger.Info("There is no change in user tags for volume, skipping the updateVolume for VPC IaaS... ", zap.Reflect("existShare", existShare.UserTags), zap.Reflect("volumeRequest", volumeTemplate.Tags))
108+
return nil
109+
}
110+
111+
//Append the existing tags with the requested input tags
112+
existShare.UserTags = append(existShare.UserTags, volumeTemplate.Tags...)
113+
114+
volume := &models.Share{
115+
UserTags: existShare.UserTags,
116+
>>>>>>> Stashed changes
103117
}
104118

105119
vpcs.Logger.Info("Calling VPC provider for volume UpdateVolumeWithTags...",

iks/provider/update_volume.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func NewUpdatePVC(volumeRequest provider.Volume) provider.UpdatePVC {
9191
pvc := provider.UpdatePVC{
9292
ID: volumeRequest.VolumeID,
9393
CRN: volumeRequest.CRN,
94-
Tags: volumeRequest.VPCVolume.Tags,
94+
Tags: volumeRequest.Tags,
9595
Provider: string(volumeRequest.Provider),
9696
VolumeType: string(volumeRequest.VolumeType),
9797
}

pkg/metadata/metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (nodeManager *NodeInfoManager) NewNodeMetadata(logger *zap.Logger) (NodeMet
9494
return nil, err
9595
}
9696

97-
nodeLabels := node.ObjectMeta.Labels
97+
nodeLabels := node.Labels
9898
if len(nodeLabels[NodeRegionLabel]) == 0 || len(nodeLabels[NodeZoneLabel]) == 0 {
9999
errorMsg := fmt.Errorf("One or few required node label(s) is/are missing [%s, %s]. Node Labels Found = [#%v]", NodeRegionLabel, NodeZoneLabel, nodeLabels) //nolint:golint
100100
return nil, errorMsg

pkg/watcher/pv_watcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func (pvw *PVWatcher) getTags(pv *v1.PersistentVolume, ctxLogger *zap.Logger) (s
253253
tags = append(tags, StorageClassTag+pv.Spec.StorageClassName)
254254
tags = append(tags, NameSpaceTag+pv.Spec.ClaimRef.Namespace)
255255
tags = append(tags, PVCNameTag+pv.Spec.ClaimRef.Name)
256-
tags = append(tags, PVNameTag+pv.ObjectMeta.Name)
256+
tags = append(tags, PVNameTag+pv.Name)
257257
tags = append(tags, ProvisionerTag+pvw.provisionerName)
258258
ctxLogger.Debug("Exit getTags()", zap.String("VolumeCRN", volAttributes[VolumeCRN]), zap.Reflect("tags", tags))
259259
return volAttributes[VolumeCRN], tags

0 commit comments

Comments
 (0)