diff options
Diffstat (limited to 'weed/shell')
23 files changed, 39 insertions, 27 deletions
diff --git a/weed/shell/command_fs_cat.go b/weed/shell/command_fs_cat.go index 47a7f3be8..cf1395a2f 100644 --- a/weed/shell/command_fs_cat.go +++ b/weed/shell/command_fs_cat.go @@ -1,6 +1,7 @@ package shell import ( + "context" "fmt" "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" @@ -49,7 +50,7 @@ func (c *commandFsCat) Do(args []string, commandEnv *CommandEnv, writer io.Write Name: name, Directory: dir, } - respLookupEntry, err := filer_pb.LookupEntry(client, request) + respLookupEntry, err := filer_pb.LookupEntry(context.Background(), client, request) if err != nil { return err } diff --git a/weed/shell/command_fs_du.go b/weed/shell/command_fs_du.go index c35179f88..456f6bab6 100644 --- a/weed/shell/command_fs_du.go +++ b/weed/shell/command_fs_du.go @@ -1,6 +1,7 @@ package shell import ( + "context" "fmt" "io" @@ -58,7 +59,7 @@ func (c *commandFsDu) Do(args []string, commandEnv *CommandEnv, writer io.Writer func duTraverseDirectory(writer io.Writer, filerClient filer_pb.FilerClient, dir, name string) (blockCount, byteCount uint64, err error) { - err = filer_pb.ReadDirAllEntries(filerClient, util.FullPath(dir), name, func(entry *filer_pb.Entry, isLast bool) error { + err = filer_pb.ReadDirAllEntries(context.Background(), filerClient, util.FullPath(dir), name, func(entry *filer_pb.Entry, isLast bool) error { var fileBlockCount, fileByteCount uint64 diff --git a/weed/shell/command_fs_log.go b/weed/shell/command_fs_log.go index e6b7a6f9a..66f143030 100644 --- a/weed/shell/command_fs_log.go +++ b/weed/shell/command_fs_log.go @@ -1,6 +1,7 @@ package shell import ( + "context" "flag" "fmt" "github.com/seaweedfs/seaweedfs/weed/filer" @@ -41,11 +42,11 @@ func (c *commandFsLogPurge) Do(args []string, commandEnv *CommandEnv, writer io. } modificationTimeAgo := time.Now().Add(-time.Hour * 24 * time.Duration(*daysAgo)).Unix() - err = filer_pb.ReadDirAllEntries(commandEnv, filer.SystemLogDir, "", func(entry *filer_pb.Entry, isLast bool) error { + err = filer_pb.ReadDirAllEntries(context.Background(), commandEnv, filer.SystemLogDir, "", func(entry *filer_pb.Entry, isLast bool) error { if entry.Attributes.Mtime > modificationTimeAgo { return nil } - if errDel := filer_pb.Remove(commandEnv, filer.SystemLogDir, entry.Name, true, true, true, false, nil); errDel != nil { + if errDel := filer_pb.Remove(context.Background(), commandEnv, filer.SystemLogDir, entry.Name, true, true, true, false, nil); errDel != nil { return errDel } if *verbose { diff --git a/weed/shell/command_fs_ls.go b/weed/shell/command_fs_ls.go index e007b4c9e..442702693 100644 --- a/weed/shell/command_fs_ls.go +++ b/weed/shell/command_fs_ls.go @@ -1,6 +1,7 @@ package shell import ( + "context" "fmt" "io" "os" @@ -66,7 +67,7 @@ func (c *commandFsLs) Do(args []string, commandEnv *CommandEnv, writer io.Writer dir, name := util.FullPath(path).DirAndName() entryCount := 0 - err = filer_pb.ReadDirAllEntries(commandEnv, util.FullPath(dir), name, func(entry *filer_pb.Entry, isLast bool) error { + err = filer_pb.ReadDirAllEntries(context.Background(), commandEnv, util.FullPath(dir), name, func(entry *filer_pb.Entry, isLast bool) error { if !showHidden && strings.HasPrefix(entry.Name, ".") { return nil diff --git a/weed/shell/command_fs_merge_volumes.go b/weed/shell/command_fs_merge_volumes.go index 31d9d6294..f31ec10f4 100644 --- a/weed/shell/command_fs_merge_volumes.go +++ b/weed/shell/command_fs_merge_volumes.go @@ -134,7 +134,7 @@ func (c *commandFsMergeVolumes) Do(args []string, commandEnv *CommandEnv, writer continue } - if err = filer_pb.UpdateEntry(filerClient, &filer_pb.UpdateEntryRequest{ + if err = filer_pb.UpdateEntry(context.Background(), filerClient, &filer_pb.UpdateEntryRequest{ Directory: string(parentPath), Entry: entry, }); err != nil { diff --git a/weed/shell/command_fs_meta_cat.go b/weed/shell/command_fs_meta_cat.go index e47d8faa6..2abb4d2b9 100644 --- a/weed/shell/command_fs_meta_cat.go +++ b/weed/shell/command_fs_meta_cat.go @@ -1,6 +1,7 @@ package shell import ( + "context" "fmt" "github.com/seaweedfs/seaweedfs/weed/filer" "google.golang.org/protobuf/proto" @@ -49,7 +50,7 @@ func (c *commandFsMetaCat) Do(args []string, commandEnv *CommandEnv, writer io.W Name: name, Directory: dir, } - respLookupEntry, err := filer_pb.LookupEntry(client, request) + respLookupEntry, err := filer_pb.LookupEntry(context.Background(), client, request) if err != nil { return err } diff --git a/weed/shell/command_fs_meta_change_volume_id.go b/weed/shell/command_fs_meta_change_volume_id.go index f1c148f5b..167d64288 100644 --- a/weed/shell/command_fs_meta_change_volume_id.go +++ b/weed/shell/command_fs_meta_change_volume_id.go @@ -1,6 +1,7 @@ package shell import ( + "context" "flag" "fmt" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" @@ -86,7 +87,7 @@ func (c *commandFsMetaChangeVolumeId) Do(args []string, commandEnv *CommandEnv, if hasChanges { println("Updating", parentPath, entry.Name) if *isForce { - if updateErr := filer_pb.UpdateEntry(client, &filer_pb.UpdateEntryRequest{ + if updateErr := filer_pb.UpdateEntry(context.Background(), client, &filer_pb.UpdateEntryRequest{ Directory: string(parentPath), Entry: entry, }); updateErr != nil { diff --git a/weed/shell/command_fs_meta_load.go b/weed/shell/command_fs_meta_load.go index d56274362..f43574f49 100644 --- a/weed/shell/command_fs_meta_load.go +++ b/weed/shell/command_fs_meta_load.go @@ -1,6 +1,7 @@ package shell import ( + "context" "flag" "fmt" "io" @@ -117,7 +118,7 @@ func (c *commandFsMetaLoad) Do(args []string, commandEnv *CommandEnv, writer io. fullEntry.Entry.Name = strings.ReplaceAll(fullEntry.Entry.Name, "/", "x") if fullEntry.Entry.IsDirectory { wg.Wait() - if errEntry := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{ + if errEntry := filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{ Directory: fullEntry.Dir, Entry: fullEntry.Entry, }); errEntry != nil { @@ -128,7 +129,7 @@ func (c *commandFsMetaLoad) Do(args []string, commandEnv *CommandEnv, writer io. wg.Add(1) waitChan <- struct{}{} go func(entry *filer_pb.FullEntry) { - if errEntry := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{ + if errEntry := filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{ Directory: entry.Dir, Entry: entry.Entry, }); errEntry != nil { diff --git a/weed/shell/command_fs_mv.go b/weed/shell/command_fs_mv.go index cb966571c..2d44e4b58 100644 --- a/weed/shell/command_fs_mv.go +++ b/weed/shell/command_fs_mv.go @@ -65,7 +65,7 @@ func (c *commandFsMv) Do(args []string, commandEnv *CommandEnv, writer io.Writer Name: destinationDir, Directory: destinationName, } - respDestinationLookupEntry, err := filer_pb.LookupEntry(client, destinationRequest) + respDestinationLookupEntry, err := filer_pb.LookupEntry(context.Background(), client, destinationRequest) var targetDir, targetName string diff --git a/weed/shell/command_fs_rm.go b/weed/shell/command_fs_rm.go index 0af75f048..2e3f19121 100644 --- a/weed/shell/command_fs_rm.go +++ b/weed/shell/command_fs_rm.go @@ -74,7 +74,7 @@ func (c *commandFsRm) Do(args []string, commandEnv *CommandEnv, writer io.Writer Directory: targetDir, Name: targetName, } - _, err = filer_pb.LookupEntry(client, lookupRequest) + _, err = filer_pb.LookupEntry(context.Background(), client, lookupRequest) if err != nil { fmt.Fprintf(writer, "rm: %s: %v\n", targetPath, err) continue diff --git a/weed/shell/command_fs_tree.go b/weed/shell/command_fs_tree.go index 21e352af2..628c95b30 100644 --- a/weed/shell/command_fs_tree.go +++ b/weed/shell/command_fs_tree.go @@ -1,6 +1,7 @@ package shell import ( + "context" "fmt" "io" "strings" @@ -55,7 +56,7 @@ func treeTraverseDirectory(writer io.Writer, filerClient filer_pb.FilerClient, d prefix.addMarker(level) - err = filer_pb.ReadDirAllEntries(filerClient, dir, name, func(entry *filer_pb.Entry, isLast bool) error { + err = filer_pb.ReadDirAllEntries(context.Background(), filerClient, dir, name, func(entry *filer_pb.Entry, isLast bool) error { if level < 0 && name != "" { if entry.Name != name { return nil diff --git a/weed/shell/command_remote_cache.go b/weed/shell/command_remote_cache.go index da19af0cf..987502c14 100644 --- a/weed/shell/command_remote_cache.go +++ b/weed/shell/command_remote_cache.go @@ -1,6 +1,7 @@ package shell import ( + "context" "flag" "fmt" "github.com/seaweedfs/seaweedfs/weed/filer" @@ -100,7 +101,7 @@ func (c *commandRemoteCache) doCacheOneDirectory(commandEnv *CommandEnv, writer func recursivelyTraverseDirectory(filerClient filer_pb.FilerClient, dirPath util.FullPath, visitEntry func(dir util.FullPath, entry *filer_pb.Entry) bool) (err error) { - err = filer_pb.ReadDirAllEntries(filerClient, dirPath, "", func(entry *filer_pb.Entry, isLast bool) error { + err = filer_pb.ReadDirAllEntries(context.Background(), filerClient, dirPath, "", func(entry *filer_pb.Entry, isLast bool) error { if entry.IsDirectory { if !visitEntry(dirPath, entry) { return nil diff --git a/weed/shell/command_remote_configure.go b/weed/shell/command_remote_configure.go index dbc44c8bf..aa2f3d1d4 100644 --- a/weed/shell/command_remote_configure.go +++ b/weed/shell/command_remote_configure.go @@ -141,7 +141,7 @@ func (c *commandRemoteConfigure) Do(args []string, commandEnv *CommandEnv, write func (c *commandRemoteConfigure) listExistingRemoteStorages(commandEnv *CommandEnv, writer io.Writer) error { - return filer_pb.ReadDirAllEntries(commandEnv, util.FullPath(filer.DirectoryEtcRemote), "", func(entry *filer_pb.Entry, isLast bool) error { + return filer_pb.ReadDirAllEntries(context.Background(), commandEnv, util.FullPath(filer.DirectoryEtcRemote), "", func(entry *filer_pb.Entry, isLast bool) error { if len(entry.Content) == 0 { fmt.Fprintf(writer, "skipping %s\n", entry.Name) return nil diff --git a/weed/shell/command_remote_meta_sync.go b/weed/shell/command_remote_meta_sync.go index 1b2e33c14..4d430bc76 100644 --- a/weed/shell/command_remote_meta_sync.go +++ b/weed/shell/command_remote_meta_sync.go @@ -136,7 +136,7 @@ func pullMetadata(commandEnv *CommandEnv, writer io.Writer, localMountedDir util localDir := filer.MapRemoteStorageLocationPathToFullPath(localMountedDir, remoteMountedLocation, remoteDir) fmt.Fprint(writer, localDir.Child(name)) - lookupResponse, lookupErr := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{ + lookupResponse, lookupErr := filer_pb.LookupEntry(context.Background(), client, &filer_pb.LookupDirectoryEntryRequest{ Directory: string(localDir), Name: name, }) diff --git a/weed/shell/command_remote_mount.go b/weed/shell/command_remote_mount.go index cfe89ddce..2892852e9 100644 --- a/weed/shell/command_remote_mount.go +++ b/weed/shell/command_remote_mount.go @@ -138,7 +138,7 @@ func syncMetadata(commandEnv *CommandEnv, writer io.Writer, dir string, nonEmpty } mountToDirIsEmpty := true - listErr := filer_pb.SeaweedList(client, dir, "", func(entry *filer_pb.Entry, isLast bool) error { + listErr := filer_pb.SeaweedList(context.Background(), client, dir, "", func(entry *filer_pb.Entry, isLast bool) error { mountToDirIsEmpty = false return nil }, "", false, 1) diff --git a/weed/shell/command_remote_unmount.go b/weed/shell/command_remote_unmount.go index 6de92e612..87487481a 100644 --- a/weed/shell/command_remote_unmount.go +++ b/weed/shell/command_remote_unmount.go @@ -88,6 +88,7 @@ func (c *commandRemoteUnmount) purgeMountedData(commandEnv *CommandEnv, dir stri // find existing directory, and ensure the directory is empty err := commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { + ctx := context.Background() parent, name := util.FullPath(dir).DirAndName() lookupResp, lookupErr := client.LookupDirectoryEntry(context.Background(), &filer_pb.LookupDirectoryEntryRequest{ Directory: parent, @@ -99,12 +100,12 @@ func (c *commandRemoteUnmount) purgeMountedData(commandEnv *CommandEnv, dir stri oldEntry := lookupResp.Entry - deleteError := filer_pb.DoRemove(client, parent, name, true, true, true, false, nil) + deleteError := filer_pb.DoRemove(ctx, client, parent, name, true, true, true, false, nil) if deleteError != nil { return fmt.Errorf("delete %s: %v", dir, deleteError) } - mkdirErr := filer_pb.DoMkdir(client, parent, name, func(entry *filer_pb.Entry) { + mkdirErr := filer_pb.DoMkdir(ctx, client, parent, name, func(entry *filer_pb.Entry) { entry.Attributes = oldEntry.Attributes entry.Extended = oldEntry.Extended entry.Attributes.Crtime = time.Now().Unix() diff --git a/weed/shell/command_s3_bucket_create.go b/weed/shell/command_s3_bucket_create.go index 86c788b0d..be17591e4 100644 --- a/weed/shell/command_s3_bucket_create.go +++ b/weed/shell/command_s3_bucket_create.go @@ -71,7 +71,7 @@ func (c *commandS3BucketCreate) Do(args []string, commandEnv *CommandEnv, writer }, } - if err := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{ + if err := filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{ Directory: filerBucketsPath, Entry: entry, }); err != nil { diff --git a/weed/shell/command_s3_bucket_delete.go b/weed/shell/command_s3_bucket_delete.go index 6f8c9c4b5..ecd83d1c2 100644 --- a/weed/shell/command_s3_bucket_delete.go +++ b/weed/shell/command_s3_bucket_delete.go @@ -66,6 +66,6 @@ func (c *commandS3BucketDelete) Do(args []string, commandEnv *CommandEnv, writer return } - return filer_pb.Remove(commandEnv, filerBucketsPath, *bucketName, false, true, true, false, nil) + return filer_pb.Remove(context.Background(), commandEnv, filerBucketsPath, *bucketName, false, true, true, false, nil) } diff --git a/weed/shell/command_s3_bucket_list.go b/weed/shell/command_s3_bucket_list.go index 7939f2086..e6fa44303 100644 --- a/weed/shell/command_s3_bucket_list.go +++ b/weed/shell/command_s3_bucket_list.go @@ -57,7 +57,7 @@ func (c *commandS3BucketList) Do(args []string, commandEnv *CommandEnv, writer i return fmt.Errorf("read buckets: %v", err) } - err = filer_pb.List(commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error { + err = filer_pb.List(context.Background(), commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error { if !entry.IsDirectory { return nil } diff --git a/weed/shell/command_s3_bucket_quota.go b/weed/shell/command_s3_bucket_quota.go index 3301a8d0e..f6562453f 100644 --- a/weed/shell/command_s3_bucket_quota.go +++ b/weed/shell/command_s3_bucket_quota.go @@ -83,7 +83,7 @@ func (c *commandS3BucketQuota) Do(args []string, commandEnv *CommandEnv, writer } } - if err := filer_pb.UpdateEntry(client, &filer_pb.UpdateEntryRequest{ + if err := filer_pb.UpdateEntry(context.Background(), client, &filer_pb.UpdateEntryRequest{ Directory: filerBucketsPath, Entry: bucketEntry, }); err != nil { diff --git a/weed/shell/command_s3_bucket_quota_check.go b/weed/shell/command_s3_bucket_quota_check.go index 04708a0e7..27b903405 100644 --- a/weed/shell/command_s3_bucket_quota_check.go +++ b/weed/shell/command_s3_bucket_quota_check.go @@ -2,6 +2,7 @@ package shell import ( "bytes" + "context" "flag" "fmt" "github.com/seaweedfs/seaweedfs/weed/filer" @@ -65,7 +66,7 @@ func (c *commandS3BucketQuotaEnforce) Do(args []string, commandEnv *CommandEnv, // process each bucket hasConfChanges := false - err = filer_pb.List(commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error { + err = filer_pb.List(context.Background(), commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error { if !entry.IsDirectory { return nil } diff --git a/weed/shell/command_s3_clean_uploads.go b/weed/shell/command_s3_clean_uploads.go index bfce5d54d..c77f3cd74 100644 --- a/weed/shell/command_s3_clean_uploads.go +++ b/weed/shell/command_s3_clean_uploads.go @@ -1,6 +1,7 @@ package shell import ( + "context" "flag" "fmt" "io" @@ -54,7 +55,7 @@ func (c *commandS3CleanUploads) Do(args []string, commandEnv *CommandEnv, writer } var buckets []string - err = filer_pb.List(commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error { + err = filer_pb.List(context.Background(), commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error { buckets = append(buckets, entry.Name) return nil }, "", false, math.MaxUint32) @@ -75,7 +76,7 @@ func (c *commandS3CleanUploads) cleanupUploads(commandEnv *CommandEnv, writer io uploadsDir := filerBucketsPath + "/" + bucket + "/" + s3_constants.MultipartUploadsFolder var staleUploads []string now := time.Now() - err := filer_pb.List(commandEnv, uploadsDir, "", func(entry *filer_pb.Entry, isLast bool) error { + err := filer_pb.List(context.Background(), commandEnv, uploadsDir, "", func(entry *filer_pb.Entry, isLast bool) error { ctime := time.Unix(entry.Attributes.Crtime, 0) if ctime.Add(timeAgo).Before(now) { staleUploads = append(staleUploads, entry.Name) diff --git a/weed/shell/commands.go b/weed/shell/commands.go index 264dd4818..40be210a2 100644 --- a/weed/shell/commands.go +++ b/weed/shell/commands.go @@ -91,7 +91,7 @@ func (ce *CommandEnv) checkDirectory(path string) error { dir, name := util.FullPath(path).DirAndName() - exists, err := filer_pb.Exists(ce, dir, name, true) + exists, err := filer_pb.Exists(context.Background(), ce, dir, name, true) if !exists { return fmt.Errorf("%s is not a directory", path) |
