Skip to content

Commit

Permalink
Merge pull request #2300 from libopenstorage/windows_no_controllerpub…
Browse files Browse the repository at this point in the history
…lish

Windows share support without using controller publish
  • Loading branch information
pnookala-px authored Aug 3, 2023
2 parents d39853e + c617dd0 commit 97966f7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const (
SpecIoThrottleRdBW = "io_throttle_rd_bw"
SpecIoThrottleWrBW = "io_throttle_wr_bw"
SpecReadahead = "readahead"
SpecWinshare = "winshare"
)

// OptionKey specifies a set of recognized query params.
Expand Down
8 changes: 8 additions & 0 deletions api/server/sdk/volume_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,14 @@ func mergeVolumeSpecsPolicy(vol *api.VolumeSpec, req *api.VolumeSpecPolicy, isVa
spec.Sharedv4Spec = req.GetSharedv4Spec()
}

//Winshare
if req.GetWinshareOpt() != nil {
if isValidate && vol.GetWinshare() != req.GetWinshare() {
return vol, errMsg
}
spec.Winshare = req.GetWinshare()
}

logrus.Debugf("Updated VolumeSpecs %v", spec)
return spec, nil
}
Expand Down
10 changes: 10 additions & 0 deletions api/spec/spec_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ var (
sharedv4ExternalAccessRegex = regexp.MustCompile(api.SpecSharedv4ExternalAccess + "=([A-Za-z]+),?")
Sharedv4FailoverStrategyRegex = regexp.MustCompile(api.SpecSharedv4FailoverStrategy + "=([A-Za-z]+),?")
fastpathRegex = regexp.MustCompile(api.SpecFastpath + "=([A-Za-z]+),?")
winshareRegex = regexp.MustCompile(api.SpecWinshare + "=([A-Za-z]+),?")
AutoFstrimRegex = regexp.MustCompile(api.SpecAutoFstrim + "=([A-Za-z]+),?")
SpecIoThrottleRdIOPSRegex = regexp.MustCompile(api.SpecIoThrottleRdIOPS + "=([0-9]+),?")
SpecIoThrottleWrIOPSRegex = regexp.MustCompile(api.SpecIoThrottleWrIOPS + "=([0-9]+),?")
Expand Down Expand Up @@ -606,6 +607,12 @@ func (d *specHandler) UpdateSpecFromOpts(opts map[string]string, spec *api.Volum
} else {
spec.FpPreference = fastpath
}
case api.SpecWinshare:
if winshare, err := strconv.ParseBool(v); err != nil {
return nil, nil, nil, err
} else {
spec.Winshare = winshare
}
case api.SpecAutoFstrim:
if autoFstrim, err := strconv.ParseBool(v); err != nil {
return nil, nil, nil, err
Expand Down Expand Up @@ -903,6 +910,9 @@ func (d *specHandler) SpecOptsFromString(
if ok, fastpath := d.getVal(fastpathRegex, str); ok {
opts[api.SpecFastpath] = fastpath
}
if ok, winshare := d.getVal(winshareRegex, str); ok {
opts[api.SpecWinshare] = winshare
}
if ok, autoFstrim := d.getVal(AutoFstrimRegex, str); ok {
opts[api.SpecAutoFstrim] = autoFstrim
}
Expand Down
10 changes: 10 additions & 0 deletions api/spec/spec_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,16 @@ func TestOptFastpath(t *testing.T) {
require.False(t, spec.FpPreference, "Failed to parse faspath option into spec")
}

func TestOptWinshare(t *testing.T) {
testSpecOptString(t, api.SpecWinshare, "true")

spec := testSpecFromString(t, api.SpecWinshare, "true")
require.True(t, spec.Winshare, "Failed to parse winshare option into spec")

spec = testSpecFromString(t, api.SpecWinshare, "false")
require.False(t, spec.Winshare, "Failed to parse winshare option into spec")
}

func TestOptAutoFstrim(t *testing.T) {
testSpecOptString(t, api.SpecAutoFstrim, "true")

Expand Down

0 comments on commit 97966f7

Please sign in to comment.