CODE_GCE_BAD_REQUEST when using FLEX_START + timeout on Google Batch

I am trying to submit a job to Google Batch that uses the Flex-Start provisioning model. It seems to get rejected with the following error if a timeout is included for the Runnable:

Job gets no longer retryable information Batch Error: code - CODE_GCE_BAD_REQUEST, description - googleapi: Error 400: Invalid value for field ‘resource.properties.scheduling.maxRunDuration’: ‘{ “seconds”: “604800”}’. max-run-duration for given provisioning model is not supported without an instance termination action., invalid, already retried 3 times, errors record CODE_GCE_BAD_REQUEST.

It’s not clear to me how to set an instance termination action for the underlying VM. Is there a better way to set a job timeout?

allocationPolicy:
  instances:
  - policy:
      accelerators:
      - count: '1'
        type: nvidia-l4
      bootDisk:
        image: <redacted>
      machineType: g2-standard-4
      provisioningModel: FLEX_START
status:
  runDuration: 0s
  state: FAILED
  statusEvents:
  - description: "Job gets no longer retryable information Batch Error: code - CODE_GCE_BAD_REQUEST,\
      \ description - googleapi: Error 400: Invalid value for field 'resource.properties.scheduling.maxRunDuration':\
      \ '{  \"seconds\": \"604800\"}'. max-run-duration for given provisioning model\
      \ is not supported without an instance termination action., invalid, already\
      \ retried 3 times, errors record CODE_GCE_BAD_REQUEST."
    eventTime: '2026-04-30T21:03:53.889120789Z'
taskGroups:
- name: (PII Removed by Staff)
  parallelism: '1'
  taskCount: '1'
  taskSpec:
    runnables:
    - script: 
        text: ...
        timeout: 3600s

Including reservation=”NO_RESERVATION” in the InstancePolicy seems to work around it.

Hey Timpalpant,

That’s true, thanks for updating the post.

Public documentation for using FLEX_START provisioning model says:

Batch uses Flex-start VMs for jobs that do all of the following:

For more details please check: Create and run a job that uses GPUs  |  Batch  |  Google Cloud Documentation

Please let me know if you will need any help.