Merge pull request #75799 from msau42/csi-empty-devicepath

return empty devicepath for csi attach
This commit is contained in:
Kubernetes Prow Robot 2019-03-29 06:08:13 -07:00 committed by GitHub
commit 861f1fcb2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions

View File

@ -29,7 +29,7 @@ import (
"k8s.io/klog" "k8s.io/klog"
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
storage "k8s.io/api/storage/v1" storage "k8s.io/api/storage/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors" apierrs "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -108,8 +108,8 @@ func (c *csiAttacher) Attach(spec *volume.Spec, nodeName types.NodeName) (string
klog.V(4).Info(log("attacher.Attach finished OK with VolumeAttachment object [%s]", attachID)) klog.V(4).Info(log("attacher.Attach finished OK with VolumeAttachment object [%s]", attachID))
// TODO(71164): In 1.15, return empty devicePath // Don't return attachID as a devicePath. We can reconstruct the attachID using getAttachmentName()
return attachID, nil return "", nil
} }
func (c *csiAttacher) WaitForAttach(spec *volume.Spec, _ string, pod *v1.Pod, timeout time.Duration) (string, error) { func (c *csiAttacher) WaitForAttach(spec *volume.Spec, _ string, pod *v1.Pod, timeout time.Duration) (string, error) {

View File

@ -198,7 +198,7 @@ func TestAttacherAttach(t *testing.T) {
csiAttacher := attacher.(*csiAttacher) csiAttacher := attacher.(*csiAttacher)
go func(spec *volume.Spec, id, nodename string, fail bool) { go func(spec *volume.Spec, nodename string, fail bool) {
attachID, err := csiAttacher.Attach(spec, types.NodeName(nodename)) attachID, err := csiAttacher.Attach(spec, types.NodeName(nodename))
if !fail && err != nil { if !fail && err != nil {
t.Errorf("expecting no failure, but got err: %v", err) t.Errorf("expecting no failure, but got err: %v", err)
@ -206,10 +206,10 @@ func TestAttacherAttach(t *testing.T) {
if fail && err == nil { if fail && err == nil {
t.Errorf("expecting failure, but got no err") t.Errorf("expecting failure, but got no err")
} }
if attachID != id && !fail { if attachID != "" {
t.Errorf("expecting attachID %v, got %v", id, attachID) t.Errorf("expecting empty attachID, got %v", attachID)
} }
}(tc.spec, tc.attachID, tc.nodeName, tc.shouldFail) }(tc.spec, tc.nodeName, tc.shouldFail)
var status storage.VolumeAttachmentStatus var status storage.VolumeAttachmentStatus
if tc.injectAttacherError { if tc.injectAttacherError {
@ -277,15 +277,15 @@ func TestAttacherAttachWithInline(t *testing.T) {
} }
csiAttacher := attacher.(*csiAttacher) csiAttacher := attacher.(*csiAttacher)
go func(spec *volume.Spec, id, nodename string, fail bool) { go func(spec *volume.Spec, nodename string, fail bool) {
attachID, err := csiAttacher.Attach(spec, types.NodeName(nodename)) attachID, err := csiAttacher.Attach(spec, types.NodeName(nodename))
if fail != (err != nil) { if fail != (err != nil) {
t.Errorf("expecting no failure, but got err: %v", err) t.Errorf("expecting no failure, but got err: %v", err)
} }
if attachID != id && !fail { if attachID != "" {
t.Errorf("expecting attachID %v, got %v", id, attachID) t.Errorf("expecting empty attachID, got %v", attachID)
} }
}(tc.spec, tc.attachID, tc.nodeName, tc.shouldFail) }(tc.spec, tc.nodeName, tc.shouldFail)
var status storage.VolumeAttachmentStatus var status storage.VolumeAttachmentStatus
if tc.injectAttacherError { if tc.injectAttacherError {
@ -362,10 +362,7 @@ func TestAttacherWithCSIDriver(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("Attach() failed: %s", err) t.Errorf("Attach() failed: %s", err)
} }
if expectAttach && attachID == "" { if attachID != "" {
t.Errorf("Expected attachID, got nothing")
}
if !expectAttach && attachID != "" {
t.Errorf("Expected empty attachID, got %q", attachID) t.Errorf("Expected empty attachID, got %q", attachID)
} }
}(spec, test.expectVolumeAttachment) }(spec, test.expectVolumeAttachment)