Specifically, warning or errors generated in drush_hook_pre_hosting_task() or hook_post_hosting_TASK_TYPE_task(), will not affect the status of a task, though they will be flagged in the task log.

To replicate just drop drush_log('intentional','warning'); or drush_log('intentional','error'); into hosting_site_post_hosting_backup_task() or drush_hosting_site_pre_hosting_task().

Comments

ergonlogic’s picture

This behaviour is due to our setting the task_status in drush_hosting_task(). At that point, we only know about the task itself, and we're unaware of pre- and post- hooks. Maybe we should also check in hosting_task_log(). If $type is 'warning' or 'error', we could update the task node's task_status accordingly.

ergonlogic’s picture

ergonlogic’s picture

Status: Active » Needs work
StatusFileSize
new1.53 KB

The attached patch works insofar as we get the proper task status. The problem though, is that a warning or error early in task execution will immediately set the status, so we lose our processing throbber.

ergonlogic’s picture

Actually, I believe this is a problem we already have. That is, as things stand, if we have a long-running post- hook, the task status will update, despite the fact that Drush continues to process.

I don't know if this can work from within the task itself. If we update the status on the fly, then we lose our 'processing' status. If we update the status in drush_hosting_task() (as we do now), we miss out on post- hooks. #1975086: tasks sometimes are marked as running when they have in fact crashed suggests using register_shutdown_function, and there's also hook_drush_exit(), but we'd need to ensure they run after any post hooks.

Perhaps the task status should be updated by the caller: hosting-dispatch or the queue daemon?

ergonlogic’s picture

Status: Needs work » Fixed

Fixed in 2b60b0d, by introducing hosting_task_drush_exit(), and removing the update code in drush_hosting_task().

steven jones’s picture

Nice work!

ergonlogic’s picture

Thanks :)

Note that we can't currently ensure we'll run after all Drush operations, since other implementations of hook_drush_exit() could end up running after. I've submitted the following feature request to Drush to enable better reliability here: #2031383: Provide weight-like mechanism to ensure order of hook calls

omega8cc’s picture

Priority: Major » Critical
Status: Fixed » Needs work

Have you tried hostmaster upgrade with this patch applied? It hangs all tasks in a "running" state, while none really runs.

[EDIT] I mean, it breaks on upgrade from older 2.x head (for me, at least) so it would be a good idea to check how it works for upgrades from 1.x

ergonlogic’s picture

Status: Needs work » Fixed

I've update #2023113: [meta] 2.0 release and the beta2 release notes to mention that fixing this issue required a new Drush commandfile, so we should ensure upgrade processes and documentation point out the need for a 'drush cc drush' if we aren't upgrading from Drush 4 to 5 with the next beta release. Either way, we can track this in a separate issue, if it turns out to be more serious than that.

anarcat’s picture

the debian package already does a drush cc drush, and should the install/upgrade docs, but i haven't checked.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 2b60b0d on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by ergonlogic:
    Issue #2027269: Update a task's status after all Drush operations are...

  • Commit 2b60b0d on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by ergonlogic:
    Issue #2027269: Update a task's status after all Drush operations are...