Allow CSI Drivers suporting 0.x/1.x to use old dir

Allow drivers implmenting both CSI 0.x and 1.x to use the old volume
plugin directory in addition to the the new volume plugin directory.
pull/58/head
saad-ali 2018-11-28 11:11:37 -08:00
parent 3d68f44d11
commit 18050e308c
2 changed files with 11 additions and 11 deletions

View File

@ -705,15 +705,15 @@ func highestSupportedVersion(versions []string) (*utilversion.Version, error) {
return nil, fmt.Errorf("None of the CSI versions reported by this driver are supported") return nil, fmt.Errorf("None of the CSI versions reported by this driver are supported")
} }
// Only CSI 0.x drivers are allowed to use deprecated socket dir. // Only drivers that implement CSI 0.x are allowed to use deprecated socket dir.
func isDeprecatedSocketDirAllowed(versions []string) bool { func isDeprecatedSocketDirAllowed(versions []string) bool {
for _, version := range versions { for _, version := range versions {
if !isV0Version(version) { if isV0Version(version) {
return false return true
} }
} }
return true return false
} }
func isV0Version(version string) bool { func isV0Version(version string) bool {

View File

@ -617,7 +617,7 @@ func TestValidatePlugin(t *testing.T) {
endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock", endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock",
versions: []string{"0.2.0", "v1.0.0"}, versions: []string{"0.2.0", "v1.0.0"},
foundInDeprecatedDir: true, foundInDeprecatedDir: true,
shouldFail: true, shouldFail: false,
}, },
{ {
pluginName: "test.plugin", pluginName: "test.plugin",
@ -631,7 +631,7 @@ func TestValidatePlugin(t *testing.T) {
endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock", endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock",
versions: []string{"0.2.0", "v1.2.3"}, versions: []string{"0.2.0", "v1.2.3"},
foundInDeprecatedDir: true, foundInDeprecatedDir: true,
shouldFail: true, shouldFail: false,
}, },
{ {
pluginName: "test.plugin", pluginName: "test.plugin",
@ -645,7 +645,7 @@ func TestValidatePlugin(t *testing.T) {
endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock", endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock",
versions: []string{"v1.2.3", "v0.3.0"}, versions: []string{"v1.2.3", "v0.3.0"},
foundInDeprecatedDir: true, foundInDeprecatedDir: true,
shouldFail: true, shouldFail: false,
}, },
{ {
pluginName: "test.plugin", pluginName: "test.plugin",
@ -659,14 +659,14 @@ func TestValidatePlugin(t *testing.T) {
endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock", endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock",
versions: []string{"v1.2.3", "v0.3.0", "2.0.1"}, versions: []string{"v1.2.3", "v0.3.0", "2.0.1"},
foundInDeprecatedDir: true, foundInDeprecatedDir: true,
shouldFail: true, shouldFail: false,
}, },
{ {
pluginName: "test.plugin", pluginName: "test.plugin",
endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock", endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock",
versions: []string{"v0.3.0", "2.0.1"}, versions: []string{"v0.3.0", "2.0.1"},
foundInDeprecatedDir: true, foundInDeprecatedDir: true,
shouldFail: true, shouldFail: false,
}, },
{ {
pluginName: "test.plugin", pluginName: "test.plugin",
@ -680,7 +680,7 @@ func TestValidatePlugin(t *testing.T) {
endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock", endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock",
versions: []string{"v1.2.3", "4.9.12", "v0.3.0", "2.0.1"}, versions: []string{"v1.2.3", "4.9.12", "v0.3.0", "2.0.1"},
foundInDeprecatedDir: true, foundInDeprecatedDir: true,
shouldFail: true, shouldFail: false,
}, },
{ {
pluginName: "test.plugin", pluginName: "test.plugin",
@ -694,7 +694,7 @@ func TestValidatePlugin(t *testing.T) {
endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock", endpoint: "/var/log/kubelet/plugins/myplugin/csi.sock",
versions: []string{"v1.2.3", "boo", "v0.3.0", "2.0.1"}, versions: []string{"v1.2.3", "boo", "v0.3.0", "2.0.1"},
foundInDeprecatedDir: true, foundInDeprecatedDir: true,
shouldFail: true, shouldFail: false,
}, },
{ {
pluginName: "test.plugin", pluginName: "test.plugin",