From 5e919129e2896acbdc4e4a18965754bc6567915d Mon Sep 17 00:00:00 2001 From: guyhardonag Date: Tue, 10 Oct 2023 17:01:03 +0300 Subject: [PATCH] Fix link physical address response to contain full path --- esti/lakectl_test.go | 2 +- pkg/api/controller.go | 6 ++++-- pkg/api/helpers/upload.go | 5 +---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/esti/lakectl_test.go b/esti/lakectl_test.go index 4f7707240ab..9119a33615c 100644 --- a/esti/lakectl_test.go +++ b/esti/lakectl_test.go @@ -111,7 +111,7 @@ func TestLakectlPreSignUpload(t *testing.T) { filePath := "ro_1k.1" vars["FILE_PATH"] = filePath - RunCmdAndVerifySuccessWithFile(t, Lakectl()+" fs upload -s files/ro_1k lakefs://"+repoName+"/"+mainBranch+"/"+filePath+" --pre-sign", false, "lakectl_fs_upload_pre_signed", vars) + RunCmdAndVerifySuccessWithFile(t, Lakectl()+" fs upload -s files/ro_1k lakefs://"+repoName+"/"+mainBranch+"/"+filePath+" --pre-sign", false, "lakectl_fs_upload", vars) } func TestLakectlCommit(t *testing.T) { diff --git a/pkg/api/controller.go b/pkg/api/controller.go index 144087dfd3f..d523363d11f 100644 --- a/pkg/api/controller.go +++ b/pkg/api/controller.go @@ -358,7 +358,9 @@ func (c *Controller) LinkPhysicalAddress(w http.ResponseWriter, r *http.Request, } writeTime := time.Now() - physicalAddress, addressType := normalizePhysicalAddress(repo.StorageNamespace, swag.StringValue(body.Staging.PhysicalAddress)) + fullPhysicalAddress := swag.StringValue(body.Staging.PhysicalAddress) + physicalAddress, addressType := normalizePhysicalAddress(repo.StorageNamespace, fullPhysicalAddress) + if addressType == catalog.AddressTypeRelative { // if the address is in the storage namespace, verify it has been saved for linking err = c.Catalog.VerifyLinkAddress(ctx, repository, physicalAddress) @@ -403,7 +405,7 @@ func (c *Controller) LinkPhysicalAddress(w http.ResponseWriter, r *http.Request, Mtime: entry.CreationDate.Unix(), Path: entry.Path, PathType: entryTypeObject, - PhysicalAddress: entry.PhysicalAddress, + PhysicalAddress: fullPhysicalAddress, SizeBytes: swag.Int64(entry.Size), } diff --git a/pkg/api/helpers/upload.go b/pkg/api/helpers/upload.go index db4f572bbab..94070d6a7d9 100644 --- a/pkg/api/helpers/upload.go +++ b/pkg/api/helpers/upload.go @@ -178,10 +178,7 @@ func clientUploadPreSignHelper(ctx context.Context, client apigen.ClientWithResp return nil, fmt.Errorf("link object to backing store: %w", err) } if linkResp.JSON200 != nil { - objStat := *linkResp.JSON200 - // this is a workaround for the fact that the API does not return the full physical address - objStat.PhysicalAddress = preSignURL - return &objStat, nil + return linkResp.JSON200, nil } if linkResp.JSON409 != nil { return nil, ErrConflict