anydistro / bxt

Next generation repository maintenance tool (WIP)
GNU Affero General Public License v3.0
0 stars 4 forks source link

Move request reports 200, but package not moved #84

Open romangg opened 2 months ago

romangg commented 2 months ago

I tested the move request and expected the package uploaded to multilib to be moved to extra.

Am I misunderstanding your example ?

When uploading a package one need six form parts

When sending a move an element to_move is required, containing a json object array consisting of at least one named element with source and destination

Trying to move the package from above upload (arch-install-scripts)

upload_form : 
{('to_move',
  '[{"name": "arch-install-scripts-28-1-any.pkg.tar.zst", "from_section": '
  '{"branch": "stable", "repository": "multilib", "architecture": "x86_64"}, '
  '"to_section": {"branch": "stable", "repository": "extra", "architecture": '
  '"x86_64"}}]')}
request begin -->  2024-07-07 07:28:31
response recv -->  2024-07-07 07:28:31
          headers  {'Alt-Svc': 'h3=":443"; ma=2592000', 'Content-Length': '15', 'Content-Type': 'application/json; charset=utf-8', 'Date': 'Sun, 07 Jul 2024 05:28:31 GMT', 'Server': 'Caddy, drogon/1.8.2'}
          status   200

returns 200 but the package doesn't move.

Originally posted by @fhdk in https://github.com/anydistro/bxt/issues/80#issuecomment-2212328327

fhdk commented 2 months ago

I have created some simple tests in the bxtctl repo https://github.com/fhdk/bxtctl

fhdk commented 2 months ago

updated tests/20_pkg_move.py

Response is OK but nothing happens on the endpoint - from the output from test script - the request should go through

Corrected for permission for the bxtctl user

bxt_move_pkg : 
req headers : {'Authorization': 'Bearer *****', 'Accept': 'application/json', 'Content-Type': 'multipart/form-data', 'Content-Length': '341'}
req url     : https://bxt.staging.manjaro.org/api/packages/commit
req data    : b'--5e33262c1fbe4bffcc3a5081e7863730\r\nContent-Disposition: form-data; name="to_move"\r\n\r\n[{"name": "arch-install-scripts", "from_section": {"branch": "unstable", "repository": "multilib", "architecture": "x86_64"}, "to_section": {"branch": "testing", "repository": "multilib", "architecture": "x86_64"}}]\r\n--5e33262c1fbe4bffcc3a5081e7863730--\r\n': 
move request begin -->  2024-07-19 09:40:10
response recv -->  2024-07-19 09:40:10
      headers -->  {'Alt-Svc': 'h3=":443"; ma=2592000', 'Content-Length': '15', 'Content-Type': 'application/json; charset=utf-8', 'Date': 'Fri, 19 Jul 2024 07:40:10 GMT', 'Server': 'Caddy, drogon/1.8.2'}
       status -->  200
fhdk commented 2 weeks ago

Just a followup - move a package - service responds with OK - but nothing happens.

POST /api/packages/commit HTTP/1.1
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJleHAiOjE3MjUyODE5OTAsImlhdCI6MTcyNTI4MTA5MCwiaXNzIjoiYnh0Iiwia2luZCI6ImFjY2Vzc190b2tlbiIsInN0b3JhZ2UiOiJiZWFyZXIiLCJ1c2VybmFtZSI6ImJ4dGN0bCJ9.ODR59J2sqveWUlZOZW2wtBdyY1P_BesC5h0yGCu28D4
User-Agent: PostmanRuntime/7.38.0
Accept: */*
Postman-Token: 9e9c3830-c1b5-4966-9dbd-b237145196f1
Host: bxt.staging.manjaro.org
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------------------------907285369569507472035194
Content-Length: 379

----------------------------907285369569507472035194
Content-Disposition: form-data; name="to_move"
Content-Type: application/json
[{"name": "a-dummy1", "from_section":{"branch":"testing","repository":"extra","architecture":"x86_64"}, "to_section":{"branch":"testing","repository":"extra","architecture":"aarch64"}}]
----------------------------907285369569507472035194--

HTTP/1.1 200 OK
Alt-Svc: h3=":443"; ma=2592000
Content-Length: 15
Content-Type: application/json; charset=utf-8
Date: Mon, 02 Sep 2024 12:50:14 GMT
Server: Caddy
Server: drogon/1.8.2

{"status":"ok"}
fhdk commented 2 weeks ago

Tested today - the move transaction request is accepted with 200 OK - but no packages are moved

bxt_move_pkg  : BearerAuth
req headers   : {'User-Agent': 'bxtctl/0.6alpha', 'Authorization': 'Bearer eyJhbGciOiJIUzI...UDGnV02_CJ060bM', 'x-bxtctl-token': 'fcf39669-052c-48e6-8bea-fc1b94698c5a', 'Content-Length': '749', 'Content-Type': 'multipart/form-data; boundary=087b0460581041e3adda58e208a9a5b2'}
req url       : https://bxt.staging.manjaro.org/api/packages/commit
req body      : b'--087b0460581041e3adda58e208a9a5b2\r\nContent-Disposition: form-data; name="to_move"\r\nContent-Type: application/json\r\n\r\n[{"name": "a-dummy1", "from_section": {"branch": "testing", "repository": "extra", "architecture": "x86_64"}, "to_section": {"branch": "testing", "repository": "extra", "architecture": "aarch64"}}, {"name": "a-dummy2", "from_section": {"branch": "testing", "repository": "extra", "architecture": "x86_64"}, "to_section": {"branch": "testing", "repository": "extra", "architecture": "aarch64"}}, {"name": "a-dummy3", "from_section": {"branch": "testing", "repository": "extra", "architecture": "x86_64"}, "to_section": {"branch": "testing", "repository": "extra", "architecture": "aarch64"}}]\r\n--087b0460581041e3adda58e208a9a5b2--\r\n'
--------------------------------------------------------------
request begin    -->  2024-09-05 17:00:47
response recv    -->  2024-09-05 17:00:47
response headers -->  {'Alt-Svc': 'h3=":443"; ma=2592000', 'Content-Length': '15', 'Content-Type': 'application/json; charset=utf-8', 'Date': 'Thu, 05 Sep 2024 15:00:47 GMT', 'Server': 'Caddy, drogon/1.8.2'}
response status  -->  200
response content -->  b'{"status":"ok"}'
fhdk commented 1 week ago

I have stumpled upon why the move transaction is weird

I did

To me it looks like the daemon got it opposite of what the form says

run the following script sequence and watch the output

package versions and section content (please pull before you test - I have renamed the files - removed the using_bearer - not necessary any more.

pkgbuild/recreate_packages.sh
scratchpads/0010_pkg_upload.py
scratchpads/0050_list_section_content.py
scratchpads/0030_pkg_copy.py
scratchpads/0050_list_section_content.py
pkgbuild/recreate_packages.sh
scratchpads/0010_pkg_upload.py
scratchpads/0050_list_section_content.py
scratchpads/0020_pkg_move.py
scratchpads/0050_list_section_content.py