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

Activate miq_task when deliver from miq_queue #17015

Merged
merged 7 commits into from
Mar 16, 2018

Conversation

yrudman
Copy link
Contributor

@yrudman yrudman commented Feb 16, 2018

This PR:

  • ensure that any task will have corect started date
  • if arguments for queued method is Hash than :miq_task_id => <task id> will be added to parameters when delivering

blocked by:

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1543289

@miq-bot miq-bot added the wip label Feb 16, 2018
@yrudman yrudman force-pushed the activate-task-when-deliver-from-queue branch from 11f10b2 to b2a1df7 Compare February 19, 2018 12:33
@yrudman
Copy link
Contributor Author

yrudman commented Feb 19, 2018

\cc @mkanoor

@yrudman
Copy link
Contributor Author

yrudman commented Feb 19, 2018

\cc @Fryguy

@yrudman yrudman changed the title [WIP] Activate miq_task when deliver from miq_queue Activate miq_task when deliver from miq_queue Mar 14, 2018
@yrudman
Copy link
Contributor Author

yrudman commented Mar 14, 2018

@miq-bot assign @Fryguy

@@ -541,6 +543,13 @@ def self.get_worker(task_id)

private

def activate_miq_task(args)
MiqTask.update_status(miq_task_id, MiqTask::STATE_ACTIVE, MiqTask::STATUS_OK, "Task starting") if miq_task
Copy link
Member

Choose a reason for hiding this comment

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

Prefer if miq_task_id, so it doesn't need to go out and fetch the task on every dispatch. That being said, if the task is deleted out from underneath the queue item, the MiqTask.update_status method should probably handle that.

Copy link
Contributor Author

@yrudman yrudman Mar 14, 2018

Choose a reason for hiding this comment

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

👍 using miq_task_id is better
When task does not exist MiqTask.update_status does handle it it:

task.update_status(state, status, message) unless task.nil?

@@ -541,6 +543,13 @@ def self.get_worker(task_id)

private

def activate_miq_task(args)
MiqTask.update_status(miq_task_id, MiqTask::STATE_ACTIVE, MiqTask::STATUS_OK, "Task starting") if miq_task
pars = args.first
Copy link
Member

Choose a reason for hiding this comment

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

Prefer params or parameters...pars is not a common abbreviation, so it reads funny.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@Fryguy
Copy link
Member

Fryguy commented Mar 14, 2018

@yrudman What happens to

  • existing messages on the queue where the task id is positional
  • existing usage of the tasks where they don't go through generic_action_with_callback

def activate_miq_task(args)
MiqTask.update_status(miq_task_id, MiqTask::STATE_ACTIVE, MiqTask::STATUS_OK, "Task starting") if miq_task_id
params = args.first
params[:miq_task_id] = miq_task_id if pars.kind_of?(Hash)
Copy link
Member

Choose a reason for hiding this comment

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

woops (if pars)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:(

@yrudman yrudman force-pushed the activate-task-when-deliver-from-queue branch 2 times, most recently from 72a1b2d to 31b3663 Compare March 14, 2018 19:54
@yrudman
Copy link
Contributor Author

yrudman commented Mar 15, 2018

@Fryguy

@yrudman
Copy link
Contributor Author

yrudman commented Mar 15, 2018

also, if there is no willingness to use generic_action_with_callback (as in above examples) than adding :miq_task_id to parameters hash for MiqQueue.put will also trigger activating task when delivering.

@Fryguy Fryguy closed this Mar 15, 2018
@Fryguy Fryguy reopened this Mar 15, 2018
@yrudman yrudman force-pushed the activate-task-when-deliver-from-queue branch from dad3655 to f7653b0 Compare March 16, 2018 17:33
@miq-bot
Copy link
Member

miq-bot commented Mar 16, 2018

Checked commits yrudman/manageiq@5c32ee4~...f7653b0 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
5 files checked, 1 offense detected

app/models/miq_task.rb

@Fryguy Fryguy merged commit 2ead6ad into ManageIQ:master Mar 16, 2018
@Fryguy Fryguy added this to the Sprint 82 Ending Mar 26, 2018 milestone Mar 16, 2018
@yrudman
Copy link
Contributor Author

yrudman commented Mar 16, 2018

@miq-bot add-label gaprindashvili/no

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