Skip to content

Commit

Permalink
Merge pull request #128 from YeYoot/V3.2
Browse files Browse the repository at this point in the history
init v3.2.2
  • Loading branch information
YeYoot authored May 8, 2023
2 parents 142afab + cef9964 commit 60285c1
Show file tree
Hide file tree
Showing 24 changed files with 190 additions and 245 deletions.
82 changes: 0 additions & 82 deletions CI/.cloudbuild/build.yml

This file was deleted.

61 changes: 0 additions & 61 deletions CI/build.sh

This file was deleted.

50 changes: 0 additions & 50 deletions CI/conf/cmc_dependency.xml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM busybox:stable-glibc

LABEL maintainers="The Huawei CSI Team"
LABEL description="Kubernetes CSI Driver for Huawei Storage"
LABEL version="3.2.0"
LABEL version="3.2.2"

COPY huawei-csi /

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# usage: make -f Makefile VER=3.2.0 PLATFORM=X86 RELEASE_VER=2.5.RC2
# usage: make -f Makefile VER=3.2.2 PLATFORM=X86 RELEASE_VER=2.5.RC3

# (required) [3.2.0]
# (required) [3.2.2]
VER=VER
# (required) [X86 ARM]
PLATFORM=PLATFORM
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Step 1. Download the package and **cd** into the package
Step 2. Run following command to compile the Huawei CSI Driver

// PLATFORM support [X86|ARM]
make -f Makefile VER=3.2.0 PLATFORM=X86
make -f Makefile VER=3.2.2 PLATFORM=X86

Step 3. After the compilation is finished, a bin directory will be created in the current
directory, the structure is as follows:
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# limitations under the License.
#

# usage: sh build.sh 3.2.0 X86
# usage: sh build.sh 3.2.2 X86

# [3.2.0]
# [3.2.2]
VER=$1
# [X86 ARM]
PLATFORM=$2
Expand Down
5 changes: 3 additions & 2 deletions connector/connector_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"strings"
"time"

