Project

General

Profile

Actions

Bug #18919

closed

Starting Foreman task from finalize of another leaves new task in planned state

Added by Matthias Dellweg about 7 years ago. Updated over 6 years ago.

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

Description

When initiating a new Foreman task within finalize phase of another, the corresponding Dynflow task might change its state/result to stopped/successful before the frontend Foreman task has hit the database.
In that case, the latter will be saved with planned/successful and never receive the update. It will hold its resource locks forever.
The workaround i found is to check for a changed state in the after_commit hook and initiate another update. See the attached Patch.


Files

Actions #1

Updated by Adam Ruzicka about 7 years ago

Just to be sure we're on the same page...
You have a task A and in its finalize phase you start task B. B becomes planned, A finishes and goes to stopped/success.

and never receive the update.

What is the update B never receives?

Could you please elaborate a bit on this?

Actions #2

Updated by The Foreman Bot about 7 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman-tasks/pull/242 added
Actions #3

Updated by Matthias Dellweg about 7 years ago

The problem is, the task is saved twice in the database: Once as Dynflow's execution plan and once as the ForemanTasks::Task.
When starting task B from finalize of task A (synchronously or asynchronously), the execution plan may finish itself before the transaction of task A commits the ForemanTasks::Task of B into the database. It tries to update B's status in line lib/foreman_tasks/dynflow/persistence.rb:48, but fails silently.

Actions #4

Updated by Matthias Dellweg over 6 years ago

How can I close this issue?
The the original problem is solved, and the answer is: "Do not plan tasks in finalize."

Actions #5

Updated by Ivan Necas over 6 years ago

  • Status changed from Ready For Testing to Rejected

Thanks for info. Closing now

Actions

Also available in: Atom PDF