Jump to: navigation, search

EventScheduler

Revision as of 20:12, 2 May 2013 by Adrian Otto (talk | contribs) (Event Creation)

Proposal Only

Please recognize that this is only a proposed service to be considered for development. This is NOT YET IMPLEMENTED. Proposed by Adrian Otto on 2013-05-02.

Overview

Both Nova and Heat (Autoscale) have a need to kick off regularly scheduled task flows. We expect that it may be convenient to trigger Heat Orchestrations as well, which may in turn trigger Convection task flows. A discussion on our Dev ML[1][2] about scheduled snapshots in Nova has made it clear that this would be useful as a general purpose service that multiple projects could utilize.

In the spirit of Gall's Law we wish to create something simple, functional, and useful that can be evolved over time to support a wider range of utility.

ML References

  1. http://lists.openstack.org/pipermail/openstack-dev/2013-April/008307.html
  2. http://lists.openstack.org/pipermail/openstack-dev/2013-May/008332.html

Scope

An API service for allowing for a future event to be triggered, or repeatedly triggered on a regular schedule until deletion. Offer the ability to:

  1. Register a webhook that will be executed at a specific future time.
  2. Register a that will be executed repeatedly once per specified time interval.

The only job of this service is to trigger a webhook at the specified future time, or on the indicated time interval.

NOTE: The actual start time of the event is not guaranteed, but the attempt to start such an event at least once every cycle of the interval is guaranteed.

Out of Scope

  1. This system is not concerned with the tasks or scripts that will be run. Such task creation and execution thereof will happen in an external system such as Convection. Such a system may trigger an Orchestration in Heat, which involves submitting an orchestration template to the Heat API.
  2. This system is not concerned with cron syntax, or any localized timezone concerns. If those features are desired they can be implemented using this system as a fundamental building block.

API

Synopsis:

Verb URI Description
GET /{tenant_id}/events List existing scheduled events
GET /{tenant_id}/events/{id} Get event details
PUT /{tenant_id}/events Create a new event
DELETE /{tenant_id}/events/{id} Delete an event

Event Creation

Verb URI Description
PUT /{tenant_id}/events Create a new event

Schedule a recurring event to run once per 24 hours:

{
   "name": "Nightly Snapshot Trigger",
   "webhook": "http://example.org/aabbccdd",
   "deleteWebhook": "http://example.org/aabbccdd834903",
   "intervalSeconds": "86400",
   "overlapPolicy", "kill",
   "timeoutSeconds": 3600
}

Schedule single event to run at a future date

{
   "name": "Nightly Snapshot Trigger",
   "webhook": "http://example.org/aabbccdd",
   "deleteWebhook": "http://example.org/aabbccdd834903",
   "runAtEpochSeconds": "1399057324",
   "timeoutSeconds": 3600
}

Request Attributes:

Attribute Required Description
name N A short descriptive string assigned upon creation to identify the task.
webhook Y The webhook URL that the event scheduler system will trigger on the specified interval.
deleteWebhook N The webhook URL that the event scheduler system will trigger if the timeout is reached, or overlapPolicy triggers.
runAtEpochSeconds OR The unix epoch time (seconds since 1970-01-01 00:00:00 GMT) to start the task. May not be combined with intervalSeconds or overlapPolicy.
intervalSeconds OR The frequency in seconds that this task will be triggered on. May not be combined with runAtEpochSeconds.
overlapPolicy N How to handle the situation there the previous task's completionWebhook was not called before the start of the subsequent start time. Available policies:
skip: Do not start an overlapping task. May not be combined with runAtTime.
delete: Delete the prior task using the deleteWebhook (kill/rollback the task in the task system)
default: Start another task
timeoutSeconds N Number of seconds to wait before calling deleteWebhook if completionWebhook is not called first. Default: 3600


NOTE: Either runAtEpochSeconds or intervalSeconds must be supplied. If both are present, or both are absent a "400 Bad Request" error must be returned.

One-Time Events

If the runAtEpochSeconds attribute is used to indicate a specific future run time for the task, the system may execute it at that precise time, or some time after that time, and before runAtEpochSeconds+timeoutSeconds. If the system can not guarantee to trigger the even during this window, then an error may be returned to refuse the PUT request. (Error code TBD).

Get Event Details

Verb URI Description
GET /{tenant_id}/events/{id} Get event details
{
   "id": "aaaaaa-bbbbb-cccc-dddd-eee",
   "name": "Nightly Snapshot Trigger",
   "webhook": "http://example.org/aabbccdd",
   "deleteWebhook": "http://example.org/aabbccdd834903",
   "completionWebhook": "http://example.org/aabbccdd78437834798382782",
   "intervalSeconds": "86400",
   "overlapPolicy", "skip",
   "timeoutSeconds": "3600",
   "lastExecution", "1367519917",
   "status", "IDLE"
}

Details:

  • id: The server-assigned GUID string of the scheduled event
  • name: A short descriptive string assigned upon creation to identify the task.
  • webhook: The webhook URL that the event scheduler system will trigger on the specified interval.
  • deleteWebhook: The webhook URL that the event scheduler system will trigger if the timeout is reached, or overlapPolicy triggers.
  • completionWebhook: The webhook that the task executor must call to mark this task as completed in the EventScheduler system.
  • intervalSeconds: The frequency in seconds that this task will be triggered on.
  • overlapPolicy: How to handle the situation there the completionWebhook was not called before the start of the subsequent start time
    • skip: Do not start an overlapping task.
    • delete: Deelte the prior task using the deleteWebhook (kill/rollback the task in the task system)
    • default: Start another task
  • timeoutSeconds"': The timeout in seconds after which the
  • lastExecution, The unix epoch time (seconds since 1970-01-01 00:00:00 GMT) the last task was started. Default: 0
  • status: Indicate the status of the event, in accordance with the Event Lifecycle

Event Lifecycle

State Description
IDLE The task is not running, and will be scheduled to run in the future.
RUNNING The task for this event has been started and is running. The completionWebhook has not yet been called.
TIMEOUT The task has been timed out after timeoutSeconds, and the deleteWebhook is being called.
ERROR The task could not be started because the POST request to the webhook URL failed.

Triggering Tasks

Scheduled events trigger task flows (aka: workflows) in an external system (probably Convection) by using a webhook. The output of a GET on that single event will be passed in the body of the POST to the specified webhook URL. This will inform the task execution system of the completionWebhook to call when it finishes the task.

Security

The webhooks will need to be signed in a way that the receiver of the webhook (most likely Convection) will be able to authenticate the request, and take the appropriate action. We may want a feature that restricts the domains that are allowed in the URL of the supplied webhooks.

Use Cases

# Project Description
1 Nova Scheduled Images
2 Heat Scheduled Autoscale (Scale up/down resources on a pre-determined schedule)
N Yours Add yours here please

Pending Questions

  1. What features should be included?
  2. Where should the service be incubated, and if/how it should be integrated with Oslo? The answer to this should indicate where the blueprints should be filed.
  3. Are there volunteers to work on this?