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

Change last_run_at=None when using disable tasks admin action #501

Merged
merged 5 commits into from Jan 25, 2022
Merged

Change last_run_at=None when using disable tasks admin action #501

merged 5 commits into from Jan 25, 2022

Conversation

Kirade
Copy link
Contributor

@Kirade Kirade commented Jan 24, 2022

PeriodicTask model's save method implements that when disabling task, it changes its last_run_at field to None.

# models.py
if not self.enabled:
    self.last_run_at = None

But disable_tasks in PeriodicTaskAdmin action. does not change periodic task's last_run_at attribute.

# admin.py
def disable_tasks(self, request, queryset):
    rows_updated = queryset.update(enabled=False)
    PeriodicTasks.update_changed()
    self._message_user_about_update(request, rows_updated, 'disabled')
disable_tasks.short_description = _('Disable selected tasks')

Due to this behavior, Even if we disable some tasks using action, tasks runs immediatey as soon as task enabled.

To fix this issue, I suggest change last_run_at attribute to None when disable_tasks.

Thanks!

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

thanks for the PR can you check the lint failure please? I will do some testing & thorough review before merge

@Kirade
Copy link
Contributor Author

Kirade commented Jan 24, 2022

Yes, I'll check out and request you soon. Thanks!

@Kirade Kirade requested a review from auvipy January 24, 2022 10:58
@auvipy auvipy added this to the v2.3.0 milestone Jan 24, 2022
@Kirade Kirade closed this Jan 25, 2022
@Kirade Kirade deleted the disable-tasks branch January 25, 2022 05:19
@Kirade Kirade restored the disable-tasks branch January 25, 2022 05:19
@Kirade Kirade reopened this Jan 25, 2022
Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

can you also include release note entry please?

@Kirade
Copy link
Contributor Author

Kirade commented Jan 25, 2022

can you also include release note entry please?

Yup, I guess you mean Changelog entry. right? 😉

@Kirade Kirade requested a review from auvipy January 25, 2022 08:02
@auvipy auvipy merged commit d9ba432 into celery:master Jan 25, 2022
@auvipy
Copy link
Member

auvipy commented Jan 25, 2022

thanks. feel free to send any follow up PR, if any regression happen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants