Jobs

This chapter describes the “Jobs” resource that represents instances of backups and restores.

GET /api/v1/jobs?sort=-_created

200 OK

{
    "_items": [
        {
            "_created": "Mon, 24 Aug 2020 01:59:18 GMT",
            "_etag": "7a47976781bcbd0e5ad4936253dc6ffacc98ca86",
            "_id": "5f431ef6a7690b60975f6664",
            "_links": {
                "related": {
                    "backupdef": {
                        "href": "/v1/kubebackups/5f7721cb44b03575ec17a5af",
                        "title": "Kubebackup"
                    },
                    "cluster": {
                        "href": "/v1/kubeclusters/5f77218d44b03575ec17a5ae",
                        "title": "Kubecluster"
                    }
                },
                "self": {
                    "href": "/v1/jobs/5f431ef6a7690b60975f6664",
                    "title": "Job"
                }
            },
            "_updated": "Mon, 24 Aug 2020 01:59:29 GMT",
            "activity": [
                "Initiating backup process",
                "Backing up resources"
            ],
            "backupdef": "5f7721cb44b03575ec17a5af",
            "backupdef_name": "testbackup",
            "cluster": "5f77218d44b03575ec17a5ae",
            "cluster_name": "testcluster",
            "end_time": 1598234368,
            "message": "Backup Successful",
            "name": "kubecluster-1598234357",
            "num_backup_resources": 377,
            "num_total_resources": 377,
            "start_time": 1598234357,
            "state": "COMPLETED"
            "kube_copy_progress": {
                "stats": {
                    "estimated_size": 10,
                    "estimated_number_of_files": 10,
                    "io_size": 10,
                    "io_number_of_files": 10,
                    "transferred_size": 10,
                    "transferred_number_of_files": 10
                },
                "total_pvs": 10,
                "pending_pvs": 10,
                "active_pvs": 10,
                "completed_pvs": 10,
                "failed_pvs": 10
            },
            "kube_snapshot_progress": {
                "total_pvs": 10,
                "pending_pvs": 10,
                "active_pvs": 10,
                "completed_pvs": 10,
                "failed_pvs": 10,
                "skipped_pvs": 10
            },
        }
    ],
    "_links": {
        "parent": {
            "href": "/",
            "title": "home"
        },
        "self": {
            "href": "v1/jobs?sort=-_created",
            "title": "/v1/jobs"
        }
    },
    "_meta": {
        "max_results": 25,
        "page": 1,
        "total": 1
    }
}

Apart from the standard properties such as name, the following custom properties are present in the jobs resource:

start_time

Integer. Start time of the job expressed as number of seconds elapsed since January 1, 1970 UTC.

end_time

Integer. End time of the job expressed as number of seconds elapsed since January 1, 1970 UTC.

state

String. Represents the current state of the job.

Possible values are:

  • UNKNOWN

  • PENDING

  • RUNNING

  • COMPLETED

  • FAILED

  • SKIPPED

  • PARTIAL

message

String. A description of current status of the job including any error or warning.

num_total_resources

Integer. Number of total resources that are available for backup.

num_backup_resources

Integer. Number of resources backed up so far.

cluster

String. ID of the Kubernetes cluster associated with the job.

cluster_name

String. Name of the Kubernetes cluster associated with the job.

backupdef

String. ID of the KubeBackup resource associated with the job.

backupdef_name

String. Name of the KubeBackup resource associated with the job.

restoredef_name

String. Name of the KubeRestore resource associated with the job.

securityscan_name

String. Name of the securityscan resource associated with the job.

activity

List of strings. Indicates the job progress.

type

String. Represents the type of the job.

Possible values are:

  • K8S_SNAP

  • RESTORE

  • K8S_COPY

  • DELETE_BACKUP

  • AWS_INVENTORY

  • AWSRDS_BACKUP

  • AWSRDS_RESTORE

  • AWSRDS_BACKUP_DELETE

  • AWSRDS_COPY

  • AWSEKS_RESTORE

  • SECURITY_SCAN

kube_copy_progress

Aggregated/Summary of persistent volumes involved in the copy operation. This field will be updated when there are persistent volumes for whom data transfer (COPY) operation was undertaken as part of this job. In a COPY job, this field will carry a value only when the COPY phase is started. This field will not carry valid values when the SNAPSHOT phase of the COPY job is in progress. “io” in fields “io_size” and “io_number_of_files” should be interpreted as “READ” for COPY operation and “WRITE” for RESTORE operation. We may seprate these as two fields in the future. All sizes are in bytes.

