This repository has been archived by the owner on Nov 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BZ#1184630 - deployments run forever
https://bugzilla.redhat.com/show_bug.cgi?id=1184630 Implement timeouts for actions which do polling. Note that if DynFlow executor stops working, the timeout checking will stop working too, and the deployment will still run forever. This patch mitigates issues like Puppet not being triggered, provisioning failures etc., but not DynFlow failures.
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Actions | ||
module Staypuft | ||
module Middleware | ||
class Timeout < Dynflow::Middleware | ||
|
||
def plan(*args) | ||
pass(*args).tap do | ||
action.input[:timeout] ||= action.class::TIMEOUT | ||
end | ||
end | ||
|
||
def run(*args) | ||
assert_timeout_not_reached | ||
pass(*args) | ||
end | ||
|
||
private | ||
|
||
def assert_timeout_not_reached | ||
action.output[:timeout_start] ||= Time.now.to_i | ||
|
||
timeout_start = action.output[:timeout_start] | ||
now = Time.now.to_i | ||
timeout = action.input[:timeout] | ||
|
||
if now - timeout_start > timeout | ||
# clear timeout_start so that the action can be resumed/skipped | ||
action.output[:timeout_start] = nil | ||
fail(::Staypuft::Exception, | ||
"You've reached the timeout set for this action. If the " + | ||
"action is still ongoing, you can click on the " + | ||
"\"Resume Deployment\" button to continue.") | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |