-
Notifications
You must be signed in to change notification settings - Fork 3
Guest Action Workflows
This outlines three guest-related workflows: creation, deletion, and reboot. Reboot was chosen as it is representative of several other actions manipulating an existing guest - power-off, etc.
The job queue uses beanstalkd rather than trying to implement a queue on top of etcd. For now, a a single beanstalkd server is used for lochness. It is discovered/configured via etcd and ansible as other services. Later, "resiliency" can be added. The queue is used for ordering and easier notification for the worker daemons, though listing and looping over the jobs prefix in etcd would be possible.
Also, two additional daemons:
-
cplacerd - the "guest placement daemon". A single instance - protected by a cluster wide lock - is ran. It only selects hypervisors for new guests (and the metadata shuffling involved). It does not communicate with
mistfy-agent
hypervisors. -
cworkerd - the "worker daemon". Multiple instances may be ran. This handles the actual communication with
mistify-agent
hypervisors and updating of metadata.
Tasks in the beanstalks are just IDs for jobs. Jobs are persisted to etcd and remain after completion. Jobs have a TTL of 24 hours.
cguestd is the "guest API" (not the agent), an HTTP API that end users interact with and is the "official" way to view jobs. The command line tool guest can be used for more convenient interaction with cguestd.
- End user makes request to
cguestd
to create guest with given configuration, directly or viaguest
-
cguestd
processes request- Basic validation of guest data
- Creates guest data stub in etcd, without hypervisor or ip specified
- Creates a job referencing the guest with an action for hypervisor selection
- Adds a task to the
create
beanstalk tube - Returns guest object JSON and job ID to user. The rest of the process is asynchronous and the end user can request job status by ID via
guest
/cguestd
-
cplacerd
processes job- Reserves task from the
create
tube - Basic validation on job and guest
- Selects hypervisor for guest based on criteria
- Saves selected hypervisor in guest data
- Updates job with an action for creation
- Adds a task to the
work
beanstalk tube
- Reserves task from the
-
cworkerd
begins processing job- Reserves the task from the
work
tube - Makes request to the hypervisor's
mistify-agent
to create guest - Updates job with the remote job id (
mistify-agent
has a local job queue), start time, and working status - Release/Requeue task in work beanstalk tube
- Reserves the task from the
The mistify-agent
works on actually creating the guest.
-
cworkerd
monitors job- Reserves task from worker tube
- Makes request to hypervisor's
mistify-agent
to check job status - If incomplete:
- Requeue job into
work
tube (after brief delay) to check again later
- Requeue job into
- If complete/errored:
- Update any necessary metadata
- Update job with finish time and final status (and error if applicable)
- Delete task from beanstalk
- End user makes request to
cguestd
to delete guest, directly or viaguest
-
cguestd
processes request- Creates a job referencing the guest with an action for guest deletion
- Adds a task to the
work
beanstalk tube - Returns guest object JSON and job ID to user. The rest of the process is asynchronous and the end user can request job status by ID via
guest
/cguestd
.
-
cworkerd
begins processing job- Reserves the task from the work tube
- Makes request to the hypervisor's
mistify-agent
to delete guest - Updates job with the remote job id (
mistify-agent
has a local job queue), start time, and working status - Requeue task in work beanstalk tube
The mistify-agent
works on actually deleting the guest.
-
cworkerd
monitors job- Reserves task from worker tube
- Makes request to hypervisor's
mistify-agent
to check job status - If incomplete:
- Requeue in work beanstalk tube after brief delay to check again
- If complete/errored:
- Remove guest from etcd, free up IP, etc.
- Update job with finish time and final status (and error if applicable)
- Delete task from beanstalk
Reboot, power off, start, etc. can all be handled in the same way.
- End user makes request to
cguestd
to reboot guest, directly or viaguest
-
cguestd
processes request- Creates a job referencing the guest with an action for guest reboot
- Adds a task to the work beanstalk tube
- Returns guest object JSON and job ID to user. The rest of the process is asynchronous and the end user can request job status by ID via
guest
/cguestd
-
cworkerd
begins processing job- Reserves the task from the
work
tube - Makes request to the hypervisor's
mistify-agent
to reboot guest - Updates job with the remote job id (
mistify-agent
has a local job queue), start time, and working status - Requeue task in work beanstalk tube.
- Reserves the task from the
The mistify-agent
works on actually rebooting the guest.
-
cworkerd
monitors job- Reserves task from worker tube
- Makes request to hypervisor's
mistify-agent
to check job status - If incomplete:
- Requeue in work beanstalk tube after brief delay to check again
- If complete/errored:
- Update job with finish time and final status (and error if applicable)
- Delete task from beanstalk