kube_snapshot_progress

Aggregated/Summary of persistent volumes involved in the snapshot operation. This field will be updated when there are persistent volumes for whom CSI or storage snapshots were taken. In case of a COPY job, although this field will be present, it will not be updated further when the COPY i.e data transfer phase shall commence.

Reporting PVC progress

Data transfer progress and snapshot progress updates related to Persistent Volumes involved in a BACKUP/COPY/RESTORE job can be obtained by sending a GET request with an empty body.

GET /api/v1/kubepvcprogress?where={"job_id":"5f431ef6a7690b60975f6664"}

HTTP/1.1 200 OK

[
{
    "_id": "60b761c8ce3d70a3e664eb83",
    "name": "csi-pvc",
    "namespace": "test-csi-snapshot",
    "job_id": "60b76183a8c4c6a35a28dbdf",
    "state": "COMPLETED",
    "start_time": 1622630856,
    "end_time": 1622630856,
    "message": "Data Transfer Successful",
    "op_type": "K8S_COPY",
    "snapshot_progress_percentage": 100,
    "stats": {
                    "estimated_size": 10,
                    "estimated_number_of_files": 10,
                    "io_size": 10,
                    "io_number_of_files": 10,
                    "transferred_size": 10,
                    "transferred_number_of_files": 10
    },
    "_updated": "Wed, 02 Jun 2021 10:47:36 GMT",
    "_created": "Wed, 02 Jun 2021 10:47:36 GMT",
    "_etag": "be5df26661723c5d539aa8c0a026021a41dd5a2d",
    "_links": {
        "self": {
            "title": "Kubepvcprogre",
            "href": "/v1/kubepvcprogress/60b761c8ce3d70a3e664eb83"
        },
        "related": {
            "job_id": {
                "title": "Job",
                "href": "/v1/jobs/60b76183a8c4c6a35a28dbdf"
            }
        }
    }
}
]

Apart from the standard properties such as _id, the following custom properties are present in the kubepvcprogress resource:

name

String. Name of PVC

namespace

String. Namespace of PVC

job_id

String. ID of the job this resource is associated with.

state

String. Current state/result of data transfer. Possible values are:

  • “PENDING” - PVC enqueued for snapshot operation

  • “ACTIVE” - Persistent volume snapshot in progress

  • “COMPLETED” - Snapshot complete

  • “FAILED” - Snasphot failed to complete

  • “SKIPPED-MISSING-VOLUME-FROM-INVENTORY” - EBS volumes could not be found in AWS inventory within Cloudcasa

  • “SKIPPED-MISSING-ACCOUNT” - EBS volumes do not have an associated AWS account within Cloudcasa

  • “SKIPPED-ACCOUNT-INACTIVE” - AWS account related to this EBS Volume in Cloudcasa is not in ACTIVE state

  • “SKIPPED-VOLUME-FROM-OTHER-REGION” - EBS Volume belongs to other region. EBS Volume Snapshot from a single region is supported

message

String. Human readable message in case of success/failure.

start_time

Integer. Start time of the data transfer for this PVC expressed as number of seconds

end_time

Integer. End time of the data transfer for this PVC expressed as number of seconds

stats

Current statistics for data transfer for this PVC. This field has no significance if “snapshot_type” field is set to “K8S_SNAP”

op_type

String. Type of snapshot operation performed on this PVC. The possible values are “K8S_COPY” for COPY snapshot or “K8S_SNAP” for snapshot operation. For kubepvcprogress resources created by jobs prior to this feature introduction, this value will either not exist, or the value will be “”. Hence, for backward compatibility, the client should check if this field exists. If the field exists and the value is “K8S_SNAP”, then this resource represents a PVC whose snapshot is taken. If this field does not exist, or its value is “”, consider this resource represents a PVC whose COPY operation is being done.

snapshot_progress_percentage

Integer. If “snapshot_type” field is set to “K8S_SNAP”, then this field contains the value of the snapshot progress in terms of percentage. At present, this progress is available only for snapshots from storage provider. Progress is not available for snapshots taken using CSI driver.

Cancelling a job

Running job can be canceled by sending a POST request with an empty body.

POST /api/v1/jobs/<ID>/action/cancel

Note

Right now, only cancellation of an K8S_SNAP and K8S_COPY job is supported. The operation will fail if the job is not in RUNNING state.