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

[PWX-36750] Added NFS Proxy Endpoint to VolumeUpdateSpec #2441

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions SDK_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Releases

### v0.184.0 - (04/30/2024)

* Added new `pure_nfs_endpoint_opt` field to VolumeSpecUpdate message in proto.

### v0.183.0 - (04/30/2024)

* Added flag ResumeFromSavedOffset to verify-checksum start command
Expand Down
10,440 changes: 5,237 additions & 5,203 deletions api/api.pb.go

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion api/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,11 @@ message VolumeSpecUpdate {
oneof near_sync_replication_strategy_opt { NearSyncReplicationStrategy near_sync_replication_strategy = 43;}
// Checksummed indicates if volumed data is checksummed to provide data integrity
oneof checksummed_opt { bool checksummed = 44; }
// PureNfsEnpoint specifies NFS endpoint for PureFile Direct Access volumes
oneof pure_nfs_endpoint_opt { string pure_nfs_endpoint = 45; }
}


// VolumeSpecPolicy provides a method to set volume storage policy
message VolumeSpecPolicy {
// This defines an operator for the policy comparisons
Expand Down Expand Up @@ -5850,7 +5853,7 @@ message SdkVersion {
// SDK version major value of this specification
Major = 0;
// SDK version minor value of this specification
Minor = 183;
Minor = 184;
// SDK version patch value of this specification
Patch = 0;
}
Expand Down
5 changes: 4 additions & 1 deletion api/server/sdk/api/api.swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion api/server/sdk/volume_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,21 @@ func (s *VolumeServer) mergeVolumeSpecs(vol *api.VolumeSpec, req *api.VolumeSpec
spec.ProxySpec = vol.GetProxySpec()
}

// Pure NFS Endpoint
if vol != nil && vol.ProxySpec != nil && vol.ProxySpec.PureFileSpec != nil {
// if volume to be updated is Pure File Direct Access volume
if spec.ProxySpec == nil {
spec.ProxySpec = &api.ProxySpec{
PureFileSpec: &api.PureFileSpec{},
}
}
if req.GetPureNfsEndpoint() != "" {
spec.ProxySpec.PureFileSpec.NfsEndpoint = req.GetPureNfsEndpoint()
} else {
spec.ProxySpec.PureFileSpec.NfsEndpoint = vol.ProxySpec.PureFileSpec.GetNfsEndpoint()
}
}

// Sharedv4ServiceSpec
if req.GetSharedv4ServiceSpec() != nil {
spec.Sharedv4ServiceSpec = req.GetSharedv4ServiceSpec()
Expand Down Expand Up @@ -1094,7 +1109,6 @@ func GetDefaultVolSpecs(
}
return spec, nil
}

return mergeVolumeSpecsPolicy(spec, policy.GetPolicy(), policy.GetForce())
}

Expand All @@ -1115,6 +1129,19 @@ func mergeVolumeSpecsPolicy(vol *api.VolumeSpec, req *api.VolumeSpecPolicy, isVa
}
spec.Sharedv4 = req.GetSharedv4()
}

//NFS Endpoint
if req.GetProxySpec() != nil &&
req.GetProxySpec().GetPureFileSpec() != nil &&
req.GetProxySpec().GetPureFileSpec().NfsEndpoint != "" {
if spec.ProxySpec == nil {
spec.ProxySpec = &api.ProxySpec{
PureFileSpec: &api.PureFileSpec{},
}
}
spec.ProxySpec.PureFileSpec.NfsEndpoint = req.GetProxySpec().GetPureFileSpec().NfsEndpoint
}

//sticky
if req.GetStickyOpt() != nil {
if isValidate && vol.GetSticky() != req.GetSticky() {
Expand Down
6 changes: 6 additions & 0 deletions api/server/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,12 @@ func getVolumeUpdateSpec(spec *api.VolumeSpec, vol *api.Volume, isSchedulerReque
}
}

if spec.ProxySpec != nil && spec.ProxySpec.PureFileSpec != nil && spec.ProxySpec.PureFileSpec.NfsEndpoint != "" {
newSpec.PureNfsEndpointOpt = &api.VolumeSpecUpdate_PureNfsEndpoint{
PureNfsEndpoint: spec.ProxySpec.PureFileSpec.NfsEndpoint,
}
}

if spec.FpPreference != vol.Spec.FpPreference {
newSpec.FastpathOpt = &api.VolumeSpecUpdate_Fastpath{
Fastpath: spec.FpPreference,
Expand Down
4 changes: 0 additions & 4 deletions api/spec/spec_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package spec

import (
"fmt"
"net"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -656,9 +655,6 @@ func (d *specHandler) UpdateSpecFromOpts(opts map[string]string, spec *api.Volum
if spec.ProxySpec.PureFileSpec == nil {
spec.ProxySpec.PureFileSpec = &api.PureFileSpec{}
}
if net.ParseIP(v) == nil {
return nil, nil, nil, fmt.Errorf("invalid Pure NFS endpoint: %v", v)
}
spec.ProxySpec.PureFileSpec.NfsEndpoint = v
case api.SpecIoThrottleRdIOPS:
if spec.IoThrottle == nil {
Expand Down
17 changes: 11 additions & 6 deletions api/spec/spec_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,18 +526,23 @@ func TestPureNFSEndpoint(t *testing.T) {
require.Equal(t, proxySpec.GetPureFileSpec().GetNfsEndpoint(), nfsEndpoint)

nfsEndpoint = ""
_, _, _, err = s.SpecFromOpts(map[string]string{
spec, _, _, err = s.SpecFromOpts(map[string]string{
api.SpecPureNFSEnpoint: nfsEndpoint,
})
require.Error(t, err, "Failed to parse nfs endpoint parameter")
require.ErrorContains(t, err, "invalid Pure NFS endpoint")
require.NoError(t, err)
proxySpec = spec.GetProxySpec()
require.NotNil(t, proxySpec)
require.Equal(t, proxySpec.GetPureFileSpec().GetNfsEndpoint(), nfsEndpoint)

nfsEndpoint = "abc"
_, _, _, err = s.SpecFromOpts(map[string]string{
spec, _, _, err = s.SpecFromOpts(map[string]string{
api.SpecPureNFSEnpoint: nfsEndpoint,
})
require.Error(t, err, "Failed to parse nfs endpoint parameter")
require.ErrorContains(t, err, "invalid Pure NFS endpoint")

require.NoError(t, err)
proxySpec = spec.GetProxySpec()
require.NotNil(t, proxySpec)
require.Equal(t, proxySpec.GetPureFileSpec().GetNfsEndpoint(), nfsEndpoint)
}

func TestXattr(t *testing.T) {
Expand Down
Loading