Project

General

Profile

Actions

Bug #10285

closed

setBuild Rails route is HTTP PUT and not GET

Added by Ben Bettridge about 9 years ago. Updated about 8 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
Web Interface
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Hey guys,

Picked this bug up today when trying to rebuild a machine:

Started GET "/hosts/intdaflcap01.switch.internal/setBuild" for 10.1.0.1 at 2015-04-28 15:07:31 +1000

ActionController::RoutingError (No route matches [GET] "/hosts/intdaflcap01.switch.internal/setBuild"):
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'

And checking /usr/share/foreman/config/routes.rb I see:

...
        get 'review_before_build'
        put 'setBuild'
...

Changing the lines in routes.rb to read:

...
        get 'review_before_build'
        get 'setBuild'
...

Fixes the issue. I did a quick grep of the codebase to ensure that it's not breaking anything elsewhere, and haven't experienced any issues since making the patch.

Actions #1

Updated by Dominic Cleal about 9 years ago

  • Category set to Web Interface
  • Status changed from New to Need more information

How did you make the setBuild request in the first place? Is this from your browser (which version?) and on which page? Your browser should be able to send a PUT request. Is there a regular way to reproduce it?

Also, which version of Foreman?

Actions #2

Updated by Ben Bettridge about 9 years ago

Foreman version is 1.7.4.

The issue isn't that the browser is incapable of performing an HTTP PUT request, it's that the route type (PUT) doesn't match the method called by the "Build" Web UI button.

So when you click the "Build" button in the web UI it runs this under the hood:

<a data-original-title="Enable rebuild on next host boot" class="btn btn-default" href="/hosts/<HOSTNAME>/setBuild" data-confirm="Rebuild <HOSTNAME> on next reboot?
This would also delete all of its current facts and reports" data-id="aid_hosts_<HOSTNAME>_setBuild" title="">Build</a>

And clicking that performs an HTTP GET, resulting in a 404 error because the route defined for setBuild is a PUT.

Either the route should be changed to match the Web UI button as I have done locally, or the Web UI button should be updated to perform a PUT.

Actions #3

Updated by Dominic Cleal about 9 years ago

I think something is wrong in your installation, it looks like a weird mix of 1.6 and 1.7.

Foreman 1.7 added a build review popup when you click the Build button, and also changed the build link (which is within the popup window) to PUT from GET.

The build link HTML you showed isn't actually in 1.7 anywhere, it was part of 1.6, which explains why it wouldn't have worked for you now without more code changes.

I would consider reinstalling the foreman package and making sure apache2 is fully restarted. If you have foreman-assets installed, then you might want to try manually recompiling assets with "foreman-rake assets:precompile" - if you don't have this installed, ignore this as it might worsen matters.

https://www.youtube.com/watch?v=u2T96Ekpysg shows what you should be seeing when clicking the Build button.

Actions #4

Updated by Tomer Brisker about 8 years ago

  • Status changed from Need more information to Rejected

Seems to be a problem with user's installation. No new comments were added in 10 months, assuming this has been resolved and closing. Feel free to reopen if issue still occurs and provide more information.

Actions

Also available in: Atom PDF