Page MenuHomePhabricator

Underscore in job name gives non-helpful error in toolforge-jobs
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • I was trying to migrate a cronjob from the Grid to toolforge-jobs. So I entered:
  • toolforge-jobs run fer_efem --command /data/project/jorobot/periodics/efemerides/fer_efem.sh --image tf-bullseye-std --schedule "12 20 * * 3"
  • I get an error, saying "likely wrong schedule time"
  • So I retry the same command minus the --schedule option
  • Then I get another error: likely an internal bug.
  • After some thought, I replace the underscore in fer_efem with a hyphen.
  • toolforge-jobs run fer-efem --command /data/project/jorobot/periodics/efemerides/fer_efem.sh --image tf-bullseye-std --schedule "2 21 * * 3"
  • that gets accepted, so it must have been the underscore.

What happens?:

  • The complete first error is:
ERROR: unable to create job: "HTTP 422: likely wrong schedule time. k8s JSON: {\"apiVersion\": \"batch/v1beta1\", \"kind\": \"CronJob\", \"metadata\": {\"name\": \"fer_efem\", \"namespace\": \"tool-jorobot\", \"labels\": {\"toolforge\": \"tool\", \"app.kubernetes.io/version\": \"1\", \"app.kubernetes.io/managed-by\": \"toolforge-jobs-framework\", \"app.kubernetes.io/created-by\": \"jorobot\", \"app.kubernetes.io/component\": \"cronjobs\", \"app.kubernetes.io/name\": \"fer_efem\", \"jobs.toolforge.org/filelog\": \"yes\", \"jobs.toolforge.org/emails\": \"none\"}}, \"spec\": {\"schedule\": \"15 20 * * 3\", \"successfulJobsHistoryLimit\": 0, \"failedJobsHistoryLimit\": 0, \"concurrencyPolicy\": \"Forbid\", \"jobTemplate\": {\"spec\": {\"template\": {\"metadata\": {\"labels\": {\"toolforge\": \"tool\", \"app.kubernetes.io/version\": \"1\", \"app.kubernetes.io/managed-by\": \"toolforge-jobs-framework\", \"app.kubernetes.io/created-by\": \"jorobot\", \"app.kubernetes.io/component\": \"cronjobs\", \"app.kubernetes.io/name\": \"fer_efem\", \"jobs.toolforge.org/filelog\": \"yes\", \"jobs.toolforge.org/emails\": \"none\"}}, \"spec\": {\"restartPolicy\": \"Never\", \"containers\": [{\"name\": \"fer_efem\", \"image\": \"docker-registry.tools.wmflabs.org/toolforge-bullseye-standalone:latest\", \"workingDir\": \"/data/project/jorobot\", \"command\": [\"/bin/sh\", \"-c\", \"--\", \"/data/project/jorobot/periodics/efemerides/fer_efem.sh 1>>fer_efem.out 2>>fer_efem.err\"], \"resources\": {}, \"env\": [{\"name\": \"HOME\", \"value\": \"/data/project/jorobot\"}], \"volumeMounts\": [{\"mountPath\": \"/data/project\", \"name\": \"home\"}]}], \"volumes\": [{\"name\": \"home\", \"hostPath\": {\"path\": \"/data/project\", \"type\": \"Directory\"}}]}}, \"ttlSecondsAfterFinished\": 30, \"backoffLimit\": 1}}}}"
{
  "apiVersion": "batch/v1beta1",
  "kind": "CronJob",
  "metadata": {
    "name": "fer_efem",
    "namespace": "tool-jorobot",
    "labels": {
      "toolforge": "tool",
      "app.kubernetes.io/version": "1",
      "app.kubernetes.io/managed-by": "toolforge-jobs-framework",
      "app.kubernetes.io/created-by": "jorobot",
      "app.kubernetes.io/component": "cronjobs",
      "app.kubernetes.io/name": "fer_efem",
      "jobs.toolforge.org/filelog": "yes",
      "jobs.toolforge.org/emails": "none"
    }
  },
  "spec": {
    "schedule": "15 20 * * 3",
    "successfulJobsHistoryLimit": 0,
    "failedJobsHistoryLimit": 0,
    "concurrencyPolicy": "Forbid",
    "jobTemplate": {
      "spec": {
        "template": {
          "metadata": {
            "labels": {
              "toolforge": "tool",
              "app.kubernetes.io/version": "1",
              "app.kubernetes.io/managed-by": "toolforge-jobs-framework",
              "app.kubernetes.io/created-by": "jorobot",
              "app.kubernetes.io/component": "cronjobs",
              "app.kubernetes.io/name": "fer_efem",
              "jobs.toolforge.org/filelog": "yes",
              "jobs.toolforge.org/emails": "none"
            }
          },
          "spec": {
            "restartPolicy": "Never",
            "containers": [
              {
                "name": "fer_efem",
                "image": "docker-registry.tools.wmflabs.org/toolforge-bullseye-standalone:latest",
                "workingDir": "/data/project/jorobot",
                "command": [
                  "/bin/sh",
                  "-c",
                  "--",
                  "/data/project/jorobot/periodics/efemerides/fer_efem.sh 1>>fer_efem.out 2>>fer_efem.err"
                ],
                "resources": {},
                "env": [
                  {
                    "name": "HOME",
                    "value": "/data/project/jorobot"
                  }
                ],
                "volumeMounts": [
                  {
                    "mountPath": "/data/project",
                    "name": "home"
                  }
                ]
              }
            ],
            "volumes": [
              {
                "name": "home",
                "hostPath": {
                  "path": "/data/project",
                  "type": "Directory"
                }
              }
            ]
          }
        },
        "ttlSecondsAfterFinished": 30,
        "backoffLimit": 1
      }
    }
  }
}
  • The complete second error is:
