mirror of https://github.com/k3s-io/k3s
Merge pull request #75799 from msau42/csi-empty-devicepath
return empty devicepath for csi attachk3s-v1.15.3
commit
861f1fcb2e
|
@ -29,7 +29,7 @@ import (
|
|||
|
||||
"k8s.io/klog"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
storage "k8s.io/api/storage/v1"
|
||||
apierrs "k8s.io/apimachinery/pkg/api/errors"
|
||||
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))
|
||||
|
||||
// TODO(71164): In 1.15, return empty devicePath
|
||||
return attachID, nil
|
||||
// Don't return attachID as a devicePath. We can reconstruct the attachID using getAttachmentName()
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (c *csiAttacher) WaitForAttach(spec *volume.Spec, _ string, pod *v1.Pod, timeout time.Duration) (string, error) {
|
||||
|
|
|
@ -198,7 +198,7 @@ func TestAttacherAttach(t *testing.T) {
|
|||
|
||||
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))
|
||||
if !fail && err != nil {
|
||||
t.Errorf("expecting no failure, but got err: %v", err)
|
||||
|
@ -206,10 +206,10 @@ func TestAttacherAttach(t *testing.T) {
|
|||
if fail && err == nil {
|
||||
t.Errorf("expecting failure, but got no err")
|
||||
}
|
||||
if attachID != id && !fail {
|
||||
t.Errorf("expecting attachID %v, got %v", id, attachID)
|
||||
if 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
|
||||
if tc.injectAttacherError {
|
||||
|
@ -277,15 +277,15 @@ func TestAttacherAttachWithInline(t *testing.T) {
|
|||
}
|
||||
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))
|
||||
if fail != (err != nil) {
|
||||
t.Errorf("expecting no failure, but got err: %v", err)
|
||||
}
|
||||
if attachID != id && !fail {
|
||||
t.Errorf("expecting attachID %v, got %v", id, attachID)
|
||||
if 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
|
||||
if tc.injectAttacherError {
|
||||
|
@ -362,10 +362,7 @@ func TestAttacherWithCSIDriver(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("Attach() failed: %s", err)
|
||||
}
|
||||
if expectAttach && attachID == "" {
|
||||
t.Errorf("Expected attachID, got nothing")
|
||||
}
|
||||
if !expectAttach && attachID != "" {
|
||||
if attachID != "" {
|
||||
t.Errorf("Expected empty attachID, got %q", attachID)
|
||||
}
|
||||
}(spec, test.expectVolumeAttachment)
|
||||
|
|
Loading…
Reference in New Issue