FRosner / cluster-broccoli

Self service for Nomad based on templates.
Apache License 2.0
60 stars 22 forks source link

Periodic job controls #340

Closed FRosner closed 6 years ago

FRosner commented 6 years ago

Problem

When starting a periodic job, the individual runs are also nomad jobs. However they have no control buttons on Broccoli so you cannot stop them.

Solution

Add job controls for periodic jobs. I think we only need stop buttons here.

Documentation Update

https://github.com/FRosner/cluster-broccoli/wiki/HTTP-API-v1#post-1

POST

Description: Updates an instance. You can either change the status, update the parameter values or select a new template of an instance.

Parameters: status, parameterValues, selectedTemplate, periodicJobsToStop.

Example query for status update:

curl -v -H 'Content-Type: application/json' \
  -X POST -d '{ "status": "running" }' \
  'http://localhost:9000/api/v1/instances/my-http'

Example query for parameter values update:

curl -v -H 'Content-Type: application/json' \
  -X POST -d '{ "parameterValues": { "id": "my-http", "cpu": "50" } }' \
  'http://localhost:9000/api/v1/instances/my-http'

Example query for periodic job stopping:

curl -v -H 'Content-Type: application/json' \
  -X POST -d '{ "periodicJobsToStop": ["my-curl/periodic-1518168960"] }' \
  'http://localhost:9000/api/v1/instances/my-curl'

Example return value:

< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
{
  "id": "my-curl",
  "template": {
    "id": "curl",
    "description": "A periodic job that sends an HTTP GET request to a specified address every minute.",
    "parameters": [
      "id",
      "URL",
      "enabled"
    ],
    "parameterInfos": {
      "URL": {
        "id": "URL",
        "default": "localhost:8000",
        "type": "string"
      },
      "enabled": {
        "id": "enabled",
        "default": "true",
        "type": "raw"
      },
      "id": {
        "id": "id",
        "type": "string"
      }
    },
    "version": "300dd858eb5ac74be1f7779b94060df8"
  },
  "parameterValues": {
    "URL": "wttr.in",
    "id": "my-curl"
  },
  "status": "running",
  "services": [],
  "periodicRuns": [
    {
      "createdBy": "my-curl",
      "status": "dead",
      "utcSeconds": 1518168960,
      "jobName": "my-curl/periodic-1518168960"
    },
    {
      "createdBy": "my-curl",
      "status": "dead",
      "utcSeconds": 1518169020,
      "jobName": "my-curl/periodic-1518169020"
    },
    {
      "createdBy": "my-curl",
      "status": "dead",
      "utcSeconds": 1518169080,
      "jobName": "my-curl/periodic-1518169080"
    }
  ]
}

Links

FRosner commented 6 years ago

selectedTemplate is missing