Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding simple polling timeout mechanism #151

Merged
merged 2 commits into from May 18, 2015

Conversation

jlsherrill
Copy link
Contributor

This adds the ability for an action to call schedule_timeout(50), to
schedule when the polling should stop and the task be marked as failed.
In this simple implementation the above would cause the task to fail after 50
seconds. Actions could override process_timeout to do more advanced things

@jlsherrill
Copy link
Contributor Author

example of a more advanced implementation: Katello/katello#5225

this uses process_timeout to do a 2-phase timeout

@@ -13,6 +14,9 @@ def run(event = nil)
end
when Poll
poll_external_task_with_rescue
when Timeout
process_timeout
poll_external_task_with_rescue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is unreachable, rigth (since the process_timeout will fail)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if process timeout throws an exception (in the default case that is true, but in the 'advanced' cases where process_timeout is overridden, maybe not).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't that then be part of the overridden process_timeout the responsibility to poll?

@iNecas
Copy link
Member

iNecas commented May 13, 2015

Looks good. One suggestion: extracting the timeout-specific methods into Action::Timeout and including that into the Polling, so that other actions can use that as well: might be useful not just for polling

@iNecas
Copy link
Member

iNecas commented May 13, 2015

Would you mind adding some tests into https://github.com/Dynflow/dynflow/blob/master/test/action_test.rb, you can inspire by https://github.com/Dynflow/dynflow/blob/master/test/action_test.rb#L256: simply defining a dummy polling action that would define the timeouts and would simulate the hanging, and then checking that it got paused after the timeout (the timeout might be really short so that the tests are still fast)

@iNecas
Copy link
Member

iNecas commented May 13, 2015

The tests would then be also a good example on how to use this feature

jlsherrill and others added 2 commits May 14, 2015 15:20
This adds the ability for an action to call schedule_timeout(50), to
schedule when the polling should stop and the task be marked as failed.
In this simple implementation the above would cause the task to fail after 50
seconds.  Actions could override process_timeout to do more advanced things
Before this patch, the clock in tests were not respecting the
time values, so some event to happen in far future would be triggered
before the shot-term event. Also, when two events were pending in
clock, when while processing the first event, some other event
occurred, we were ignoring it. Now, the new event gets properly
scheduled.
@iNecas
Copy link
Member

iNecas commented May 18, 2015

Thanks @jlsherrill

iNecas added a commit that referenced this pull request May 18, 2015
adding simple polling timeout mechanism
@iNecas iNecas merged commit e84f24e into Dynflow:master May 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants