convert error fromating to %w everywhere (#6995)
This commit is contained in:
@@ -186,7 +186,7 @@ func startAdminServer(ctx context.Context, options AdminOptions) error {
|
||||
sessionKeyBytes := make([]byte, 32)
|
||||
_, err := rand.Read(sessionKeyBytes)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to generate session key: %v", err)
|
||||
return fmt.Errorf("failed to generate session key: %w", err)
|
||||
}
|
||||
store := cookie.NewStore(sessionKeyBytes)
|
||||
r.Use(sessions.Sessions("admin-session", store))
|
||||
@@ -234,7 +234,7 @@ func startAdminServer(ctx context.Context, options AdminOptions) error {
|
||||
// Start worker gRPC server for worker connections
|
||||
err = adminServer.StartWorkerGrpcServer(*options.port)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to start worker gRPC server: %v", err)
|
||||
return fmt.Errorf("failed to start worker gRPC server: %w", err)
|
||||
}
|
||||
|
||||
// Set up cleanup for gRPC server
|
||||
@@ -304,7 +304,7 @@ func startAdminServer(ctx context.Context, options AdminOptions) error {
|
||||
defer cancel()
|
||||
|
||||
if err := server.Shutdown(shutdownCtx); err != nil {
|
||||
return fmt.Errorf("admin server forced to shutdown: %v", err)
|
||||
return fmt.Errorf("admin server forced to shutdown: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -328,7 +328,7 @@ func expandHomeDir(path string) (string, error) {
|
||||
// Get current user
|
||||
currentUser, err := user.Current()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get current user: %v", err)
|
||||
return "", fmt.Errorf("failed to get current user: %w", err)
|
||||
}
|
||||
|
||||
// Handle different tilde patterns
|
||||
|
||||
@@ -268,7 +268,7 @@ func (worker *FileCopyWorker) doEachCopy(task FileCopyTask) error {
|
||||
}
|
||||
|
||||
if shouldCopy, err := worker.checkExistingFileFirst(task, f); err != nil {
|
||||
return fmt.Errorf("check existing file: %v", err)
|
||||
return fmt.Errorf("check existing file: %w", err)
|
||||
} else if !shouldCopy {
|
||||
if *worker.options.verbose {
|
||||
fmt.Printf("skipping copied file: %v\n", f.Name())
|
||||
@@ -395,7 +395,7 @@ func (worker *FileCopyWorker) uploadFileAsOne(task FileCopyTask, f *os.File) err
|
||||
}
|
||||
|
||||
if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {
|
||||
return fmt.Errorf("update fh: %v", err)
|
||||
return fmt.Errorf("update fh: %w", err)
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
@@ -428,7 +428,7 @@ func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File,
|
||||
|
||||
uploader, err := operation.NewUploader()
|
||||
if err != nil {
|
||||
uploadError = fmt.Errorf("upload data %v: %v\n", fileName, err)
|
||||
uploadError = fmt.Errorf("upload data %v: %w\n", fileName, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
uploadError = fmt.Errorf("upload data %v: %v\n", fileName, err)
|
||||
uploadError = fmt.Errorf("upload data %v: %w\n", fileName, err)
|
||||
return
|
||||
}
|
||||
if uploadResult.Error != "" {
|
||||
@@ -489,7 +489,7 @@ func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File,
|
||||
|
||||
manifestedChunks, manifestErr := filer.MaybeManifestize(worker.saveDataAsChunk, chunks)
|
||||
if manifestErr != nil {
|
||||
return fmt.Errorf("create manifest: %v", manifestErr)
|
||||
return fmt.Errorf("create manifest: %w", manifestErr)
|
||||
}
|
||||
|
||||
if err := pb.WithGrpcFilerClient(false, worker.signature, worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||
@@ -512,7 +512,7 @@ func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File,
|
||||
}
|
||||
|
||||
if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {
|
||||
return fmt.Errorf("update fh: %v", err)
|
||||
return fmt.Errorf("update fh: %w", err)
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
@@ -546,7 +546,7 @@ func detectMimeType(f *os.File) string {
|
||||
func (worker *FileCopyWorker) saveDataAsChunk(reader io.Reader, name string, offset int64, tsNs int64) (chunk *filer_pb.FileChunk, err error) {
|
||||
uploader, uploaderErr := operation.NewUploader()
|
||||
if uploaderErr != nil {
|
||||
return nil, fmt.Errorf("upload data: %v", uploaderErr)
|
||||
return nil, fmt.Errorf("upload data: %w", uploaderErr)
|
||||
}
|
||||
|
||||
finalFileId, uploadResult, flushErr, _ := uploader.UploadWithRetry(
|
||||
@@ -573,7 +573,7 @@ func (worker *FileCopyWorker) saveDataAsChunk(reader io.Reader, name string, off
|
||||
)
|
||||
|
||||
if flushErr != nil {
|
||||
return nil, fmt.Errorf("upload data: %v", flushErr)
|
||||
return nil, fmt.Errorf("upload data: %w", flushErr)
|
||||
}
|
||||
if uploadResult.Error != "" {
|
||||
return nil, fmt.Errorf("upload result: %v", uploadResult.Error)
|
||||
|
||||
@@ -133,14 +133,14 @@ func (metaBackup *FilerMetaBackupOptions) traverseMetadata() (err error) {
|
||||
|
||||
println("+", parentPath.Child(entry.Name))
|
||||
if err := metaBackup.store.InsertEntry(context.Background(), filer.FromPbEntry(string(parentPath), entry)); err != nil {
|
||||
saveErr = fmt.Errorf("insert entry error: %v\n", err)
|
||||
saveErr = fmt.Errorf("insert entry error: %w\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
if traverseErr != nil {
|
||||
return fmt.Errorf("traverse: %v", traverseErr)
|
||||
return fmt.Errorf("traverse: %w", traverseErr)
|
||||
}
|
||||
return saveErr
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func (option *RemoteGatewayOptions) followBucketUpdatesAndUploadToRemote(filerSo
|
||||
|
||||
// read filer remote storage mount mappings
|
||||
if detectErr := option.collectRemoteStorageConf(); detectErr != nil {
|
||||
return fmt.Errorf("read mount info: %v", detectErr)
|
||||
return fmt.Errorf("read mount info: %w", detectErr)
|
||||
}
|
||||
|
||||
eachEntryFunc, err := option.makeBucketedEventProcessor(filerSource)
|
||||
@@ -168,7 +168,7 @@ func (option *RemoteGatewayOptions) makeBucketedEventProcessor(filerSource *sour
|
||||
if message.NewEntry.Name == filer.REMOTE_STORAGE_MOUNT_FILE {
|
||||
newMappings, readErr := filer.UnmarshalRemoteStorageMappings(message.NewEntry.Content)
|
||||
if readErr != nil {
|
||||
return fmt.Errorf("unmarshal mappings: %v", readErr)
|
||||
return fmt.Errorf("unmarshal mappings: %w", readErr)
|
||||
}
|
||||
option.mappings = newMappings
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func followUpdatesAndUploadToRemote(option *RemoteSyncOptions, filerSource *sour
|
||||
// read filer remote storage mount mappings
|
||||
_, _, remoteStorageMountLocation, remoteStorage, detectErr := filer.DetectMountInfo(option.grpcDialOption, pb.ServerAddress(*option.filerAddress), mountedDir)
|
||||
if detectErr != nil {
|
||||
return fmt.Errorf("read mount info: %v", detectErr)
|
||||
return fmt.Errorf("read mount info: %w", detectErr)
|
||||
}
|
||||
|
||||
eachEntryFunc, err := option.makeEventProcessor(remoteStorage, mountedDir, remoteStorageMountLocation, filerSource)
|
||||
@@ -99,7 +99,7 @@ func (option *RemoteSyncOptions) makeEventProcessor(remoteStorage *remote_pb.Rem
|
||||
if message.NewEntry.Name == filer.REMOTE_STORAGE_MOUNT_FILE {
|
||||
mappings, readErr := filer.UnmarshalRemoteStorageMappings(message.NewEntry.Content)
|
||||
if readErr != nil {
|
||||
return fmt.Errorf("unmarshal mappings: %v", readErr)
|
||||
return fmt.Errorf("unmarshal mappings: %w", readErr)
|
||||
}
|
||||
if remoteLoc, found := mappings.Mappings[mountedDir]; found {
|
||||
if remoteStorageMountLocation.Bucket != remoteLoc.Bucket || remoteStorageMountLocation.Path != remoteLoc.Path {
|
||||
|
||||
@@ -170,7 +170,7 @@ func doFixOneVolume(basepath string, baseFileName string, collection string, vol
|
||||
}
|
||||
|
||||
if err := storage.ScanVolumeFile(basepath, collection, vid, storage.NeedleMapInMemory, scanner); err != nil {
|
||||
err := fmt.Errorf("scan .dat File: %v", err)
|
||||
err := fmt.Errorf("scan .dat File: %w", err)
|
||||
if *fixIgnoreError {
|
||||
glog.Error(err)
|
||||
} else {
|
||||
@@ -179,7 +179,7 @@ func doFixOneVolume(basepath string, baseFileName string, collection string, vol
|
||||
}
|
||||
|
||||
if err := SaveToIdx(scanner, indexFileName); err != nil {
|
||||
err := fmt.Errorf("save to .idx File: %v", err)
|
||||
err := fmt.Errorf("save to .idx File: %w", err)
|
||||
if *fixIgnoreError {
|
||||
glog.Error(err)
|
||||
} else {
|
||||
|
||||
@@ -92,7 +92,7 @@ func startMasterFollower(masterOptions MasterOptions) {
|
||||
err = pb.WithOneOfGrpcMasterClients(false, masters, grpcDialOption, func(client master_pb.SeaweedClient) error {
|
||||
resp, err := client.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("get master grpc address %v configuration: %v", masters, err)
|
||||
return fmt.Errorf("get master grpc address %v configuration: %w", masters, err)
|
||||
}
|
||||
masterOptions.defaultReplication = &resp.DefaultReplication
|
||||
masterOptions.volumeSizeLimitMB = aws.Uint(uint(resp.VolumeSizeLimitMB))
|
||||
|
||||
@@ -78,7 +78,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||
err = pb.WithOneOfGrpcFilerClients(false, filerAddresses, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("get filer grpc address %v configuration: %v", filerAddresses, err)
|
||||
return fmt.Errorf("get filer grpc address %v configuration: %w", filerAddresses, err)
|
||||
}
|
||||
cipher = resp.Cipher
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user