Repository: dell/csi-baremetal
Pull request #543 (2021-09-22 07:48:13)

[ISSUE-538] Update node-driver-registrar sidecar
## Purpose
### Issue #538 

- node-driver-registrar version is 1.3
- remove csi-attacher

## PR checklist
- [x] Add link to the issue
- [x] Choose PR label
- [ ] New unit tests added
- [ ] Modified code has meaningful comments
- [ ] All TODOs are linked with the issues
- [ ] All comments are resolved


codecov[bot]: # [Codecov](https://codecov.io/gh/dell/csi-baremetal/pull/543?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell) Report
> Merging [#543](https://codecov.io/gh/dell/csi-baremetal/pull/543?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell) (860e6cb) into [master](https://codecov.io/gh/dell/csi-baremetal/commit/4c0c38da3cdb57a214e63c8ef1373bff8841db49?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell) (4c0c38d) will **decrease** coverage by `0.02%`.
> The diff coverage is `0.00%`.

> :exclamation: Current head 860e6cb differs from pull request most recent head cb12dc6. Consider uploading reports for the commit cb12dc6 to get more accurate results
[![Impacted file tree graph](https://codecov.io/gh/dell/csi-baremetal/pull/543/graphs/tree.svg?width=650&height=150&src=pr&token=4D8WVNWX5O&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell)](https://codecov.io/gh/dell/csi-baremetal/pull/543?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell)

```diff
@@            Coverage Diff             @@
##           master     #543      +/-   ##
==========================================
- Coverage   60.36%   60.34%   -0.03%     
==========================================
  Files          60       60              
  Lines        6000     6002       +2     
==========================================
  Hits         3622     3622              
- Misses       2167     2169       +2     
  Partials      211      211              
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `60.34% <0.00%> (-0.03%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/dell/csi-baremetal/pull/543?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell) | Coverage Δ | |
|---|---|---|
| [pkg/base/capacityplanner/node\_capacity.go](https://codecov.io/gh/dell/csi-baremetal/pull/543/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell#diff-cGtnL2Jhc2UvY2FwYWNpdHlwbGFubmVyL25vZGVfY2FwYWNpdHkuZ28=) | `91.66% <0.00%> (-2.62%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/dell/csi-baremetal/pull/543?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/dell/csi-baremetal/pull/543?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell). Last update [4c0c38d...cb12dc6](https://codecov.io/gh/dell/csi-baremetal/pull/543?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell).


Patch:
diff --git a/.golangci.yml b/.golangci.yml
index a76cd53..d8a3e78 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -39,7 +39,6 @@ linters:
     - gosimple
     - govet
     - ineffassign
-    - interfacer
     - lll
     - megacheck
     - misspell
diff --git a/Makefile.validation b/Makefile.validation
index 0dcb3c8..636d810 100644
--- a/Makefile.validation
+++ b/Makefile.validation
@@ -67,7 +67,6 @@ kind-pull-images: kind-pull-sidecar-images
 kind-pull-sidecar-images:
 	docker pull ${REGISTRY}/${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG}
 	docker pull ${REGISTRY}/${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG}
-	docker pull ${REGISTRY}/${CSI_ATTACHER}:${CSI_ATTACHER_TAG}
 	docker pull ${REGISTRY}/${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG}
 	docker pull ${REGISTRY}/${CSI_RESIZER}:${CSI_RESIZER_TAG}
 	docker pull ${REGISTRY}/${BUSYBOX}:${BUSYBOX_TAG}
@@ -77,7 +76,6 @@ kind-pull-sidecar-images:
 kind-tag-images:
 	docker tag ${REGISTRY}/${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG} ${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG}
 	docker tag ${REGISTRY}/${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG} ${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG}
-	docker tag ${REGISTRY}/${CSI_ATTACHER}:${CSI_ATTACHER_TAG} ${CSI_ATTACHER}:${CSI_ATTACHER_TAG}
 	docker tag ${REGISTRY}/${CSI_RESIZER}:${CSI_RESIZER_TAG} ${CSI_RESIZER}:${CSI_RESIZER_TAG}
 	docker tag ${REGISTRY}/${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG} ${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG}
 	docker tag ${REGISTRY}/${BUSYBOX}:${BUSYBOX_TAG} ${BUSYBOX}:${BUSYBOX_TAG}
@@ -95,7 +93,6 @@ kind-tag-images:
 kind-load-images:
 	$(KIND) load docker-image ${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG}
 	$(KIND) load docker-image ${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG}
-	$(KIND) load docker-image ${CSI_ATTACHER}:${CSI_ATTACHER_TAG}
 	$(KIND) load docker-image ${CSI_RESIZER}:${CSI_RESIZER_TAG}
 	$(KIND) load docker-image ${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG}
 	$(KIND) load docker-image ${BUSYBOX}:${BUSYBOX_TAG}
diff --git a/pkg/base/linuxutils/datadiscover/datadiscover.go b/pkg/base/linuxutils/datadiscover/datadiscover.go
index a817ea9..efbc61a 100644
--- a/pkg/base/linuxutils/datadiscover/datadiscover.go
+++ b/pkg/base/linuxutils/datadiscover/datadiscover.go
@@ -71,7 +71,7 @@ func (w *WrapDataDiscoverImpl) DiscoverData(device, serialNumber string) (*types
 		}, nil
 	}
 
-	if hasData, err = w.partHelper.DeviceHasPartitions(device, serialNumber); err != nil {
+	if hasData, err = w.partHelper.DeviceHasPartitions(device); err != nil {
 		return nil, err
 	}
 	if hasData {
diff --git a/pkg/base/linuxutils/partitionhelper/partition_helper.go b/pkg/base/linuxutils/partitionhelper/partition_helper.go
index 00017fa..2ab9605 100644
--- a/pkg/base/linuxutils/partitionhelper/partition_helper.go
+++ b/pkg/base/linuxutils/partitionhelper/partition_helper.go
@@ -42,7 +42,7 @@ type WrapPartition interface {
 	SyncPartitionTable(device string) error
 	GetPartitionNameByUUID(device, partUUID string) (string, error)
 	DeviceHasPartitionTable(device string) (bool, error)
-	DeviceHasPartitions(device, serialNumber string) (bool, error)
+	DeviceHasPartitions(device string) (bool, error)
 }
 
 const (
@@ -355,9 +355,9 @@ func (p *WrapPartitionImpl) DeviceHasPartitionTable(device string) (bool, error)
 }
 
 // DeviceHasPartitions calls lsblk and determine if device has partitions (children)
-// Receive device path and serial number
+// Receive device path
 // Return true if device has partitions, false in opposite, error if something went wrong
-func (p *WrapPartitionImpl) DeviceHasPartitions(device, serialNumber string) (bool, error) {
+func (p *WrapPartitionImpl) DeviceHasPartitions(device string) (bool, error) {
 	blockDevices, err := p.lsblkUtil.GetBlockDevices(device)
 	if len(blockDevices) != 1 {
 		return false, fmt.Errorf("wrong output of lsblk for %s, block devices: %v", device, blockDevices)
@@ -367,13 +367,8 @@ func (p *WrapPartitionImpl) DeviceHasPartitions(device, serialNumber string) (bo
 		return false, err
 	}
 
-	bdev := blockDevices[0]
-
-	if !strings.EqualFold(bdev.Serial, serialNumber) {
-		return false, fmt.Errorf("serial numbers for block device %s don't match: %s != %s", bdev.Name, bdev.Serial,
-			serialNumber)
-	}
-	if len(bdev.Children) > 0 {
+	// check number of partitions
+	if len(blockDevices[0].Children) > 0 {
 		return true, nil
 	}
 
diff --git a/pkg/mocks/linuxutils/partitionhelper.go b/pkg/mocks/linuxutils/partitionhelper.go
index 4027eff..ca22d42 100644
--- a/pkg/mocks/linuxutils/partitionhelper.go
+++ b/pkg/mocks/linuxutils/partitionhelper.go
@@ -33,8 +33,8 @@ func (m *MockWrapPartition) DeviceHasPartitionTable(device string) (bool, error)
 }
 
 // DeviceHasPartitions is a mock implementations
-func (m *MockWrapPartition) DeviceHasPartitions(device, serialNumber string) (bool, error) {
-	args := m.Mock.Called(device, serialNumber)
+func (m *MockWrapPartition) DeviceHasPartitions(device string) (bool, error) {
+	args := m.Mock.Called(device)
 
 	return args.Bool(0), args.Error(1)
 }
diff --git a/variables.mk b/variables.mk
index 13a7e87..efa81dd 100644
--- a/variables.mk
+++ b/variables.mk
@@ -24,8 +24,7 @@ BRANCH           := $(shell git rev-parse --abbrev-ref HEAD)
 ### third-party components version
 CSI_PROVISIONER_TAG := v1.6.0
 CSI_RESIZER_TAG     := v1.1.0
-CSI_REGISTRAR_TAG   := v1.0.1-gke.0
-CSI_ATTACHER_TAG    := v1.0.1
+CSI_REGISTRAR_TAG   := v1.3.0
 LIVENESS_PROBE_TAG  := v2.1.0
 BUSYBOX_TAG         := 1.29
 
@@ -55,7 +54,6 @@ DRIVE_MANAGER_TYPE := ${BASE_DRIVE_MGR}
 CSI_PROVISIONER := csi-provisioner
 CSI_REGISTRAR   := csi-node-driver-registrar
 CSI_RESIZER     := csi-resizer
-CSI_ATTACHER    := csi-attacher
 LIVENESS_PROBE  := livenessprobe
 BUSYBOX         := busybox
 


Test patch:
diff --git a/pkg/base/linuxutils/datadiscover/datadiscover_test.go b/pkg/base/linuxutils/datadiscover/datadiscover_test.go
index ad3d0e5..7e5b808 100644
--- a/pkg/base/linuxutils/datadiscover/datadiscover_test.go
+++ b/pkg/base/linuxutils/datadiscover/datadiscover_test.go
@@ -49,7 +49,7 @@ func Test_DiscoverData(t *testing.T) {
 		)
 		fs.On("DeviceFs", device).Return("", nil).Times(1)
 		part.On("DeviceHasPartitionTable", device).Return(false, nil).Times(1)
-		part.On("DeviceHasPartitions", device, serialNumber).Return(true, nil).Times(1)
+		part.On("DeviceHasPartitions", device).Return(true, nil).Times(1)
 		discoverResult, err := discoverData.DiscoverData(device, serialNumber)
 		assert.Nil(t, err)
 		assert.True(t, discoverResult.HasData)
@@ -64,7 +64,7 @@ func Test_DiscoverData(t *testing.T) {
 		)
 		fs.On("DeviceFs", device).Return("", nil).Times(1)
 		part.On("DeviceHasPartitionTable", device).Return(false, nil).Times(1)
-		part.On("DeviceHasPartitions", device, serialNumber).Return(false, nil).Times(1)
+		part.On("DeviceHasPartitions", device).Return(false, nil).Times(1)
 		discoverResult, err := discoverData.DiscoverData(device, serialNumber)
 		assert.Nil(t, err)
 		fmt.Println(discoverResult.HasData)
@@ -104,7 +104,7 @@ func Test_DiscoverData(t *testing.T) {
 		)
 		fs.On("DeviceFs", device).Return("", nil).Times(1)
 		part.On("DeviceHasPartitionTable", device).Return(false, nil).Times(1)
-		part.On("DeviceHasPartitions", device, serialNumber).Return(false, errors.New("error")).Times(1)
+		part.On("DeviceHasPartitions", device).Return(false, errors.New("error")).Times(1)
 		discoverResult, err := discoverData.DiscoverData(device, serialNumber)
 		assert.NotNil(t, err)
 		assert.Nil(t, discoverResult)
diff --git a/pkg/base/linuxutils/partitionhelper/partitionhelper_test.go b/pkg/base/linuxutils/partitionhelper/partitionhelper_test.go
index 5c1188f..b4c29dc 100644
--- a/pkg/base/linuxutils/partitionhelper/partitionhelper_test.go
+++ b/pkg/base/linuxutils/partitionhelper/partitionhelper_test.go
@@ -252,7 +252,7 @@ func TestLinuxUtils_DeviceHasPartitions(t *testing.T) {
 		}}
 		mockLsblk.On("GetBlockDevices", device).
 			Return([]lsblk.BlockDevice{blkDev1}, nil).Times(1)
-		hasPart, err := p.DeviceHasPartitions(device, serialNumber)
+		hasPart, err := p.DeviceHasPartitions(device)
 		assert.Nil(t, err)
 		assert.True(t, hasPart)
 	})
@@ -261,7 +261,7 @@ func TestLinuxUtils_DeviceHasPartitions(t *testing.T) {
 		blkDev1 := lsblk.BlockDevice{Serial: serialNumber}
 		mockLsblk.On("GetBlockDevices", device).
 			Return([]lsblk.BlockDevice{blkDev1}, nil).Times(1)
-		hasPart, err := p.DeviceHasPartitions(device, serialNumber)
+		hasPart, err := p.DeviceHasPartitions(device)
 		assert.Nil(t, err)
 		assert.False(t, hasPart)
 	})
@@ -269,22 +269,14 @@ func TestLinuxUtils_DeviceHasPartitions(t *testing.T) {
 	t.Run("Command failed", func(t *testing.T) {
 		mockLsblk.On("GetBlockDevices", device).
 			Return(nil, errors.New("error")).Times(1)
-		hasPart, err := p.DeviceHasPartitions(device, serialNumber)
+		hasPart, err := p.DeviceHasPartitions(device)
 		assert.NotNil(t, err)
 		assert.False(t, hasPart)
 	})
 	t.Run("Bad output", func(t *testing.T) {
 		mockLsblk.On("GetBlockDevices", device).
 			Return(nil, nil).Times(1)
-		hasPart, err := p.DeviceHasPartitions(device, serialNumber)
-		assert.NotNil(t, err)
-		assert.False(t, hasPart)
-	})
-	t.Run("Different serial numbers", func(t *testing.T) {
-		blkDev1 := lsblk.BlockDevice{Serial: serialNumber}
-		mockLsblk.On("GetBlockDevices", device).
-			Return([]lsblk.BlockDevice{blkDev1}, nil).Times(1)
-		hasPart, err := p.DeviceHasPartitions(device, "test2")
+		hasPart, err := p.DeviceHasPartitions(device)
 		assert.NotNil(t, err)
 		assert.False(t, hasPart)
 	})