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

Driver Node should only ping arrays within the zone on which the pod is scheduled #378

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
dbe9cb0
Add snapshot check and topology add during zone volume creation
falfaroc Dec 3, 2024
19bcb43
Add topology checks for clones
tdawe Dec 4, 2024
559f607
Add zone snapshot and restore e2e test
falfaroc Dec 5, 2024
c86b87c
Address failed PR checks
falfaroc Dec 5, 2024
e22ab62
Update README
falfaroc Dec 5, 2024
6ded989
Add setNodePodLabel and zone probing for nodes
falfaroc Dec 6, 2024
22d00d6
rb
falfaroc Dec 6, 2024
ebd8f37
Update modified goscaleio
falfaroc Dec 9, 2024
d4897b0
Use modified Authentication in goscaleio
falfaroc Dec 9, 2024
0e71a35
set timeout for probe calls with long response time
lukeatdell Dec 11, 2024
0483cc0
clarify comment
lukeatdell Dec 11, 2024
e0671d0
handle when one array has a long response time.
lukeatdell Dec 11, 2024
979ebea
optimize GetCapacity
lukeatdell Dec 11, 2024
8204ed1
optimize GetCapacity
lukeatdell Dec 11, 2024
a88e059
tidying
lukeatdell Dec 11, 2024
825b2d7
revert changes to probe calls due to data race
lukeatdell Dec 12, 2024
21e7043
update test context creation
lukeatdell Dec 12, 2024
cf89ec3
update goscaleio for context impl
lukeatdell Dec 13, 2024
cf06c7f
clarify return value for Probe()
lukeatdell Dec 13, 2024
a262f0e
Merge branch 'feature/multi-availability-zone' into usr/falfaroc/mult…
lukeatdell Dec 13, 2024
0b0d135
fix merge issue
lukeatdell Dec 13, 2024
8099403
use withContext from goscaleio
lukeatdell Dec 16, 2024
5978819
refactor changes and add UT
lukeatdell Dec 16, 2024
d0ff2fc
remove debug logs
lukeatdell Dec 17, 2024
addfc10
support context when adding pod labels
lukeatdell Dec 17, 2024
1e0c233
add tests to SetPodZoneLabel
lukeatdell Dec 17, 2024
8011ee1
tidying controller_tests
lukeatdell Dec 17, 2024
7582c91
fix int test
lukeatdell Dec 17, 2024
5415a15
linting
lukeatdell Dec 17, 2024
6671d8d
adding more tests to cover additions
lukeatdell Dec 17, 2024
62be51c
linting
lukeatdell Dec 17, 2024
bab6660
reverting debug changes
lukeatdell Dec 17, 2024
095147b
refactoring
lukeatdell Dec 17, 2024
e636b06
update copyright
lukeatdell Dec 18, 2024
4b71e12
tidying comments
lukeatdell Dec 18, 2024
d82cdfd
fix bug after regression tests
lukeatdell Dec 18, 2024
8939c70
update goscaleio
lukeatdell Dec 18, 2024
90867b3
PR comments: tdawe
lukeatdell Dec 18, 2024
5ea281b
PR comments: falfaroc
lukeatdell Dec 18, 2024
c6e56f5
align tests with new error messages from prev commit
lukeatdell Dec 18, 2024
5f49dac
add tests for systemProbeAll
lukeatdell Dec 18, 2024
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
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
Loading