mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Add storage layer contexts (#10321)
Add context to all (non-trivial) calls to the storage layer. Contexts are propagated through the REST client. - `context.TODO()` is left in place for the places where it needs to be added to the caller. - `endWalkCh` could probably be removed from the walkers, but no changes so far. The "dangerous" part is that now a caller disconnecting *will* propagate down, so a "delete" operation will now be interrupted. In some cases we might want to disconnect this functionality so the operation completes if it has started, leaving the system in a cleaner state.
This commit is contained in:
@@ -20,6 +20,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -54,20 +55,20 @@ func TestUNCPaths(t *testing.T) {
|
||||
}
|
||||
|
||||
// Create volume to use in conjunction with other StorageAPI's file API(s)
|
||||
err = fs.MakeVol("voldir")
|
||||
err = fs.MakeVol(context.Background(), "voldir")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for i, test := range testCases {
|
||||
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
||||
err = fs.AppendFile("voldir", test.objName, []byte("hello"))
|
||||
err = fs.AppendFile(context.Background(), "voldir", test.objName, []byte("hello"))
|
||||
if err != nil && test.pass {
|
||||
t.Error(err)
|
||||
} else if err == nil && !test.pass {
|
||||
t.Error(err)
|
||||
}
|
||||
fs.DeleteFile("voldir", test.objName)
|
||||
fs.DeleteFile(context.Background(), "voldir", test.objName)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -89,19 +90,19 @@ func TestUNCPathENOTDIR(t *testing.T) {
|
||||
}
|
||||
|
||||
// Create volume to use in conjunction with other StorageAPI's file API(s)
|
||||
err = fs.MakeVol("voldir")
|
||||
err = fs.MakeVol(context.Background(), "voldir")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = fs.AppendFile("voldir", "/file", []byte("hello"))
|
||||
err = fs.AppendFile(context.Background(), "voldir", "/file", []byte("hello"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Try to create a file that includes a file in its path components.
|
||||
// In *nix, this returns syscall.ENOTDIR while in windows we receive the following error.
|
||||
err = fs.AppendFile("voldir", "/file/obj1", []byte("hello"))
|
||||
err = fs.AppendFile(context.Background(), "voldir", "/file/obj1", []byte("hello"))
|
||||
if err != errFileAccessDenied {
|
||||
t.Errorf("expected: %s, got: %s", errFileAccessDenied, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user