Skip to content

Commit

Permalink
Driver Node should only ping arrays within the zone on which the pod …
Browse files Browse the repository at this point in the history
…is scheduled (#378)

* configure driver node service to only ping arrays in the same zone as the service.

Co-authored-by: Fernando Alfaro Campos <[email protected]>
Co-authored-by: Trevor Dawe <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2024
1 parent 8c6ae2c commit cb1ecfd
Show file tree
Hide file tree
Showing 10 changed files with 865 additions and 160 deletions.
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module github.com/dell/csi-vxflexos/v2
go 1.23

require (
github.com/akutz/memconn v0.1.0
github.com/apparentlymart/go-cidr v1.1.0
github.com/container-storage-interface/spec v1.6.0
github.com/cucumber/godog v0.12.1
Expand All @@ -16,14 +15,14 @@ require (
github.com/dell/dell-csi-extensions/volumeGroupSnapshot v1.7.0
github.com/dell/gocsi v1.12.0
github.com/dell/gofsutil v1.17.0
github.com/dell/goscaleio v1.17.0
github.com/dell/goscaleio v1.17.2-0.20241218182509-936b677c46d5
github.com/fsnotify/fsnotify v1.5.1
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.0
github.com/kubernetes-csi/csi-lib-utils v0.9.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/viper v1.10.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.9.0
golang.org/x/net v0.28.0
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.34.2
Expand Down Expand Up @@ -73,7 +72,7 @@ require (
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
Expand Down
21 changes: 14 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdko
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/akutz/gosync v0.1.0 h1:naxPT/aDYDh79PMwM3XmencmNQeYmpNFSZy4ZE9zIW0=
github.com/akutz/gosync v0.1.0/go.mod h1:I8I4aiqJI1nqaeYOOB1WS+CgRJVVPqhct9Y4njywM84=
github.com/akutz/memconn v0.1.0 h1:NawI0TORU4hcOMsMr11g7vwlCdkYeLKXBcxWu2W/P8A=
github.com/akutz/memconn v0.1.0/go.mod h1:Jo8rI7m0NieZyLI5e2CDlRdRqRRB4S7Xp77ukDjH+Fw=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand Down Expand Up @@ -116,8 +114,16 @@ github.com/dell/gocsi v1.12.0 h1:Dn/8f2BLovo57T/aC5pP/4Eqz4h6WX8SbX+hxT5NlvQ=
github.com/dell/gocsi v1.12.0/go.mod h1:hJURrmDrXDGW4xVtgi5Kx6zUsU3ht9l+nlreNx33rf0=
github.com/dell/gofsutil v1.17.0 h1:QA6gUb1mz8kXNEN4eEx47OHCz8nSqZrrCnaDUYmV5EY=
github.com/dell/gofsutil v1.17.0/go.mod h1:PN2hWl/pVLQiTsFR0X1x+GfhfOrfW8pGgH5xGcGMeFs=
github.com/dell/goscaleio v1.17.0 h1:x+RfTgLW6fCwVpMgKjbGPXtwioK7KO7CBNQ54E0jLl0=
github.com/dell/goscaleio v1.17.0/go.mod h1:dB1a2wXevGps25VAda+6WDp+NTUdgMZXvQVM0YOBpX8=
github.com/dell/goscaleio v1.17.2-0.20241209165307-dcbadc33ab2e h1:Y+F8YP3ceH6XRz0phFV5VpS2Pmoi8f0Vtg261/C2pZo=
github.com/dell/goscaleio v1.17.2-0.20241209165307-dcbadc33ab2e/go.mod h1:7bX3rL8JWMmdifGr/UeD/Ju9wbkHUqvKDrbdu7XyGm8=
github.com/dell/goscaleio v1.17.2-0.20241213145027-141cfe292cfa h1:9honWWT9xEcI0OWyLtiWIDCaMAEpBAeyyzW+KPRVh10=
github.com/dell/goscaleio v1.17.2-0.20241213145027-141cfe292cfa/go.mod h1:7bX3rL8JWMmdifGr/UeD/Ju9wbkHUqvKDrbdu7XyGm8=
github.com/dell/goscaleio v1.17.2-0.20241213204026-19006b56eb26 h1:Kg6MSwBmAlmUDWRKiG0YJRv1xd8qi9+mW7vAVNnghj4=
github.com/dell/goscaleio v1.17.2-0.20241213204026-19006b56eb26/go.mod h1:7bX3rL8JWMmdifGr/UeD/Ju9wbkHUqvKDrbdu7XyGm8=
github.com/dell/goscaleio v1.17.2-0.20241213215244-2164caaef4ab h1:DYWY7fs8v1VbmzF2pAx7peZtKhkppW5NCIyHCJN1fS4=
github.com/dell/goscaleio v1.17.2-0.20241213215244-2164caaef4ab/go.mod h1:7bX3rL8JWMmdifGr/UeD/Ju9wbkHUqvKDrbdu7XyGm8=
github.com/dell/goscaleio v1.17.2-0.20241218182509-936b677c46d5 h1:d7DwHvp7/hESR742f4iurtH3nHHSGPvnMadujZA2hsU=
github.com/dell/goscaleio v1.17.2-0.20241218182509-936b677c46d5/go.mod h1:2BsR92dYYnSmbZ34ixYdsucfyoQBDlbhbUUKnv6WalQ=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
Expand Down Expand Up @@ -432,8 +438,9 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/thecodeteam/gosync v0.1.0 h1:RcD9owCaiK0Jg1rIDPgirdcLCL1jCD6XlDVSg0MfHmE=
Expand Down Expand Up @@ -604,8 +611,8 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down
96 changes: 84 additions & 12 deletions service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2266,13 +2266,16 @@ func (s *service) getSystemCapacity(ctx context.Context, systemID, protectionDom

adminClient := s.adminClients[systemID]
system := s.systems[systemID]
if adminClient == nil || system == nil {
return 0, fmt.Errorf("can't find adminClient or system by id %s", systemID)
}

var statsFunc func() (*siotypes.Statistics, error)

// Default to get Capacity of system
statsFunc = system.GetStatistics

if len(spName) > 0 {
if len(spName) > 0 && spName[0] != "" {
// if storage pool is given, get capacity of storage pool
pdID, err := s.getProtectionDomainIDFromName(systemID, protectionDomain)
if err != nil {
Expand Down Expand Up @@ -2365,6 +2368,15 @@ func (s *service) GetCapacity(
}
}

// If using availability zones, get capacity for the system in the zone
// using accessible topology parameter from k8s.
if s.opts.zoneLabelKey != "" {
systemID, err = s.getSystemIDFromZoneLabelKey(req)
if err != nil {
return nil, status.Errorf(codes.Internal, "%s", err.Error())
}
}

if systemID == "" {
// Get capacity of storage pool spname in all systems, return total capacity
capacity, err = s.getCapacityForAllSystems(ctx, "", spname)
Expand Down Expand Up @@ -2407,6 +2419,28 @@ func (s *service) GetCapacity(
}, nil
}

// getSystemIDFromZoneLabelKey returns the system ID associated with the zoneLabelKey if zoneLabelKey is set and
// contains an associated zone name. Returns an empty string otherwise.
func (s *service) getSystemIDFromZoneLabelKey(req *csi.GetCapacityRequest) (systemID string, err error) {
zoneName, ok := req.AccessibleTopology.Segments[s.opts.zoneLabelKey]
if !ok {
Log.Infof("could not get availability zone from accessible topology. Getting capacity for all systems")
return "", nil
}

// find the systemID with the matching zone name
for _, array := range s.opts.arrays {
if zoneName == string(array.AvailabilityZone.Name) {
systemID = array.SystemID
break
}
}
if systemID == "" {
return "", fmt.Errorf("could not find an array assigned to zone '%s'", zoneName)
}
return systemID, nil
}

func (s *service) getMaximumVolumeSize(systemID string) (int64, error) {
valueInCache, found := getCachedMaximumVolumeSize(systemID)
if !found || valueInCache < 0 {
Expand Down Expand Up @@ -2540,15 +2574,51 @@ func (s *service) ControllerGetCapabilities(
}, nil
}

func (s *service) getZoneFromZoneLabelKey(ctx context.Context, zoneLabelKey string) (zone string, err error) {
// get labels for this service, s
labels, err := GetNodeLabels(ctx, s)
if err != nil {
return "", err
}

Log.Infof("Listing labels: %v", labels)

// get the zone name from the labels
if val, ok := labels[zoneLabelKey]; ok {
return val, nil
}

return "", fmt.Errorf("label %s not found", zoneLabelKey)
}

// systemProbeAll will iterate through all arrays in service.opts.arrays and probe them. If failed, it logs
// the failed system name
func (s *service) systemProbeAll(ctx context.Context) error {
// probe all arrays
Log.Infof("Probing all arrays. Number of arrays: %d", len(s.opts.arrays))
Log.Infoln("Probing all associated arrays")
allArrayFail := true
errMap := make(map[string]error)
zoneName := ""
usingZones := s.opts.zoneLabelKey != "" && s.isNodeMode()

if usingZones {
var err error
zoneName, err = s.getZoneFromZoneLabelKey(ctx, s.opts.zoneLabelKey)
if err != nil {
return err
}
Log.Infof("probing zoneLabel '%s', zone value: '%s'", s.opts.zoneLabelKey, zoneName)
}

for _, array := range s.opts.arrays {
// If zone information is available, use it to probe the array
if usingZones && !array.isInZone(zoneName) {
// Driver node containers should not probe arrays that exist outside their assigned zone
// Driver controller container should probe all arrays
Log.Infof("array %s zone %s does not match %s, not pinging this array\n", array.SystemID, array.AvailabilityZone.Name, zoneName)
continue
}

err := s.systemProbe(ctx, array)
systemID := array.SystemID
if err == nil {
Expand All @@ -2569,23 +2639,23 @@ func (s *service) systemProbeAll(ctx context.Context) error {
}

// systemProbe will probe the given array
func (s *service) systemProbe(_ context.Context, array *ArrayConnectionData) error {
func (s *service) systemProbe(ctx context.Context, array *ArrayConnectionData) error {
// Check that we have the details needed to login to the Gateway
if array.Endpoint == "" {
return status.Error(codes.FailedPrecondition,
"missing VxFlexOS Gateway endpoint")
"missing PowerFlex Gateway endpoint")
}
if array.Username == "" {
return status.Error(codes.FailedPrecondition,
"missing VxFlexOS MDM user")
"missing PowerFlex MDM user")
}
if array.Password == "" {
return status.Error(codes.FailedPrecondition,
"missing VxFlexOS MDM password")
"missing PowerFlex MDM password")
}
if array.SystemID == "" {
return status.Error(codes.FailedPrecondition,
"missing VxFlexOS system name")
"missing PowerFlex system name")
}
var altSystemNames []string
if array.AllSystemNames != "" {
Expand All @@ -2608,25 +2678,27 @@ func (s *service) systemProbe(_ context.Context, array *ArrayConnectionData) err
}
}

Log.Printf("Login to PowerFlex Gateway, system=%s, endpoint=%s, user=%s\n", systemID, array.Endpoint, array.Username)

if s.adminClients[systemID].GetToken() == "" {
_, err := s.adminClients[systemID].Authenticate(&goscaleio.ConfigConnect{
_, err := s.adminClients[systemID].WithContext(ctx).Authenticate(&goscaleio.ConfigConnect{
Endpoint: array.Endpoint,
Username: array.Username,
Password: array.Password,
})
if err != nil {
return status.Errorf(codes.FailedPrecondition,
"unable to login to VxFlexOS Gateway: %s", err.Error())
"unable to login to PowerFlex Gateway: %s", err.Error())
}
}

// initialize system if needed
if s.systems[systemID] == nil {
system, err := s.adminClients[systemID].FindSystem(
system, err := s.adminClients[systemID].WithContext(ctx).FindSystem(
array.SystemID, array.SystemID, "")
if err != nil {
return status.Errorf(codes.FailedPrecondition,
"unable to find matching VxFlexOS system name: %s",
"unable to find matching PowerFlex system name: %s",
err.Error())
}
s.systems[systemID] = system
Expand Down Expand Up @@ -3582,7 +3654,7 @@ func (s *service) CreateReplicationConsistencyGroupSnapshot(client *goscaleio.Cl
rcg := goscaleio.NewReplicationConsistencyGroup(client)
rcg.ReplicationConsistencyGroup = group

response, err := rcg.CreateReplicationConsistencyGroupSnapshot(false)
response, err := rcg.CreateReplicationConsistencyGroupSnapshot()
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit cb1ecfd

Please sign in to comment.