OTA Update Deployment States
After a user deploys an OTA update (say, using the OTA update API), the deployment could be in one of the follow states:
- WAITING
- SCHEDULED
- RUNNING
- EXECUTED
This document describes in detail what each of these states mean and explains the current status of the deployment.
WAITING
The user has just deployed a workflow and created a new deployment (also known as job
) via the API. The job/deployment is stored in the jobs DB for all future references. We call this job/deployment as the parent job. The parent job is added to the job dispatcher’s queue and is waiting to be dispatched by the job dispatcher in the gateway.
SCHEDULED
The job dispatcher in the gateway picks up the parent job, finds the list of devices that belongs to the device group or device tag associated with the deployment/parent job, creates a new child job (one for each device in the list) and finally schedules each of the child job for further processing by adding it in the job downloader queue.
The job is now marked as SCHEDULED but still waiting to be dowloaded to the remote IoT device. Note: Only the child jobs are scheduled to be downloaded to the corresponding IoT devices.
The parent jobs are never scheduled but will be kept in the WAITING state until all the child jobs have finished executing and their results have been received from all the devices.
RUNNING
The job downloader dequeues the child job from the downloader queue, checks if the IoT device is online. If the device status is offline, the child job will be marked as DEVICE_OFFLINE and it will be downloaded to the device later when the device becomes online.
If the device status is online, the job downloader will download the job to the IoT device. At this stage, the gateway has NOT yet received ANY response from the IoT device. The gateway has just finished downloading the job to the device for execution. Until the device has finished executing the job and uploaded the job results back to the gateway, the gateway blindly assumes that the job is still RUNNING in the device.
EXECUTED
The device has finished executing the job and has uploaded the job execution result back to the gateway. The gateway adds the job result to the corresponding child job (StdOut and StdErr fields will be updated) in the DB and marks the child job state as EXECUTED. When all the child jobs for a given parent job have finished executing, the parent job status will also be marked as EXECUTED.