Bug #19173

host never leaves build mode when token expires during built

Added by Dmitri Dolguikh over 1 year ago. Updated 7 days ago.

Assignee:Dmitri Dolguikh
Category:Host creation
Target version:1.16.0
Difficulty: Team Backlog:
Triaged: Fixed in Releases:
Bugzilla link:1432775 Found in Releases:
Pull request:https://github.com/theforeman/foreman/pull/4508


When building hosts, the templates get rendered using a token that is valid for a certain amount of time.
This token is also verified in the "built" template, which is suposed to flip the host from "in build" to "build finished".
Thus if you start your deployment while the token was still OK, and it expires during the build, the state will not be switched and the machine will boot in build mode again on next reboot.
The new build will error out, but the machine will remain in the booted broken build system and will not boot from local disc.

The problem is because of:
The unattended "built" template calls "find_host_by_token" which calls "Host.for_token(token).first" (see app/controllers/unattended_controller.rb)
for_token is defined as
scope :for_token, ->(token) { joins(:token).where(:tokens => { :value => token }).where("expires >= ?", Time.now.utc.to_s(:db)).select('hosts.*') }
(in app/models/concerns/hostext/token.rb upstream, app/models/host/managed.rb in satellite 6.2)
thus the host is never found and the "built" mode flip is never executed.

Associated revisions

Revision 5e38d636
Added by Dmitri Dolguikh about 1 year ago

Fixes #19173 - build notification succeeds with expired token.


#1 Updated by The Foreman Bot about 1 year ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4508 added

#2 Updated by Anonymous about 1 year ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#3 Updated by Ivan Necas about 1 year ago

  • Target version set to 1.13.1

#4 Updated by Marek Hulán about 1 year ago

  • Legacy Backlogs Release (now unused) set to 240

Also available in: Atom PDF