ERROR: unable to create job: "HTTP 422: likely an internal bug. k8s JSON: {\"apiVersion\": \"batch/v1\", \"kind\": \"Job\", \"metadata\": {\"name\": \"fer_efem\", \"namespace\": \"tool-jorobot\", \"labels\": {\"toolforge\": \"tool\", \"app.kubernetes.io/version\": \"1\", \"app.kubernetes.io/managed-by\": \"toolforge-jobs-framework\", \"app.kubernetes.io/created-by\": \"jorobot\", \"app.kubernetes.io/component\": \"jobs\", \"app.kubernetes.io/name\": \"fer_efem\", \"jobs.toolforge.org/filelog\": \"yes\", \"jobs.toolforge.org/emails\": \"none\"}}, \"spec\": {\"template\": {\"metadata\": {\"labels\": {\"toolforge\": \"tool\", \"app.kubernetes.io/version\": \"1\", \"app.kubernetes.io/managed-by\": \"toolforge-jobs-framework\", \"app.kubernetes.io/created-by\": \"jorobot\", \"app.kubernetes.io/component\": \"jobs\", \"app.kubernetes.io/name\": \"fer_efem\", \"jobs.toolforge.org/filelog\": \"yes\", \"jobs.toolforge.org/emails\": \"none\"}}, \"spec\": {\"restartPolicy\": \"Never\", \"containers\": [{\"name\": \"fer_efem\", \"image\": \"docker-registry.tools.wmflabs.org/toolforge-bullseye-standalone:latest\", \"workingDir\": \"/data/project/jorobot\", \"command\": [\"/bin/sh\", \"-c\", \"--\", \"/data/project/jorobot/periodics/efemerides/fer_efem.sh 1>>fer_efem.out 2>>fer_efem.err\"], \"resources\": {}, \"env\": [{\"name\": \"HOME\", \"value\": \"/data/project/jorobot\"}], \"volumeMounts\": [{\"mountPath\": \"/data/project\", \"name\": \"home\"}]}], \"volumes\": [{\"name\": \"home\", \"hostPath\": {\"path\": \"/data/project\", \"type\": \"Directory\"}}]}}, \"ttlSecondsAfterFinished\": 30, \"backoffLimit\": 1}}"
{
  "apiVersion": "batch/v1",
  "kind": "Job",
  "metadata": {
    "name": "fer_efem",
    "namespace": "tool-jorobot",
    "labels": {
      "toolforge": "tool",
      "app.kubernetes.io/version": "1",
      "app.kubernetes.io/managed-by": "toolforge-jobs-framework",
      "app.kubernetes.io/created-by": "jorobot",
      "app.kubernetes.io/component": "jobs",
      "app.kubernetes.io/name": "fer_efem",
      "jobs.toolforge.org/filelog": "yes",
      "jobs.toolforge.org/emails": "none"
    }
  },
  "spec": {
    "template": {
      "metadata": {
        "labels": {
          "toolforge": "tool",
          "app.kubernetes.io/version": "1",
          "app.kubernetes.io/managed-by": "toolforge-jobs-framework",
          "app.kubernetes.io/created-by": "jorobot",
          "app.kubernetes.io/component": "jobs",
          "app.kubernetes.io/name": "fer_efem",
          "jobs.toolforge.org/filelog": "yes",
          "jobs.toolforge.org/emails": "none"
        }
      },
      "spec": {
        "restartPolicy": "Never",
        "containers": [
          {
            "name": "fer_efem",
            "image": "docker-registry.tools.wmflabs.org/toolforge-bullseye-standalone:latest",
            "workingDir": "/data/project/jorobot",
            "command": [
              "/bin/sh",
              "-c",
              "--",
              "/data/project/jorobot/periodics/efemerides/fer_efem.sh 1>>fer_efem.out 2>>fer_efem.err"
            ],
            "resources": {},
            "env": [
              {
                "name": "HOME",
                "value": "/data/project/jorobot"
              }
            ],
            "volumeMounts": [
              {
                "mountPath": "/data/project",
                "name": "home"
              }
            ]
          }
        ],
        "volumes": [
          {
            "name": "home",
            "hostPath": {
              "path": "/data/project",
              "type": "Directory"
            }
          }
        ]
      }
    },
    "ttlSecondsAfterFinished": 30,
    "backoffLimit": 1
  }
}

What should have happened instead?:

  • I think that underscores should be accepted in the job name.
  • If this is not possible, the error message should at least be helpful and suggest replacing the underscore by a hyphen.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:
This was in tools.jorobot@tools-sgebastion-10:~$

Event Timeline

Using an underscore in a job name is not possible.

There is a check to validate job names, but the error isn't being surfaced to users correctly.

Change 784301 had a related patch set uploaded (by Majavah; author: Majavah):

[cloud/toolforge/jobs-framework-api@main] job: fix name validation

https://gerrit.wikimedia.org/r/784301

Change 784301 merged by jenkins-bot:

[cloud/toolforge/jobs-framework-api@main] job: fix name validation

https://gerrit.wikimedia.org/r/784301

taavi claimed this task.