"huawei-csi-driver/csi/app"
"huawei-csi-driver/utils"
"huawei-csi-driver/utils/log"
)
Expand Down Expand Up @@ -166,7 +167,7 @@ var GetVirtualDevice = func(ctx context.Context, tgtLunGUID string) (string, int
if err != nil {
return "", 0, utils.Errorf(ctx, "check device: %s is a partition device failed. error: %v", device, err)
} else if partitionDev {
log.AddContext(ctx).Infof("Device: %s is a partition device, skip", device)
log.AddContext(ctx).Infof("Device: %s is a partition deviceskip", device)
continue
}

Expand Down Expand Up @@ -440,7 +441,7 @@ func WatchDMDevice(ctx context.Context, lunWWN string, expectPathNumber int) (DM

dm, err = findDMDeviceByWWN(ctx, lunWWN)
if err == nil {
if len(dm.Devices) == expectPathNumber {
if !app.GetGlobalConfig().AllPathOnline || len(dm.Devices) == expectPathNumber {
return dm, nil
}
log.AddContext(ctx).Warningf("Querying DM Disk Path Information. "+
Expand Down
9 changes: 5 additions & 4 deletions connector/connector_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/prashantv/gostub"
"github.com/stretchr/testify/assert"

"huawei-csi-driver/csi/app"
"huawei-csi-driver/utils"
)

Expand Down Expand Up @@ -384,9 +385,9 @@ func TestGetVirtualDevice(t *testing.T) {
{"NormalPhysicalSd*", args{context.TODO(), "7100e98b8e19b76d00e4069a00000003"}, outputs{[]string{"sdd"}, "", nil, nil}, "sdd", NotUseMultipath, false},
{"NormalPhysicalNVMe*", args{context.TODO(), "7100e98b8e19b76d00e4069a00000003"}, outputs{[]string{"nvme1n1"}, "", nil, nil}, "nvme1n1", NotUseMultipath, false},
{"ErrorMultiUltrapath*", args{context.TODO(), "7100e98b8e19b76d00e4069a00000003"}, outputs{[]string{"ultrapathh", "ultrapathi"}, "", nil, nil}, "", 0, true},
{"ErrorPartitionUltrapath*", args{context.TODO(), "7100e98b8e19b76d00e4069a00000003"}, outputs{[]string{"ultrapathh", "ultrapathh2"}, "", nil, nil}, "", 0, true},
{"ErrorPartitionDm-*", args{context.TODO(), "7100e98b8e19b76d00e4069a00000003"}, outputs{[]string{"dm-2"}, "lrwxrwxrwx. 1 root root 7 Mar 14 10:26 mpatha2 -> ../dm-2", nil, nil}, "", 0, true},
{"ErrorPartitionNvme*", args{context.TODO(), "7100e98b8e19b76d00e4069a00000003"}, outputs{[]string{"nvme1n1", "nvme1n1p1"}, "", nil, nil}, "", 0, true},
{"ErrorPartitionUltrapath*", args{context.TODO(), "7100e98b8e19b76d00e4069a00000003"}, outputs{[]string{"ultrapathh", "ultrapathh2"}, "", nil, nil}, "ultrapathh", UseUltraPathNVMe, false},
{"ErrorPartitionDm-*", args{context.TODO(), "7100e98b8e19b76d00e4069a00000003"}, outputs{[]string{"dm-2"}, "lrwxrwxrwx. 1 root root 7 Mar 14 10:26 mpatha2 -> ../dm-2", nil, nil}, "", 0, false},
{"ErrorPartitionNvme*", args{context.TODO(), "7100e98b8e19b76d00e4069a00000003"}, outputs{[]string{"nvme1n1", "nvme1n1p1"}, "", nil, nil}, "nvme1n1", 0, false},
}

stub := GetDevicesByGUID
Expand Down Expand Up @@ -462,7 +463,7 @@ func TestWatchDMDevice(t *testing.T) {

for _, c := range cases {
var startTime = time.Now()

app.Builder().WithAllPathOnline(true).Build()
stubs.Stub(&utils.ExecShellCmd, func(ctx context.Context, format string, args ...interface{}) (string, error) {
if time.Now().Sub(startTime) > c.aggregatedTime {
return fmt.Sprintf("name sysfs uuid \nmpathja %s %s", c.lunName, c.lunWWN), nil
Expand Down
22 changes: 19 additions & 3 deletions connector/iscsi/iscsi_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"huawei-csi-driver/connector"
connutils "huawei-csi-driver/connector/utils"
"huawei-csi-driver/csi/app"
"huawei-csi-driver/utils"
"huawei-csi-driver/utils/log"
)
Expand Down Expand Up @@ -805,9 +806,8 @@ func disconnectSessions(ctx context.Context, devConnectorInfos []singleConnector
for _, connectorInfo := range devConnectorInfos {
tgtPortal := connectorInfo.tgtPortal
tgtIQN := connectorInfo.tgtIQN
cmd := fmt.Sprintf("ls /dev/disk/by-path/ |grep -w %s |grep -w %s |wc -l |awk '{if($1>0) print 1; "+
"else print 0}'", tgtPortal, utils.MaskSensitiveInfo(tgtIQN))
output, err := utils.ExecShellCmd(ctx, cmd)
cmd := buildCheckSessionCmd(tgtPortal, tgtIQN)
output, err := utils.ExecShellCmdFilterLog(ctx, cmd)
if err != nil {
log.AddContext(ctx).Infof("Disconnect iSCSI target %s failed, err: %v", tgtPortal, err)
return err
Expand All @@ -820,6 +820,22 @@ func disconnectSessions(ctx context.Context, devConnectorInfos []singleConnector
return nil
}

// buildCheckSessionCmd build check iscsi session cmd
func buildCheckSessionCmd(tgtPortal, tgtIQN string) string {
// If using UltraPath , exec 'upadmin show path' .
// the terminal echo is as follows:
// $ upadmin show path
// Path ID Initiator Port Array Name Controller Target Port Path State Check State Port Type Port ID
// 1 127.0.0.1::2 101_112 0A iqn.xxx:127.0.0.1 Normal -- iSCSI CTE0.A.x
countCmd := "|wc -l |awk '{if($1>0) print 1; else print 0}'"
if app.GetGlobalConfig().VolumeUseMultiPath && app.GetGlobalConfig().ScsiMultiPathType == connector.HWUltraPath {
return fmt.Sprintf("upadmin show path |grep -w %s %s", tgtIQN, countCmd)
}

return fmt.Sprintf("ls /dev/disk/by-path/ |grep -w %s |grep -w %s %s",
tgtPortal, tgtIQN, countCmd)
}

func tryDisConnectVolume(ctx context.Context, tgtLunWWN string) error {
return connector.DisConnectVolume(ctx, tgtLunWWN, tryToDisConnectVolume)
}
Expand Down
24 changes: 23 additions & 1 deletion connector/nfs/nfs_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"time"

"github.com/container-storage-interface/spec/lib/go/csi"

"huawei-csi-driver/connector"
"huawei-csi-driver/utils"
"huawei-csi-driver/utils/log"
Expand Down Expand Up @@ -240,7 +241,8 @@ func mountUnix(ctx context.Context, sourcePath, targetPath string, flags mountPa
}

// if the checkSourcePath is false, check the filesystem by comparing the sourcePath and mountPath
if value == sourcePath || path.Base(path.Dir(targetPath)) == path.Base(path.Dir(sourcePath)) {
if value == sourcePath || path.Base(path.Dir(targetPath)) == path.Base(path.Dir(sourcePath)) ||
containSourceDevice(ctx, sourcePath, value) {
log.AddContext(ctx).Infof("Mount %s to %s is already exist", sourcePath, targetPath)
return nil
}
Expand Down Expand Up @@ -268,6 +270,26 @@ func mountUnix(ctx context.Context, sourcePath, targetPath string, flags mountPa
return nil
}

// containSourceDevice used to check target path referenced source device is equal sourceDev
func containSourceDevice(ctx context.Context, targetPath, sourceDev string) bool {
for _, value := range findSourceDevice(ctx, targetPath) {
if value == sourceDev {
return true
}
}
return false
}

// findSourceDevice use findmnt command to find mountPath referenced source device
func findSourceDevice(ctx context.Context, targetPath string) []string {
output, err := utils.ExecShellCmd(ctx, "findmnt -o source --noheadings --target %s", targetPath)
if err != nil {
return []string{}
}

return strings.Split(output, "\n")
}

func getFSType(ctx context.Context, sourcePath string) (string, error) {
// the errorCode 2 means an unFormatted filesystem and the unavailable filesystem. So ensure the device is
// available before calling command blkid
Expand Down
3 changes: 1 addition & 2 deletions connector/utils/lock/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ func SyncLock(ctx context.Context, lockName, operationType string) error {
return err
}

subCtx, cancel := context.WithTimeout(ctx, GetLockTimeoutSec*time.Second)
err = waitGetSemaphore(subCtx, cancel, operationType)
err = waitGetSemaphore(ctx, operationType)
if err != nil {
newErr := deleteLockFile(ctx, lockDir, lockName)
if newErr != nil {
Expand Down
Loading

0 comments on commit 60285c1

Please sign in to comment.