Skip to main content

Allow push policies to cancel tasks

You can end up with an infinitely delayed tracked run in the following situation:

  1. Have a task that ends up in an Undecided approval state and is thus waiting indefinitely for approval

  2. Have a tracked run triggered by any means (manually, push policy, etc.)

  3. The tracked run is blocked by the pending task. The tracked run sits in the Queued state until the task is manually approved or rejected.

We had a tracked run sit in queued for 4 days unintentionally because of a task that was pending approval.

While we can notify for tasks pending approval, I have a feeling that we would want tracked runs to take precedence over tasks (if this undesirable, then you could lock the stack perhaps). We could theoretically implement this ourselves using a push policy, except that in reality, task runs pending approval don’t appear in the push policy input in_progress_runs property.

Workaround
Problem
Status: ❌ Rejected6 comments

Log in to comment and vote

Comments6

  • Aleksandra Cieslak

    Team•

    Sep 9

    Hi!

    Closing this out, as it's been open for about a year with limited traction, and since you mentioned this is a smaller use case on your side, we don't think a platform-level fix is the right investment right now.


    The workarounds Natalia outlined are what we'd recommend for now. If you need help writing the policy, feel free to reach out to our support team!

    If this becomes a bigger issue as you scale, happy to revisit the request.

    Thanks again for the detailed writeup!

  • Natalia Gazda

    Team•

    Jul 18, 2025

    Hi @Evan Strat! Thank you for sharing this feature request and the context around your workflow. To better understand your needs and explore potential solutions, I’d like to ask a few follow-up questions:

    1. Prioritization Needs: Should tracked runs always take precedence over tasks, or are there specific scenarios (e.g., critical stacks, production environments) where this is more important?

    2. Timeouts and Escalations: Would introducing a timeout for tasks pending approval (e.g., auto-cancel or escalate after X hours) help address this issue? If so, what would be a reasonable timeout for your workflow?

    3. Push Policy Enhancements: If tasks pending approval were included in the in_progress_runs property, would that enable you to define custom prioritization logic effectively?

    4. Notifications: Would notifications for long-queued tracked runs or pending tasks help reduce operational delays?

    • Amaranth Dew

      •

      Jul 21, 2025

      1. The main issue was indefinitely queued tracked runs because of a task pending approval. The person who starts the task might not realize they’re delaying tracked runs until they get approval

      2. I’m not sure on the utility of a timeout alone, but better accessibility to the data from a notification policy would help so we can tell people that their run is waiting on a task to complete.

      3. Yes

      4. This would also help, and might also be enough. If we could find out about in-progress tasks run a notification policy, then we could share that info, or even just having some admin-level notification would make troubleshooting easier. As I recall, the original issue that led us to make this feature request was that it was unclear why the run had been queued for so long. (The UI shows the blocked run but unless you click into it, you might just assume there’s another tracked run happening and it’ll be done soon)

      • Natalia Gazda

        Team•

        Aug 8, 2025

        @Evan Strat and how about the following approaches:

        1. Use Notification Policy to alert on pending tasks

        2. Cancel stuck tasks via UI/API when they block important runs

        3. Set up automated cleanup for tasks pending >X hours

        4. Use stack locking instead of long-running tasks for maintenance windows

        Would any of these approaches work for you?

        • Amaranth Dew

          •

          Aug 8, 2025

          Notifications or automated cleanup both make sense, I think it’s mainly just that we haven’t taken the time to implement approval notifications because it’s currently a small use case and we have to write the notification policy ourselves. If Spacelift can provide a platform-level way to handle this, that would be nice, even if it’s just a simple thing like sending an admin notification for any run stuck in queued/ready for > 24 hours or something.

          • Natalia Gazda

            Team•

            Aug 14, 2025

            If you would need help with writing policies feel free to reach out to our support team, they are always happy to help there!

            Else I’ll move it to gathering votes for now, to see weather it gets more traction :)