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 #30870 - Option to delete paused task. #407
Fixes #30870 - Option to delete paused task. #407
Conversation
Issues: #30870 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality wise it works as expected. Code wise I am requesting Kavita for more views.
@kgaikwad request to review as changes are in core. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added few inline comments.
@@ -8,6 +8,8 @@ class Resume < ForemanMaintain::Procedure | |||
|
|||
def run | |||
output << feature(:foreman_tasks).resume_task_using_hammer | |||
puts '[ Waiting 30 seconds for resumed tasks to start. ]' | |||
sleep 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it be good to define constant at either procedure level or feature level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can do that.
@@ -176,6 +178,10 @@ def old_tasks_condition(state = "'stopped', 'paused'") | |||
"foreman_tasks_tasks.started_at < CURRENT_DATE - INTERVAL '#{MIN_AGE} days'" | |||
end | |||
|
|||
def paused_tasks_condition(state = "'paused'") | |||
"foreman_tasks_tasks.state IN (#{state})" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, you have taken state of tasks into consideration.
not_paused
check calls feature(:foreman_tasks).paused_tasks_count(ignored_tasks)
to find specific paused tasks.
I think, deleting only such paused tasks where result=error and not having label from ignored_tasks
is expected here. Could you confirm this behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kgaikwad Yes it is expected that we should not delete ignored_tasks
These tasks are meant to be running always.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kgaikwad @patilsuraj767 Currently we delete tasks where result=error, what about the tasks where result is pending or delayed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jameerpathan111 There is another check in foreman-maintain. Check not_running
task which is run after the check not_paused
in upgrade workflow, it will take care of running/pending tasks.
@patilsuraj767, @upadhyeammit |
@patilsuraj767 I have tried this pr and it looks good to me: Test steps:
Observation:
Workaround for creating paused tasks:
FM command output:
|
There was an issue I faced while trying this pr on 6.9. I am still looking into it, so for sometime would request to hold this pr from getting merged. |
865555e
to
a913f06
Compare
a15ae73
to
ad9694b
Compare
ad9694b
to
d502f4e
Compare
@jameerpathan111 do you have any thoughts on latest changes ? |
@@ -12,9 +12,17 @@ def run | |||
paused_tasks_count = feature(:foreman_tasks).paused_tasks_count(ignored_tasks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@upadhyeammit According to me we should also remove ignored_tasks
parameter from here. Because even though we can ignore these tasks they should not be in the Paused state ever, especially while satellite upgrade.
Let me know your thoughts on above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, however I have these thoughts,
- This check is tagged as default which means it runs for health checks and at the time of upgrade checks and runs. So should we only skip ignored_task when we will actually do the upgrade check and upgrade run ?
- We do this check after restarting the services and as per my limited knowledge if we restart all services these ignored tasks should not be in paused state ? So here if we delete those while doing the health check they wont be created again ? Because after deletion we are not restarting services ? However at the time of upgrade, at very end of scenario we start the services.
What you think @patilsuraj767 and @kgaikwad ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates on above query:
Currently, this check is tagged as default so it is running as part of health as well as upgrade.
As per offline discussion with @upadhyeammit & @patilsuraj767, it is worth verifying few things before any solution:
- What will be the impact when it deletes paused tasks including labels "Actions::Candlepin::ListenOnCandlepinEvents", "Actions::Katello::EventQueue::Monitor" because currently it is ignoring paused tasks with those labels?
- Would it be safe to run this deletion procedure when it won't perform service restart?
Example - foreman-maintain health check command. - Do we really need this check as part of health command? Other tasks related checks are tagged as "pre-upgrade"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* What will be the impact when it deletes paused tasks including labels "Actions::Candlepin::ListenOnCandlepinEvents", "Actions::Katello::EventQueue::Monitor" because currently it is ignoring paused tasks with those labels?
delete all of these, these tasks were removed from Foreman Tasks in 6.7 and are no longer processed as a task. Definitely delete them..
* Would it be safe to run this deletion procedure when it won't perform service restart? Example - foreman-maintain health check command.
yes, any time you delete a paused task, you do not need to restart services.
* Do we really need this check as part of health command? Other tasks related checks are tagged as "pre-upgrade"
I'd keep this with the health check as it is now as well as during the upgrade.
@patilsuraj767 request to do necessary changes, thank you ! |
@kgaikwad any final thoughts before merging ? |
I tested this and what I can see is we are printing sort of confusing message as below. I think we should only keep 'Deleted paused tasks' as message ? its coming from Procedures::ForemanTasks::Delete procedure.
|
|
||
def next_procedures | ||
if assumeyes? | ||
[Procedures::ForemanTasks::Resume.new, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explicitly return the array inside if block ? now even when we have assumeyes? true it returns three next steps.
No description provided.