<@ULVA73B9P> how can the default value of finished...
# ask-marvin
a
@Marvin how can the default value of finished_job_ttl be set when using a base template file? Adding default as below seems to be ignored.
Copy code
"finished_job_ttl": {
        "title": "Finished Job TTL",
        "description": "The number of seconds to retain jobs after completion. If set, finished jobs will be cleaned up by Kubernetes after the given delay. If not set, jobs will be retained indefinitely.",
        "type": "integer",
        "default": 43200
      },
m
The search results don't seem to provide direct information about setting a default value for
finished_job_ttl
when using a base template file in Prefect. However, the configuration of a work pool's base job template, including the
finished_job_ttl
parameter, should be reflected when updating the work pool with a base job template file. To update a work pool's base job template with Prefect, you would use the command:
Copy code
prefect work-pool update --base-job-template base-job-template.json my-work-pool
Work Pools Documentation Deployment Kubernetes Documentation Please note that the configuration you've shown appears to be correct in terms of defining a default JSON schema property. However, if this isn't being respected, it could be an issue with how the base job template is being applied, or how the Prefect environment interprets the template configuration. Ensure that your
base-job-template.json
file is correctly formatted and that the keys match what's expected by Prefect 2.x's job template schema. If this isn't resolving your issue, I recommend searching through the Prefect GitHub Issues to see if others have encountered similar problems or posting a question there for more targeted support.
a
Looks like this only works if the integer is quoted. i.e
"default": "43200"
inconsistent with other values such as
pod_watch_timeout_seconds: 60
This then causes a failure on execution
Copy code
annot be handled as a Job: json: cannot unmarshal string into Go struct field JobSpec.spec.ttlSecondsAfterFinished of type int32
@Nate this looks like a bug to me. Worth creating an issue on github?
n
sounds like it, can you just clarify where you're doing this? is this JSON in the CLI or in the template in the UI or somewhere else
a
A base template json file that is then loaded via a configmap. I can hardcode the value in the template but as I understand it that will mean jobs cannot customise the value
So:
Copy code
{
  "job_configuration": {
    "command": "{{ command }}",
    "env": "{{ env }}",
    "labels": "{{ labels }}",
    "name": "{{ name }}",
    "namespace": "{{ namespace }}",
    "job_manifest": {
      "apiVersion": "batch/v1",
      "kind": "Job",
      "metadata": {
        "labels": "{{ labels }}",
        "namespace": "{{ namespace }}",
        "generateName": "{{ name }}-"
      },
      "spec": {
        "backoffLimit": 0,
        "ttlSecondsAfterFinished": 43200,
vs in the variables section
n
what you hardcode in the template will just be the default for all jobs based on that work pool, so you still could override on a deployment basis so are you saying there's a quoting issue in the form for the base job template in the UI? or somewhere else sorry I still need my morning coffee 🙂
a
Edited version of the json base template that, I hope, helps make it clear. Not changing anything in the UI. All done via k8s confirmaps and restarting the work-pool (after deleting it from the prefect server...)
Copy code
{
  "job_configuration": {
      "spec": {
        "backoffLimit": 0,
        "ttlSecondsAfterFinished": 43200 <= This can be set but no longer using variables
    },
    "cluster_config": "{{ cluster_config }}",
    "job_watch_timeout_seconds": "{{ job_watch_timeout_seconds }}",
    "pod_watch_timeout_seconds": "{{ pod_watch_timeout_seconds }}",
    "stream_output": "{{ stream_output }}"
  },
  "variables": {
    "description": "Default variables for the Kubernetes worker.\n\nThe schema for this class is used to populate the `variables` section of the default\nbase job template.",
    "type": "object",
    "properties": {
      "finished_job_ttl": {
        "title": "Finished Job TTL",
        "description": "The number of seconds to retain jobs after completion. If set, finished jobs will be cleaned up by Kubernetes after the given delay. If not set, jobs will be retained indefinitely.",
        "type": "integer",
        "default": 43200 <= This will be ignored unless quoted. Quoting it then results in an error on job submission
      },
n
i see i see - thank you. yeah i think an issue for this would be helpful. thanks for bearing with me
a
No worries. Good morning and enjoy your ☕
catjam 1