Work Requests Queries

Summary

After attempting to launch a compute instance, I need to know why the launch failed.

References

List Work Requests

The oci work-requests work-request list command can return either tabular or JSON output. The tabular output can be easier to scan, while the JSON format displays all fields.

Create Table of Work Requests

To create a table with selected fields of work requests in the Sandbox compartment, run the following commands:

export sandbox_ocid=$(              \
    oci iam compartment list        \
        --name        'Sandbox'     \
        --query       'data[0].id'  \
        --raw-output                \
    )
oci work-requests work-request list     \
    --compartment-id ${sandbox_ocid}    \
    --query 'data[*].{"Operation":"operation-type","Status":status,"Time Finished":"time-finished","% Complete":"percent-complete"}' \
    --output table

Sample output is:

+------------+----------------------------+-----------+----------------------------------+
| % Complete | Operation                  | Status    | Time Finished                    |
+------------+----------------------------+-----------+----------------------------------+
| 5.0        | LaunchInstance             | FAILED    | 2024-06-15T20:38:02.073000+00:00 |
| 100.0      | Delete Autonomous Database | SUCCEEDED | 2024-06-08T18:29:39.992000+00:00 |
| 100.0      | Delete Autonomous Database | SUCCEEDED | 2024-06-08T18:11:33.030000+00:00 |
| 100.0      | Create Autonomous Database | SUCCEEDED | 2024-06-02T23:42:22.860000+00:00 |
| 100.0      | Create Autonomous Database | SUCCEEDED | 2024-06-02T16:37:30.793000+00:00 |
+------------+----------------------------+-----------+----------------------------------+

Note: FAILED work requests are deleted after some time by OCI (within 24 hours). SUCCEEDED work requests are retained.

Create JSON File of Work Requests

To create a JSON file with all fields for all work requests in the Sandbox compartment, run the following commands:

export sandbox_ocid=$(              \
    oci iam compartment list        \
        --name        'Sandbox'     \
        --query       'data[0].id'  \
        --raw-output                \
    )
oci work-requests work-request list     \
    --compartment-id ${sandbox_ocid}    \
    >all-work-requests.json

The output file has been uploaded as all-work-requests.json.

Get Work Request Error

Once a FAILED work request has been identified (see above for an example), the oci work-requests work-request-error list command is used to return results as either a table or a JSON file.

Create Table of Work Request Errors

To create a table of the errors from the latest work request in the Sandbox compartment, run the following commands:

export sandbox_ocid=$(              \
    oci iam compartment list        \
        --name        'Sandbox'     \
        --query       'data[0].id'  \
        --raw-output                \
    )
export work_req_ocid=$(                     \
    oci work-requests work-request list     \
    --compartment-id ${sandbox_ocid}        \
    --query 'data[0].id'                    \
    --raw-output                            \
    )
oci work-requests work-request-error list                               \
    --work-request-id ${work_req_ocid}                                  \
    --all                                                               \
    --query 'data[*].{code:code,message:message,timestamp:timestamp}'   \
    --output table

Sample output is:

+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+
| code      | message                                                                                                                                                                                                                                                                                        | timestamp                        |
+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+
| vcn-error | A problem occurred while preparing the instance's VNIC.  ((400, InvalidParameter, false) Cannot create a VNIC with hostnameLabel. Subnet ocid1.subnet.oc1.ap-sydney-1.aaaaaaaabfb6tyssv2t4dxci5mhymomqmrhwdq2nmagdtezfp4ifmbca7c5q does not have DNS enabled (opc-request-id: dummyRequestId)) | 2024-06-15T20:37:54.813000+00:00 |
+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+

Create JSON File of Work Request Errors

To create a JSON file of the errors from the latest work request in the Sandbox compartment, run the following commands:

export sandbox_ocid=$(              \
    oci iam compartment list        \
        --name        'Sandbox'     \
        --query       'data[0].id'  \
        --raw-output                \
    )
export work_req_ocid=$( \
    oci work-requests work-request list     \
    --compartment-id ${sandbox_ocid}    \
    --query 'data[0].id' \
    --raw-output \
    )
oci work-requests work-request-error list   \
    --work-request-id ${work_req_ocid}      \
    >failed_work_req_err.json 

The file is uploaded as failed_work_req_err.json.