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

Disabling SDC dependency for NFS Volume Provisioning #330

Merged
merged 26 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
384e855
initial changes to add ping of NAS server
bharathsreekanth Sep 10, 2024
3b5a57c
refactor changes
bharathsreekanth Sep 10, 2024
6a8336c
Tweak NAS name check
bharathsreekanth Sep 10, 2024
3b94dff
Refactor ping nas
bharathsreekanth Sep 13, 2024
51a66dc
Code cleanup
bharathsreekanth Sep 13, 2024
704223a
Add UTs, minor fixes
bharathsreekanth Sep 18, 2024
0a7ef14
Refactor UTs to add some error cases
bharathsreekanth Sep 19, 2024
574aa4a
Remove tags
bharathsreekanth Sep 19, 2024
004c3c2
Fix other UTs
bharathsreekanth Sep 19, 2024
f50883c
multi-interface IPs
suryagupta4 Aug 20, 2024
4f486bc
Find Network Interface IPs
harshitap26 Sep 11, 2024
5704e61
code formatting
harshitap26 Sep 12, 2024
6b674ce
Adding Unit tests
harshitap26 Sep 13, 2024
fd81ddd
Added test for controller functions
harshitap26 Sep 14, 2024
be4e87b
Unit test for code coverage
harshitap26 Sep 17, 2024
89b90c3
Resolving lint issues
harshitap26 Sep 17, 2024
1a5b2a1
Resolving lint issues
harshitap26 Sep 17, 2024
b769976
Resolving lint issues
harshitap26 Sep 17, 2024
2f8f58a
Updating the Unit tests for Code Coverage
harshitap26 Sep 18, 2024
2295266
fix UT, update to latest goscaleio (#332)
bharathsreekanth Sep 24, 2024
3e6a5ed
Make nodeID either node UUID or SDC GUID
bharathsreekanth Sep 27, 2024
c546b47
Add more UTs
bharathsreekanth Sep 27, 2024
9de7936
Resolving linting issues
harshitap26 Sep 29, 2024
634eaad
Address PR comments
bharathsreekanth Sep 30, 2024
5249ec5
Address PR comment
bharathsreekanth Oct 1, 2024
b00432b
Minor PR comment fixes
bharathsreekanth Oct 1, 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
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ module github.com/dell/csi-vxflexos/v2
// In order to run unit tests on Windows, you need a stubbed Windows implementation
// of the gofsutil package. Use the following replace statements if necessary.

go 1.22
go 1.22.0

toolchain go1.22.5
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to define a toolchain here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure on this, I'd have to defer this to Harshita.


require (
github.com/akutz/memconn v0.1.0
Expand All @@ -16,7 +18,7 @@ require (
github.com/dell/dell-csi-extensions/volumeGroupSnapshot v1.6.0
github.com/dell/gocsi v1.11.0
github.com/dell/gofsutil v1.16.1
github.com/dell/goscaleio v1.15.0
github.com/dell/goscaleio v1.16.1-0.20240923113203-f072f0cb0a88
bharathsreekanth marked this conversation as resolved.
Show resolved Hide resolved
github.com/fsnotify/fsnotify v1.5.1
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.0
Expand Down Expand Up @@ -73,7 +75,7 @@ require (
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ github.com/dell/gocsi v1.11.0 h1:P84VOPd1V55JQjx4tfd/6QOlVQRQkYUqmGqbzPKeyUQ=
github.com/dell/gocsi v1.11.0/go.mod h1:LzGAsEIjBxVXJuabzsG3/MsdCOczxDE1IWOBxzXIUhw=
github.com/dell/gofsutil v1.16.1 h1:BzdxMdIDgKzinlYyi5G3pi27Jw0cmtqRHM5UsIkoE+w=
github.com/dell/gofsutil v1.16.1/go.mod h1:bZ43qAOqKzGJxCRvkTVD7GCFMNkK37ur84mmMuxQshE=
github.com/dell/goscaleio v1.15.0 h1:DzI1ZlQhdIR+V4AKGOMwz1Viu2bAtj3N6kTyixB0Qg8=
github.com/dell/goscaleio v1.15.0/go.mod h1:h7SCmReARG/szFWBMQGETGkZObknhS45lQipQbtdmJ8=
github.com/dell/goscaleio v1.16.1-0.20240912175217-52d904077dc7 h1:X3CuTHtIPo8+3JZOl9z+mmoym5TTP2mYAIWKtSX/hoc=
github.com/dell/goscaleio v1.16.1-0.20240912175217-52d904077dc7/go.mod h1:h7SCmReARG/szFWBMQGETGkZObknhS45lQipQbtdmJ8=
github.com/dell/goscaleio v1.16.1-0.20240923113203-f072f0cb0a88 h1:+JewlsDL4XH/lupX7r4Z8M3D19MF9K2U8y33SCs3LGY=
github.com/dell/goscaleio v1.16.1-0.20240923113203-f072f0cb0a88/go.mod h1:b2mbdhG3IHp8YfvDrj7jWHdJNkqyrUhWNDEvo4GVEUc=
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 @@ -606,6 +608,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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/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
87 changes: 74 additions & 13 deletions service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ import (
"sync"
"time"

"github.com/dell/csi-vxflexos/v2/k8sutils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"sigs.k8s.io/yaml"

"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
Expand Down Expand Up @@ -129,6 +134,8 @@ const (

sioReplicationGroupExists = "The Replication Consistency Group already exists"
sioReplicationPairExists = "A Replication Pair for the specified local volume already exists"

DriverConfigParamsYaml = "driver-config-params.yaml"
)

// Extra metadata field names for propagating to goscaleio and beyond.
Expand Down Expand Up @@ -322,6 +329,7 @@ func (s *service) CreateVolume(
Log.Printf("Size %d is less than 3GB, rounding to 3GB", size/bytesInGiB)
size = minNfsSize
}

contentSource := req.GetVolumeContentSource()
if contentSource != nil {
snapshotSource := contentSource.GetSnapshot()
Expand Down Expand Up @@ -1166,6 +1174,45 @@ func (s *service) DeleteVolume(
return &csi.DeleteVolumeResponse{}, nil
}

func (s *service) findNetworkInterfaceIPs() ([]string, error) {
if K8sClientset == nil {
err := k8sutils.CreateKubeClientSet()
if err != nil {
Log.Errorf("Failed to create Kubernetes clientset: %v", err)
return []string{}, err
}
K8sClientset = k8sutils.Clientset
}

// Get the ConfigMap
configMap, err := K8sClientset.CoreV1().ConfigMaps(DriverNamespace).Get(context.TODO(), DriverConfigMap, metav1.GetOptions{})
if err != nil {
Log.Errorf("Failed to get the ConfigMap: %v", err)
return []string{}, err
}

var configData map[string]interface{}
var allNetworkInterfaceIPs []string

if configParamsYaml, ok := configMap.Data[DriverConfigParamsYaml]; ok {
err := yaml.Unmarshal([]byte(configParamsYaml), &configData)
if err != nil {
Log.Errorf("Failed to unmarshal the ConfigMap params: %v", err)
return []string{}, err
}

if interfaceNames, ok := configData["interfaceNames"].(map[string]interface{}); ok {
for _, ipAddressList := range interfaceNames {

ipAddresses := strings.Split(ipAddressList.(string), ",")
allNetworkInterfaceIPs = append(allNetworkInterfaceIPs, ipAddresses...)
}
return allNetworkInterfaceIPs, nil
}
}
return []string{}, fmt.Errorf("failed to get the Network Interface IPs")
}

func (s *service) ControllerPublishVolume(
ctx context.Context,
req *csi.ControllerPublishVolumeRequest) (
Expand Down Expand Up @@ -1241,15 +1288,24 @@ func (s *service) ControllerPublishVolume(
err.Error())
}

sdcIPs, err := s.getSDCIPs(nodeID, systemID)
if err != nil {
return nil, status.Errorf(codes.NotFound, "%s", err.Error())
} else if len(sdcIPs) == 0 {
return nil, status.Errorf(codes.NotFound, "%s", "received empty sdcIPs")
var ipAddresses []string

ipAddresses, err = s.findNetworkInterfaceIPs()
Log.Printf("ControllerPublish - No network interfaces found, trying to get SDC IPs")
if err != nil || len(ipAddresses) == 0 {

bharathsreekanth marked this conversation as resolved.
Show resolved Hide resolved
// get SDC IPs if Network Interface IPs not found
ipAddresses, err = s.getSDCIPs(nodeID, systemID)
if err != nil {
return nil, status.Errorf(codes.NotFound, "%s", err.Error())
} else if len(ipAddresses) == 0 {
return nil, status.Errorf(codes.NotFound, "%s", "received empty sdcIPs")
}
}
Log.Printf("ControllerPublish - ipAddresses %v", ipAddresses)

externalAccess := s.opts.ExternalAccess
publishContext["host"] = sdcIPs[0]
publishContext["host"] = ipAddresses[0]

fsc := req.GetVolumeCapability()
if fsc == nil {
Expand All @@ -1267,7 +1323,7 @@ func (s *service) ControllerPublishVolume(
errUnknownAccessMode)
}
// Export for NFS
resp, err := s.exportFilesystem(ctx, req, adminClient, fs, sdcIPs, externalAccess, nodeID, publishContext, am)
resp, err := s.exportFilesystem(ctx, req, adminClient, fs, ipAddresses, externalAccess, nodeID, publishContext, am)
return resp, err
}
volID := getVolumeIDFromCsiVolumeID(csiVolID)
Expand Down Expand Up @@ -1564,15 +1620,20 @@ func (s *service) ControllerUnpublishVolume(
err.Error())
}

sdcIPs, err := s.getSDCIPs(nodeID, systemID)
if err != nil {
return nil, status.Errorf(codes.NotFound, "%s", err.Error())
} else if len(sdcIPs) == 0 {
return nil, status.Errorf(codes.NotFound, "%s", "received empty sdcIPs")
var ipAddresses []string
ipAddresses, err = s.findNetworkInterfaceIPs()
if err != nil || len(ipAddresses) == 0 {

ipAddresses, err = s.getSDCIPs(nodeID, systemID)
if err != nil {
return nil, status.Errorf(codes.NotFound, "%s", err.Error())
} else if len(ipAddresses) == 0 {
return nil, status.Errorf(codes.NotFound, "%s", "received empty sdcIPs")
}
}

// unexport for NFS
err = s.unexportFilesystem(ctx, req, adminClient, fs, req.GetVolumeId(), sdcIPs, nodeID)
err = s.unexportFilesystem(ctx, req, adminClient, fs, req.GetVolumeId(), ipAddresses, nodeID)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions service/features/array-config/config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"insecure": true,
"isDefault": true,
"systemID": "14dbbf5617523654",
"nasName": "dummy-name"
"nasName": "dummy-nas-server"
},
{
"endpoint": "http://127.0.0.2",
Expand All @@ -16,6 +16,6 @@
"isDefault": false,
"systemID": "15dbbf5617523655",
"AllSystemNames" : "15dbbf5617523655-previous-name",
"nasName": "dummy-name"
"nasName": "dummy-nas-server"
}
]
6 changes: 3 additions & 3 deletions service/features/array-config/config.2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"insecure": true,
"isDefault": true,
"systemID": "14dbbf5617523654"
"nasName": "dummy-name"
"nasName": "dummy-nas-server"
},
{
"endpoint": "http://127.0.0.2",
Expand All @@ -15,7 +15,7 @@
"insecure": true,
"isDefault": false,
"systemID": "15dbbf5617523655"
"nasName": "dummy-name"
"nasName": "dummy-nas-server"
},
{
"username": "admin",
Expand All @@ -24,6 +24,6 @@
"endpoint": "https://1.2.3.4",
"insecure": true,
"isDefault": false
"nasName": "dummy-name"
"nasName": "dummy-nas-server"
}
]
16 changes: 14 additions & 2 deletions service/features/controller_publish_unpublish.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ Feature: VxFlex OS CSI interface
And I call UnpublishVolume nfs
And no error was received
Then a valid UnpublishVolumeResponse is returned

Scenario: a Basic NFS controller Publish and unpublish no error with SDC dependency
Given a VxFlexOS service
When I specify CreateVolumeMountRequest "nfs"
And I call CreateVolume "volume1"
Then a valid CreateVolumeResponse is returned
And I induce SDC dependency
And I call NFS PublishVolume with "single-writer"
Then a valid PublishVolumeResponse is returned
And I call UnpublishVolume nfs
And no error was received
Then a valid UnpublishVolumeResponse is returned

Scenario: a Basic NFS controller Publish and unpublish NFS export not found error
Given a VxFlexOS service
Expand Down Expand Up @@ -117,7 +129,7 @@ Feature: VxFlex OS CSI interface
Then a valid PublishVolumeResponse is returned
And I call NFS PublishVolume with "single-node-multi-writer"
Then a valid PublishVolumeResponse is returned

Scenario: a Basic NFS controller Publish incompatible access mode error
Given a VxFlexOS service
When I specify CreateVolumeMountRequest "nfs"
Expand Down Expand Up @@ -259,7 +271,7 @@ Feature: VxFlex OS CSI interface
And a valid volume
When I call Probe
And I call PublishVolume with <access>
Then the error contains "Expecting this volume id only on default system. Aborting operation"
Then the error contains "expecting this volume id only on default system. aborting operation"

Examples:
| access |
Expand Down
2 changes: 1 addition & 1 deletion service/features/csi_extension.feature
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Examples:
When I call Probe
And I induce error "LegacyVolumeConflictError"
And I call CreateVolumeSnapshotGroup
Then the error contains "Expecting this volume id only on default system"
Then the error contains "expecting this volume id only on default system"

@vg
Scenario: Snapshot a block volume consistency group with wrong system
Expand Down
2 changes: 1 addition & 1 deletion service/features/replication.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Scenario Outline: Test CreateRemoteVolume
| "sourcevol" | "PeerMdmError" | "PeerMdmError" |
| "sourcevol" | "CreateVolumeError" | "create volume induced error" |
| "sourcevol" | "BadVolIDError" | "failed to provide" |
| "sourcevol" | "BadRemoteSystemIDError" | "System 15dbbf5617523655 not found" |
| "sourcevol" | "BadRemoteSystemIDError" | "system 15dbbf5617523655 not found" |
| "sourcevol" | "ProbePrimaryError" | "PodmonControllerProbeError" |
| "sourcevol" | "ProbeSecondaryError" | "PodmonControllerProbeError" |

Expand Down
Loading
Loading