From 0c1145c20a00b515786b8d73a9cbe0396a82c678 Mon Sep 17 00:00:00 2001 From: Jayash Satolia Date: Mon, 2 Sep 2024 01:09:51 +0530 Subject: [PATCH 1/2] Log blobber --- code/go/0chain.net/blobbercore/handler/file_command_update.go | 2 +- code/go/0chain.net/blobbercore/handler/file_command_upload.go | 2 +- .../0chain.net/blobbercore/handler/object_operation_handler.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/go/0chain.net/blobbercore/handler/file_command_update.go b/code/go/0chain.net/blobbercore/handler/file_command_update.go index 1b1daf5d4..33a9914e0 100644 --- a/code/go/0chain.net/blobbercore/handler/file_command_update.go +++ b/code/go/0chain.net/blobbercore/handler/file_command_update.go @@ -171,7 +171,7 @@ func (cmd *UpdateFileCommand) ProcessContent(ctx context.Context, allocationObj } if allocationObj.BlobberSizeUsed+allocationSize > allocationObj.BlobberSize { - return result, common.NewError("max_allocation_size", "Max size reached for the allocation with this blobber") + return result, common.NewError("max_allocation_size", fmt.Sprintf("Max size reached for the allocation with this blobber : %d < %d", allocationObj.BlobberSize, allocationObj.BlobberSizeUsed+allocationSize)) } return result, nil diff --git a/code/go/0chain.net/blobbercore/handler/file_command_upload.go b/code/go/0chain.net/blobbercore/handler/file_command_upload.go index 88fea77f9..d7b5a78d6 100644 --- a/code/go/0chain.net/blobbercore/handler/file_command_upload.go +++ b/code/go/0chain.net/blobbercore/handler/file_command_upload.go @@ -187,7 +187,7 @@ func (cmd *UploadFileCommand) ProcessContent(ctx context.Context, allocationObj } if allocationObj.BlobberSizeUsed+allocationSize > allocationObj.BlobberSize { - return result, common.NewError("max_allocation_size", "Max size reached for the allocation with this blobber") + return result, common.NewError("max_allocation_size", fmt.Sprintf("Max size reached for the allocation with this blobber : %d < %d", allocationObj.BlobberSize, allocationObj.BlobberSizeUsed+allocationSize)) } return result, nil diff --git a/code/go/0chain.net/blobbercore/handler/object_operation_handler.go b/code/go/0chain.net/blobbercore/handler/object_operation_handler.go index 968eaa2a1..1c722f555 100644 --- a/code/go/0chain.net/blobbercore/handler/object_operation_handler.go +++ b/code/go/0chain.net/blobbercore/handler/object_operation_handler.go @@ -756,7 +756,7 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*b if allocationObj.BlobberSizeUsed+connectionObj.Size > allocationObj.BlobberSize { return nil, common.NewError("max_allocation_size", - "Max size reached for the allocation with this blobber") + fmt.Sprintf("Max size reached for the allocation with this blobber : %d < %d", allocationObj.BlobberSize, allocationObj.BlobberSizeUsed+connectionObj.Size)) } if latestWriteMarkerEntity != nil && latestWriteMarkerEntity.WM.ChainSize+connectionObj.Size != writeMarker.ChainSize { From 00b382acc290b9db4be761e7059f71148416d74b Mon Sep 17 00:00:00 2001 From: Jayash Satolia Date: Wed, 4 Sep 2024 21:46:55 +0530 Subject: [PATCH 2/2] Debug --- .../blobbercore/handler/file_command_delete.go | 3 ++- .../blobbercore/handler/file_command_update.go | 2 +- .../blobbercore/handler/file_command_upload.go | 2 +- .../blobbercore/handler/object_operation_handler.go | 10 +++++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/code/go/0chain.net/blobbercore/handler/file_command_delete.go b/code/go/0chain.net/blobbercore/handler/file_command_delete.go index 38497b283..8c9a3eb10 100644 --- a/code/go/0chain.net/blobbercore/handler/file_command_delete.go +++ b/code/go/0chain.net/blobbercore/handler/file_command_delete.go @@ -3,6 +3,7 @@ package handler import ( "context" "errors" + "fmt" "net/http" "github.com/0chain/gosdk/constants" @@ -33,7 +34,7 @@ func (cmd *DeleteFileCommand) GetPath() string { // IsValidated validate request. func (cmd *DeleteFileCommand) IsValidated(ctx context.Context, req *http.Request, allocationObj *allocation.Allocation, clientID string) error { if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID { - return common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } path, ok := common.GetField(req, "path") diff --git a/code/go/0chain.net/blobbercore/handler/file_command_update.go b/code/go/0chain.net/blobbercore/handler/file_command_update.go index 33a9914e0..684324cc4 100644 --- a/code/go/0chain.net/blobbercore/handler/file_command_update.go +++ b/code/go/0chain.net/blobbercore/handler/file_command_update.go @@ -47,7 +47,7 @@ func (cmd *UpdateFileCommand) GetPath() string { // IsValidated validate request. func (cmd *UpdateFileCommand) IsValidated(ctx context.Context, req *http.Request, allocationObj *allocation.Allocation, clientID string) error { if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID { - return common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } uploadMetaString := req.FormValue(UploadMeta) diff --git a/code/go/0chain.net/blobbercore/handler/file_command_upload.go b/code/go/0chain.net/blobbercore/handler/file_command_upload.go index d7b5a78d6..e2eaa641f 100644 --- a/code/go/0chain.net/blobbercore/handler/file_command_upload.go +++ b/code/go/0chain.net/blobbercore/handler/file_command_upload.go @@ -53,7 +53,7 @@ func (cmd *UploadFileCommand) GetPath() string { // IsValidated validate request. func (cmd *UploadFileCommand) IsValidated(ctx context.Context, req *http.Request, allocationObj *allocation.Allocation, clientID string) error { if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID { - return common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } fileChanger := &allocation.UploadFileChanger{} diff --git a/code/go/0chain.net/blobbercore/handler/object_operation_handler.go b/code/go/0chain.net/blobbercore/handler/object_operation_handler.go index 1c722f555..46be1c1fc 100644 --- a/code/go/0chain.net/blobbercore/handler/object_operation_handler.go +++ b/code/go/0chain.net/blobbercore/handler/object_operation_handler.go @@ -558,7 +558,7 @@ func (fsh *StorageHandler) CreateConnection(ctx context.Context, r *http.Request } if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID { - return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return nil, common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } valid, err := verifySignatureFromRequest(allocationTx, r.Header.Get(common.ClientSignatureHeader), r.Header.Get(common.ClientSignatureHeaderV2), allocationObj.OwnerPublicKey) @@ -1245,7 +1245,7 @@ func (fsh *StorageHandler) CreateDir(ctx context.Context, r *http.Request) (*all allocationID := allocationObj.ID if clientID == "" { - return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return nil, common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } dirPath := r.FormValue("dir_path") @@ -1288,7 +1288,7 @@ func (fsh *StorageHandler) CreateDir(ctx context.Context, r *http.Request) (*all } if clientID != allocationObj.OwnerID { - return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return nil, common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } if err := validateParentPathType(ctx, allocationID, dirPath); err != nil { @@ -1341,7 +1341,7 @@ func (fsh *StorageHandler) WriteFile(ctx context.Context, r *http.Request) (*all return nil, common.NewError("invalid_parameters", "Invalid connection id passed") } if clientID == "" { - return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return nil, common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationID, clientID)) } if ok := CheckBlacklist(clientID); ok { return nil, common.NewError("blacklisted_client", "Client is blacklisted: "+clientID) @@ -1361,7 +1361,7 @@ func (fsh *StorageHandler) WriteFile(ctx context.Context, r *http.Request) (*all } if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID { - return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return nil, common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } elapsedAllocation := time.Since(st)