st2 icon indicating copy to clipboard operation
st2 copied to clipboard

Request to Purge Scheduled Tasks

Open jtopjian opened this issue 7 years ago • 4 comments

Hello,

We ran into an odd issue with our st2 environment (2.5.1). On Friday we noticed that chatops commands weren't publishing results. We decided it wasn't too important and we'd worry about it after the holiday weekend.

Today I poked around and couldn't find any errors in the logs and reloading didn't help, either. So I tried doing:

$ st2ctl stop
$ st2ctl start

And that did the trick - a little too well, though. st2 became flooded with every scheduled task for the past 4 days. Running st2 execution list had the EIDs scrolling too fast to keep track of (and the command limits retrieval to 100), so I quickly lost track of all scheduled tasks. I wasn't going to have st2 hammer away at all of these tasks, either.

I remembered that st2 can purge items from mongo, so I modified the executions.py file to purge everything not in DONE_STATES. This did the trick and we're now back up and running.

I really have no idea what caused this problem, so I'm not sure if this is a rare occurrence or if it happens often enough (where "often" is "it could possibly happen to anyone") that adding support to purge queued/scheduled items would be worthwhile.

jtopjian avatar Feb 20 '18 20:02 jtopjian

I think that this should be covered by the --purge-incomplete flag?

LindsayHill avatar Aug 07 '18 18:08 LindsayHill

Not really, no.

--purge-incomplete will purge everything, right? In this case we wanted to keep our existing execution results, notably the successful ones.

jtopjian avatar Aug 07 '18 18:08 jtopjian

Yes, that is a different scenario. Haven't seen any other similar requests, but it would be easy enough to add if you want to do a PR?

LindsayHill avatar Aug 07 '18 19:08 LindsayHill

We just hit an issue where we had 10,000+ requested tasks that needed purging, luckily it was on a PoC so --purge-incomplete worked fine, and losing all history was OK.

But a --purge-only-complete flag would be very helpful here - so 👍 for this request

jk464 avatar Dec 08 '23 12:12 jk464