mirror of https://github.com/k3s-io/k3s
csi: Update version comparison model
If our supported version is still at 0.X.X, then check also the minor number. If our supported version is >= 1.X.X then check only the major number. Closes #58813pull/6/head
parent
7de1a8e0f5
commit
4abcb12296
|
@ -118,9 +118,15 @@ func (c *csiDriverClient) AssertSupportedVersion(ctx grpctx.Context, ver *csipb.
|
|||
vers := rsp.GetSupportedVersions()
|
||||
glog.V(4).Info(log("driver reports %d versions supported: %s", len(vers), versToStr(vers)))
|
||||
|
||||
// If our supported version is still at 0.X.X, then check
|
||||
// also the minor number. If our supported version is >= 1.X.X
|
||||
// then check only the major number.
|
||||
for _, v := range vers {
|
||||
//TODO (vladimirvivien) use more lenient/heuristic for exact or match of ranges etc
|
||||
if verToStr(v) == verToStr(ver) {
|
||||
if ver.GetMajor() == uint32(0) &&
|
||||
(ver.GetMajor() == v.GetMajor() && ver.GetMinor() == v.GetMinor()) {
|
||||
supported = true
|
||||
break
|
||||
} else if ver.GetMajor() != uint32(0) && ver.GetMajor() == v.GetMajor() {
|
||||
supported = true
|
||||
break
|
||||
}
|
||||
|
|
|
@ -46,8 +46,13 @@ func TestClientAssertSupportedVersion(t *testing.T) {
|
|||
mustFail bool
|
||||
err error
|
||||
}{
|
||||
{testName: "supported version", ver: &csipb.Version{Major: 0, Minor: 0, Patch: 0}},
|
||||
{testName: "supported version", ver: &csipb.Version{Major: 0, Minor: 1, Patch: 0}},
|
||||
{testName: "unsupported version", ver: &csipb.Version{Major: 0, Minor: 0, Patch: 0}, mustFail: true},
|
||||
{testName: "supported version", ver: &csipb.Version{Major: 0, Minor: 1, Patch: 10}},
|
||||
{testName: "supported version", ver: &csipb.Version{Major: 1, Minor: 1, Patch: 0}},
|
||||
{testName: "supported version", ver: &csipb.Version{Major: 1, Minor: 0, Patch: 10}},
|
||||
{testName: "unsupported version", ver: &csipb.Version{Major: 10, Minor: 0, Patch: 0}, mustFail: true},
|
||||
{testName: "unsupported version", ver: &csipb.Version{Major: 0, Minor: 10, Patch: 0}, mustFail: true},
|
||||
{testName: "grpc error", ver: &csipb.Version{Major: 0, Minor: 1, Patch: 0}, mustFail: true, err: errors.New("grpc error")},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue