Bug 1221600

Summary: "Delete all built binaries" does not work - 404 error returned
Product: [openSUSE] openSUSE.org Reporter: Ralf Habacker <ralf.habacker>
Component: BuildServiceAssignee: Adrian Schröter <adrian.schroeter>
Status: RESOLVED FIXED QA Contact: Adrian Schröter <adrian.schroeter>
Severity: Normal    
Priority: P5 - None CC: jacob.michalskie
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Other   
URL: https://build.opensuse.org/projects/windows:mingw:win32/packages/mingw32-llvm13/repositories/openSUSE_Leap_15.4/binaries
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Ralf Habacker 2024-03-18 11:50:48 UTC
At the address given in the URL field, I tried to clean up the existing binaries for this package. After pressing the "Delete all build binaries" button, I get the message "Please confirm deletion of all built binaries". After I press "Remove", I get 

404: Not found

We are sorry, but the page you are looking for does not exist. It could be that the page has simply been moved. We think your best bet is to try searching for what you're looking for below or starting over from the home page. 

This will not allow you to clean up the published binaries, which is necessary in this case to be able to fix the "unresolved" issues with https://build.opensuse.org/package/show/windows:mingw:win32/mingw32-clang13.
Comment 1 Ralf Habacker 2024-04-09 12:21:14 UTC
(In reply to Ralf Habacker from comment #0)
> At the address given in the URL field, I tried to clean up the existing
> binaries for this package.

A workaround is to use the command line

osc wipebinaries --all windows:mingw:win32 mingw32-clang13 -r openSUSE_Leap_15.4
Comment 2 Ralf Habacker 2024-04-09 12:41:31 UTC
(In reply to Ralf Habacker from comment #0)
> At the address given in the URL field, I tried to clean up the existing
> binaries for this package. After pressing the "Delete all build binaries"
> button, I get the message "Please confirm deletion of all built binaries".
> After I press "Remove", I get 
> 
> 404: Not found
> 
> We are sorry, but the page you are looking for does not exist. It could be
> that the page has simply been moved. We think your best bet is to try
> searching for what you're looking for below or starting over from the home
> page. 
>
Inspecting the html content of the associated html formular gives: 

<form action="/projects/windows:mingw:win32/packages/mingw32-clang13/repositories/openSUSE_Leap_15.4/binaries" accept-charset="UTF-8" method="post"><input type="hidden" name="_method" value="delete" autocomplete="off"><input type="hidden" name="authenticity_token" value="..." autocomplete="off"><div class="modal-footer">
<a class="btn btn-sm btn-outline-secondary px-4" data-bs-dismiss="modal">
Cancel
</a>
<input type="submit" name="commit" value="Remove" class="btn btn-sm btn-danger px-4" data-disable-with="Remove">
</div>
</form>

whose attribute 'action' points to the path '/projects/windows:mingw:win32/packages/mingw32-clang13/repositories/openSUSE_Leap_15.4/binaries', which does not exist.

The last change in this area was commit https://github.com/openSUSE/open-build-service/commit/765ea0308f8eea133130f0c75c40df4315d21057
Comment 3 Ralf Habacker 2024-04-09 12:58:11 UTC
(In reply to Ralf Habacker from comment #2)
...
> <form
> action="/projects/windows:mingw:win32/packages/mingw32-clang13/repositories/
> openSUSE_Leap_15.4/binaries" accept-charset="UTF-8" method="post"><input
> type="hidden" name="_method" value="delete" autocomplete="off"><input
> type="hidden" name="authenticity_token" value="..." autocomplete="off"><div
...
> 
> whose attribute 'action' points to the path
> '/projects/windows:mingw:win32/packages/mingw32-clang13/repositories/
> openSUSE_Leap_15.4/binaries', which does not exist.
> 
To be more precise: the URL called as a 'get' request exists, but apparently not as a post request with the specified parameters.
Comment 4 Jacob Michalskie 2024-04-09 13:13:26 UTC
I cannot reproduce this, as far as I can see it works. The request sent includes `_method=delete` parameter in the query, which means rails will treat it correctly as it would a form with delete method, despite it sending a `post`
Comment 5 Ralf Habacker 2024-04-09 14:16:41 UTC
(In reply to Jacob Michalskie from comment #4)
> I cannot reproduce this, as far as I can see it works. The request sent
> includes `_method=delete` parameter in the query, which means rails will
> treat it correctly as it would a form with delete method, despite it sending
> a `post`

If I perform this task on a local obs installation in /srv/www/obs/api/log/production.log I get: 

...
I, [2024-04-09T16:09:49.351483 #21096]  INFO -- : [ce5fcfb2-c016-4426-99fc-36914365a4f8] [21096:465.82] method=GET path=/projects/xxx/packages/xxx/repositories/openSUSE_Leap_15.5/binaries format=html controller=Webui::Packages::BinariesController action=index status=200 allocations=34898 duration=135.38 view=36.31 db=9.79 params={"project_name"=>"xxx", "package_name"=>"yyy", "repository_name"=>"openSUSE_Leap_15.5"} host=zzz time=3032918347.66 backend=71.01 user=...
F, [2024-04-09T16:10:06.537664 #21096] FATAL -- : [d11d554a-777b-4ffc-b533-9fbbdc7f840e] [21096:483.01]   
[d11d554a-777b-4ffc-b533-9fbbdc7f840e] ActionController::RoutingError (No route matches [DELETE] "/projects/xxx/packages/yyy/repositories/openSUSE_Leap_15.5/binaries"):
Comment 6 Jacob Michalskie 2024-04-09 14:23:39 UTC
When I run `rails routes`, one of the lines is `DELETE       /projects/:project_name/packages/:package_name/repositories/:repository_name/binaries(.:format)                                   webui/packages/binaries#destroy`, which corresponds to https://github.com/openSUSE/open-build-service/blob/master/src/api/config/routes/webui.rb#L294 are you seeing both the line in webui.rb file and in the result of `rails routes` command?
Comment 7 Ralf Habacker 2024-04-09 14:31:10 UTC
(In reply to Jacob Michalskie from comment #6)
... 
> which corresponds to
> https://github.com/openSUSE/open-build-service/blob/master/src/api/config/
> routes/webui.rb#L294 are you seeing both the line in webui.rb file 

yes

> and in  the result of `rails routes` command?

no, the command fails to run with the following error 

/srv/www/obs/api/config/environments/development.rb:98:in `block (2 levels) in <top (required)>': uninitialized constant Bullet (NameError)
 
Locally I did installed obs from an rpm package:

 obs-server-2.11~alpha.20240409T130813.7bae3cc67-150500.16713.1.noarch

but this issue also happens on build.opensuse.org.

I also checked with enabled and disabled "beta program" without any difference.
Comment 8 Jacob Michalskie 2024-04-09 14:54:11 UTC
Alright, I finally figured out what's wrong, this will be fixed as soon as https://github.com/openSUSE/open-build-service/pull/15949 is merged
Comment 9 Ralf Habacker 2024-04-10 07:02:39 UTC
(In reply to Jacob Michalskie from comment #8)
> Alright, I finally figured out what's wrong, this will be fixed as soon as
> https://github.com/openSUSE/open-build-service/pull/15949 is merged

I can confirm that with the actual obs rpm package for the unstable version  

obs-api-2.11~alpha.20240409T182942.b9d1c5cbb-150500.16715.1.noarch

the problem has been fixed.

However, this does not apply to https://build.opensuse.org. The problem still exists there.
Comment 10 Jacob Michalskie 2024-04-10 07:29:11 UTC
I just deployed build.opensuse.org, so it also includes this fix now. This is resolved