Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hs 312/sas device not found #53

Merged
merged 4 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/Seagate/seagate-exos-x-csi/pkg/common"
"github.com/Seagate/seagate-exos-x-csi/pkg/controller"
"k8s.io/klog"
"k8s.io/klog/v2"
)

var bind = flag.String("bind", fmt.Sprintf("unix:///var/run/%s/csi-controller.sock", common.PluginName), "RPC bind URI (can be a UNIX socket path or any URI)")
Expand Down
3 changes: 1 addition & 2 deletions cmd/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/Seagate/seagate-exos-x-csi/pkg/common"
"github.com/Seagate/seagate-exos-x-csi/pkg/node"
"k8s.io/klog"
"k8s.io/klog/v2"
)

var bind = flag.String("bind", fmt.Sprintf("unix:///var/run/%s/csi-node.sock", common.PluginName), "RPC bind URI (can be a UNIX socket path or any URI)")
Expand All @@ -24,7 +24,6 @@ func main() {
}
}


klog.Infof("starting storage node plugin (%s)", common.Version)
node.New().Start(*bind)
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/prometheus/client_golang v1.13.0
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
google.golang.org/grpc v1.50.0
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.70.0
)

require (
Expand All @@ -37,7 +37,7 @@ require (
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.70.0 // indirect
k8s.io/klog v1.0.0 // indirect

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leads me to think that we are still using klog v1 somewhere, or is that related to klog v2 having a relationship with klog v1?

)

// replace github.com/Seagate/seagate-exos-x-api-go => ../seagate-exos-x-api-go
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
"k8s.io/klog"
"k8s.io/klog/v2"
)

// PluginName is the public name to be used in storage class etc.
Expand Down Expand Up @@ -141,7 +141,7 @@ func (driver *Driver) Start(bind string) {

var ll klog.Level = 0
for i := 0; i < 10; i++ {
if klog.V(klog.Level(i)) {
if klog.V(klog.Level(i)).Enabled() {
ll = klog.Level(i)
} else {
break
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/stringlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package common
import (
"sync"

"k8s.io/klog"
"k8s.io/klog/v2"
)

type MyMutex struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"
"unicode"

"k8s.io/klog"
"k8s.io/klog/v2"
)

// ValidateName verifies that the string only includes spaces and printable UTF-8 characters except: " , < \
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog/v2"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/expander.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/container-storage-interface/spec/lib/go/csi"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog/v2"
)

// ControllerExpandVolume expands a volume to the given new size
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/container-storage-interface/spec/lib/go/csi"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog/v2"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/container-storage-interface/spec/lib/go/csi"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog/v2"
)

// getConnectorInfoPath
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/golang/protobuf/ptypes/timestamp"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog/v2"
)

// CreateSnapshot creates a snapshot of the given volume
Expand Down
2 changes: 1 addition & 1 deletion pkg/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"k8s.io/klog"
"k8s.io/klog/v2"
)

// Exporter : Configuration (from command-line)
Expand Down
4 changes: 2 additions & 2 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog/v2"
)

