Good feedback, thanks both! Filed as https://phabricator.wikimedia.org/T376099.

On Mon, Sep 30, 2024 at 7:54 AM Dreamy Jazz <dreamyjazzwikipedia@gmail.com> wrote:
Thanks for the quick reply.

Using activeDeadlineSeconds sounds good to me.

One thing I would note is that the job would be marked as having failed, though I think the distinction between complete and failed in that context would be not be significant.

Dreamy Jazz / WBrown (WMF)


On Mon, 30 Sept 2024 at 15:26, Chris Danis <cdanis@wikimedia.org> wrote:
On Mon, Sep 30, 2024 at 5:55 AM Dreamy Jazz <dreamyjazzwikipedia@gmail.com> wrote:
I have the occasional need to run a maintenance script manually one-off for a set amount of time. I used the "timeout" command with "mwscript" to exit the script after a specified amount of time. However, I cannot see an easy way to achieve this, as the mwscript-k8s command exiting doesn't stop the execution of the maintenance script.

Hi Dreamy,

I don't think this would be too hard to implement.

I think we could plumb through a new CLI argument for mwscript-k8s that, if set, would set the .spec.activeDeadlineSeconds field on the k8s Job object.  It would be a small patch to the Helm chart and to the Python script.

The activeDeadlineSeconds field has the following behavior: https://kubernetes.io/docs/concepts/workloads/controllers/job/#job-termination-and-cleanup
Can you confirm this sounds good to you?

Thanks!