From 4be265208536cc8cd4f6eb7be934b1bc96f07969 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Fri, 4 Mar 2022 23:21:30 +0000 Subject: [PATCH] conformance: fix cross-mount behavior when 'from' is missing fixes issue #442 Signed-off-by: Ramkumar Chinchani --- pkg/api/controller_test.go | 4 ++-- pkg/api/routes.go | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index 08cd4be1..5d870203 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -2665,7 +2665,7 @@ func TestCrossRepoMount(t *testing.T) { SetBasicAuth(username, passphrase).SetQueryParams(params). Post(baseURL + "/v2/zot-mount-test/blobs/uploads/") So(err, ShouldBeNil) - So(postResponse.StatusCode(), ShouldEqual, http.StatusMethodNotAllowed) + So(postResponse.StatusCode(), ShouldEqual, http.StatusAccepted) params = make(map[string]string) params["from"] = "zot-cve-test" @@ -3902,7 +3902,7 @@ func TestRouteFailures(t *testing.T) { resp = response.Result() defer resp.Body.Close() So(resp, ShouldNotBeNil) - So(resp.StatusCode, ShouldEqual, http.StatusMethodNotAllowed) + So(resp.StatusCode, ShouldEqual, http.StatusAccepted) }) Convey("Get blob upload", func() { diff --git a/pkg/api/routes.go b/pkg/api/routes.go index 9dcdd5a2..cc2ee998 100644 --- a/pkg/api/routes.go +++ b/pkg/api/routes.go @@ -716,13 +716,6 @@ func (rh *RouteHandler) CreateBlobUpload(response http.ResponseWriter, request * return } - from, ok := request.URL.Query()["from"] - if !ok || len(from) != 1 { - response.WriteHeader(http.StatusMethodNotAllowed) - - return - } - // zot does not support cross mounting directly and do a workaround creating using hard link. // check blob looks for actual path (name+mountDigests[0]) first then look for cache and // if found in cache, will do hard link and if fails we will start new upload.