// Node is the implementation of csi.NodeServer
Expand All @@ -33,7 +33,7 @@ type Node struct {

// New is a convenience function for creating a node driver
func New() *Node {
if klog.V(8) {
if klog.V(8).Enabled() {
iscsi.EnableDebugLogging(os.Stderr)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/fcNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog/v2"
)

// NodeStageVolume mounts the volume to a staging path on the node. This is
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/iscsiNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog/v2"
)

// Configuration constants
Expand Down
45 changes: 43 additions & 2 deletions pkg/storage/sasNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ import (
"os"
"os/exec"
"strings"
"time"

saslib "github.com/Seagate/csi-lib-sas/sas"
"github.com/Seagate/seagate-exos-x-csi/pkg/common"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog/v2"
)

var globalRemovedDevicesMap = map[string]time.Time{}
David-T-White marked this conversation as resolved.
Show resolved Hide resolved

// NodeStageVolume mounts the volume to a staging path on the node. This is
// called by the CO before NodePublishVolume and is used to temporary mount the
// volume to a staging path. Once mounted, NodePublishVolume will make sure to
Expand Down Expand Up @@ -63,7 +66,7 @@ func (sas *sasStorage) NodePublishVolume(ctx context.Context, req *csi.NodePubli

volumeName, _ := common.VolumeIdGetName(req.GetVolumeId())
wwn, _ := common.VolumeIdGetWwn(req.GetVolumeId())
lun, _ := req.GetPublishContext()["lun"]
lun := req.GetPublishContext()["lun"]

// Ensure that NodePublishVolume is only called once per volume
AddGatekeeper(volumeName)
Expand All @@ -80,6 +83,11 @@ func (sas *sasStorage) NodePublishVolume(ctx context.Context, req *csi.NodePubli
}
klog.Infof("attached device at %s", path)

// if current wwn has been published before, remove it from our list of previously unpublished wwns
delete(globalRemovedDevicesMap, wwn)
// check if previously unpublished devices were rediscovered by the scsi subsystem during Attach
checkPreviouslyRemovedDevices(ctx)
David-T-White marked this conversation as resolved.
Show resolved Hide resolved

fsType := req.GetVolumeContext()[common.FsTypeConfigKey]
err = EnsureFsType(fsType, path)
if err != nil {
Expand Down Expand Up @@ -215,6 +223,23 @@ func (sas *sasStorage) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnp
return nil, status.Errorf(codes.DataLoss, "(unpublish) filesystem seems to be corrupted: %v", err)
}

if !connector.Multipath {
// If we didn't discover the multipath device initially, double check that we didn't just miss it
// Detach the discovered devices if they are found
klog.Info("Device saved as non-multipath. Searching for additional devices before Detach")
if connector.IoHandler == nil {
connector.IoHandler = &saslib.OSioHandler{}
}
discoveredMpathName, devices := saslib.FindDiskById(klog.FromContext(ctx), wwn, connector.IoHandler)
if (discoveredMpathName != connector.OSPathName) && (len(devices) > 0) {
klog.V(3).Infof("Found additional linked devices: %s, %v", discoveredMpathName, devices)
David-T-White marked this conversation as resolved.
Show resolved Hide resolved
klog.V(3).Infof("Replacing original connector info prior to Detach, device: %s=>%s, linked device paths: %v=>%v", connector.OSPathName, discoveredMpathName, connector.OSDevicePaths, devices)
connector.OSPathName = discoveredMpathName
connector.OSDevicePaths = devices
connector.Multipath = true
}
}

klog.Info("DisconnectVolume, detaching SAS device")
err = saslib.Detach(ctx, connector.OSPathName, connector.IoHandler)

Expand All @@ -225,10 +250,26 @@ func (sas *sasStorage) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnp
klog.Infof("deleting SAS connection info file %s", sas.connectorInfoPath)
os.Remove(sas.connectorInfoPath)

globalRemovedDevicesMap[connector.VolumeWWN] = time.Now()

klog.Info("successfully detached SAS device")
return &csi.NodeUnpublishVolumeResponse{}, nil
}

func checkPreviouslyRemovedDevices(ctx context.Context) error {
klog.Info("Checking previously removed devices")
for wwn, _ := range globalRemovedDevicesMap {
klog.Infof("Checking for rediscovery of wwn:%s", wwn)

dm, devices := saslib.FindDiskById(klog.FromContext(ctx), wwn, &saslib.OSioHandler{})
if dm != "" {
klog.Infof("Rediscovery found for wwn:%s -- mpath device: %s, devices: %v", wwn, dm, devices)
saslib.Detach(ctx, dm, &saslib.OSioHandler{})
}
}
return nil
}

// NodeGetVolumeStats return info about a given volume
// Will not be called as the plugin does not have the GET_VOLUME_STATS capability
func (sas *sasStorage) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/storageService.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/Seagate/seagate-exos-x-csi/pkg/common"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/pkg/errors"
"k8s.io/klog"
"k8s.io/klog/v2"
)

type StorageOperations interface {
Expand Down Expand Up @@ -64,7 +64,7 @@ func buildCommonService(config map[string]string) (commonService, error) {
return commonserv, nil
}

//NewStorageNode : To return specific implementation of storage
// NewStorageNode : To return specific implementation of storage
func NewStorageNode(storageProtocol string, config map[string]string) (StorageOperations, error) {
comnserv, err := buildCommonService(config)
if err == nil {
Expand Down