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

Fixes #34344 - Add support for halting #669

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

adamruzicka
Copy link
Contributor

task.state = :stopped
task.save!
def force_unlock(task = find_dynflow_task)
task.halt
Copy link
Member

@ofedoren ofedoren Jul 27, 2022

Choose a reason for hiding this comment

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

After description in Dynflow/dynflow#406 I understand that this means:

for this task do halt the execution plan but please do finish any running steps.

Is this correct? If so, I still don't quite understand how the whole task will be marked as stopped since we remove here the task.state = :stopped? Won't it be pending even after the running steps are done?

Also, we kinda change here behaviour we had previously. Wouldn't it confuse the users even more?

UPD: Seems like the cops are after us again. Needs rebase as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this correct?

In general, yes, but if I were to be pedantic, I'd have to say almost. There might be different interpretations of "finish any running steps" with slight nuances, but yes. If an action's #run is being executed while the execution plan is halted, the execution plan moves over to stopped, but the action's #run will continue to run until it returns. This doesn't necessarily mean the step itself will be finished.

I still don't quite understand how the whole task will be marked as stopped

There is a mechanism, which makes tasks to be updated based on the state of its corresponding execution plan as the execution plan changes states. Ideally, tasks should be read-only and the only changes should be done to them by this mechanism. Once we flip the execution plan over to stopped, this hook will trigger and update the task to stopped.

we kinda change here behaviour we had previously. Wouldn't it confuse the users even more?

The previous behaviour was seriously broken. Dynflow doesn't care about tasks' attributes at all, so if we went in and updated the state of a task, it would not really do anything. The task would appear as stopped for some time, but if the underlying execution plan was still running, it would overwrite task's status again. It worked for things like locks which relied on "is a resource locked with a locked by a task which is not stopped", but we reworked that eventually.

Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

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

Well, by reading all of your comments and the code, everything LGTM and makes sense now. Not sure if I'm missing any side effects and not sure how to test this all :/ Otherwise ACK from me.

It would be perfect if we somehow ensured we don't brake anything by that. Can our tests do that? If so, let's merge both PRs (after the conflicts are solved of course).

@adamruzicka
Copy link
Contributor Author

Ohh, I knew I was missing something. The new way does nothing when used against a paused execution plan.

Either we can:

  • make the code here do different things based on task's state
  • introduce halting as a completely new action that can only be used when the task is running
  • somehow handle this in dynflow in a do-what-i-mean fashion

@ofedoren
Copy link
Member

  • introduce halting as a completely new action that can only be used when the task is running

I guess this is the safest way. We could start with this, let users to try this out. But if there will be a request to merge this feature into the current behaviour then we would still need to refactor this again :/

  • somehow handle this in dynflow in a do-what-i-mean fashion

This sounds just OK if there wasn't "somehow" :D Also, I'm kinda afraid to poke Dynflow if we can avoid that.

  • make the code here do different things based on task's state

What benefits it could bring instead of the first approach?

@adamruzicka
Copy link
Contributor Author

Went with the second option, the changes in dynflow should now work reasonably well in all possible scenarios. Now further changes should be needed here

@adamruzicka adamruzicka merged commit fbf7530 into theforeman:master Jun 12, 2024
21 of 23 checks passed
@adamruzicka adamruzicka deleted the halt branch June 12, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants