Skip to content

Commit

Permalink
Merge pull request #18 from Seagate/feat/iscsi-resync
Browse files Browse the repository at this point in the history
Feat/iscsi resync
  • Loading branch information
jskazinski authored Sep 3, 2021
2 parents f3da730 + 63ad041 commit 127ceeb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ifndef DOCKER_HUB_REPOSITORY
endif

ifndef VERSION
VERSION = v0.5.1
VERSION = v0.5.2
endif

VERSION_FLAG = -X github.com/Seagate/seagate-exos-x-csi/pkg/common.Version=$(VERSION)
Expand Down
7 changes: 1 addition & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6J
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prashantv/gostub v1.0.0 h1:wTzvgO04xSS3gHuz6Vhuo0/kvWelyJxwNS0IRBPAwGY=
github.com/prashantv/gostub v1.0.0/go.mod h1:dP1v6T1QzyGJJKFocwAU0lSZKpfjstjH8TlhkEU0on0=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
Expand Down Expand Up @@ -291,9 +289,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
Expand Down Expand Up @@ -468,8 +465,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
4 changes: 2 additions & 2 deletions helm/csi-charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: csi-driver
version: 0.5.1
appVersion: 0.5.1
version: 0.5.2
appVersion: 0.5.2
description: A dynamic persistent volume (PV) provisioner for Seagate Exos X storage systems.
type: application
home: https://github.com/Seagate/seagate-exos-x-csi
Expand Down
2 changes: 1 addition & 1 deletion helm/csi-charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ image:
repository: ghcr.io/seagate/seagate-exos-x-csi
# -- Tag to use for nodes and controller
# @default -- Uses Chart.appVersion value by default if tag does not specify a new version.
tag: "v0.5.1"
tag: "v0.5.2"
# -- Default is set to IfNotPresent, to override use Always here to always pull the specified version
pullPolicy: Always

Expand Down
47 changes: 25 additions & 22 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@ func New() *Node {

requiredBinaries := []string{
"blkid", // command-line utility to locate/print block device attributes
"blockdev", // call block device ioctls from the command line
"findmnt", // find a filesystem
"iscsiadm", // iscsi administration
"lsblk", // list block devices
"mount", // mount a filesystem
"mountpoint", // see if a directory or file is a mountpoint
"multipath", // device mapping multipathing
"multipathd", // device mapping multipathing
"scsi_id", // retrieve and generate a unique SCSI identifier
"umount", // unmount file systems
// "e2fsck", // check a Linux ext2/ext3/ext4 file system
// "mkfs.ext4", // create an ext2/ext3/ext4 filesystem
// "resize2fs", // ext2/ext3/ext4 file system resizer

// "blockdev", // call block device ioctls from the command line
// "lsblk", // list block devices
// "scsi_id", // retrieve and generate a unique SCSI identifier
// "e2fsck", // check a Linux ext2/ext3/ext4 file system
// "mkfs.ext4", // create an ext2/ext3/ext4 filesystem
// "resize2fs", // ext2/ext3/ext4 file system resizer
}

klog.Infof("Checking (%d) binaries", len(requiredBinaries))
Expand Down Expand Up @@ -159,18 +160,19 @@ func (node *Node) NodePublishVolume(ctx context.Context, req *csi.NodePublishVol
Portal: portal,
})
}
connector := &iscsi.Connector{
connector := iscsi.Connector{
Targets: targets,
Lun: int32(lun),
DoDiscovery: true,
}
path, err := connector.Connect()

path, err := iscsi.Connect(connector)
if err != nil {
return nil, status.Error(codes.Unavailable, err.Error())
}
klog.Infof("attached device at %s", path)

if connector.IsMultipathEnabled() {
if connector.Multipath {
klog.Info("device is using multipath")
} else {
klog.Info("device is NOT using multipath")
Expand Down Expand Up @@ -208,7 +210,7 @@ func (node *Node) NodePublishVolume(ctx context.Context, req *csi.NodePublishVol

iscsiInfoPath := node.getIscsiInfoPath(req.GetVolumeId())
klog.Infof("saving ISCSI connection info in %s", iscsiInfoPath)
err = connector.Persist(iscsiInfoPath)
err = iscsi.PersistConnector(&connector, iscsiInfoPath)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
Expand Down Expand Up @@ -260,23 +262,23 @@ func (node *Node) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublis
return nil, status.Error(codes.Internal, err.Error())
}

if isVolumeInUse(connector.MountTargetDevice.GetPath()) {
if isVolumeInUse(connector.DevicePath) {
klog.Info("volume is still in use on the node, thus it will not be detached")
return &csi.NodeUnpublishVolumeResponse{}, nil
}

_, err = os.Stat(connector.MountTargetDevice.GetPath())
_, err = os.Stat(connector.DevicePath)
if err != nil && os.IsNotExist(err) {
klog.Warningf("assuming that volume is already disconnected: %s", err)
return &csi.NodeUnpublishVolumeResponse{}, nil
}

if err = checkFs(connector.MountTargetDevice.GetPath()); err != nil {
if err = checkFs(connector.DevicePath); err != nil {
return nil, status.Errorf(codes.DataLoss, "Filesystem seems to be corrupted: %v", err)
}

klog.Info("detaching ISCSI device")
err = connector.DisconnectVolume()
klog.Info("DisconnectVolume, detaching ISCSI device")
err = iscsi.DisconnectVolume(*connector)
if err != nil {
return nil, err
}
Expand All @@ -296,21 +298,22 @@ func (node *Node) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolum
return nil, status.Error(codes.Internal, err.Error())
}

for i := range connector.Devices {
connector.Devices[i].Rescan()
}
// TODO: Is a rescan needed - rescan a scsi device by writing 1 in /sys/class/scsi_device/h:c:t:l/device/rescan
// for i := range connector.Devices {
// connector.Devices[i].Rescan()
// }

if connector.IsMultipathEnabled() {
if connector.Multipath {
klog.V(2).Info("device is using multipath")
if err := iscsi.ResizeMultipathDevice(connector.MountTargetDevice); err != nil {
if err := iscsi.ResizeMultipathDevice(connector.DevicePath); err != nil {
return nil, err
}
} else {
klog.V(2).Info("device is NOT using multipath")
}

klog.Infof("expanding filesystem on device %s", connector.MountTargetDevice.GetPath())
output, err := exec.Command("resize2fs", connector.MountTargetDevice.GetPath()).CombinedOutput()
klog.Infof("expanding filesystem on device %s", connector.DevicePath)
output, err := exec.Command("resize2fs", connector.DevicePath).CombinedOutput()
if err != nil {
return nil, fmt.Errorf("could not resize filesystem: %v", output)
}
Expand Down

0 comments on commit 127ceeb

Please sign in to comment.