Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.

Commit 0ff8a90

Browse files
Ram-srinimanojgop
authored andcommitted
Bug fix for the jira id TCFH-701
TCFH-701 - Passing invalid WorkloadID into Work order Submit API returns an error "Work Order is Computing" Signed-off-by: Ramakrishna Srinivasamurthy <[email protected]>
1 parent 59cc2bf commit 0ff8a90

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
lines changed

common/cpp/error.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ namespace tcf {
123123
) : Error(TCF_ERR_SYSTEM_BUSY, msg) {}
124124
}; // class SystemBusyError
125125

126+
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
127+
class WorkloadError : public Error {
128+
public:
129+
explicit WorkloadError(
130+
const std::string& msg
131+
) : Error(TCF_ERR_INVALID_WORKLOAD, msg) {}
132+
}; // class WorkloadError
133+
126134
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
127135
class UnknownError : public Error {
128136
public:

common/cpp/tcf_error.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ typedef enum {
2828
TCF_ERR_OVERFLOW = -7,
2929
TCF_ERR_VALUE = -8,
3030
TCF_ERR_SYSTEM = -9,
31-
TCF_ERR_CRYPTO = -11,
32-
TCF_ERR_SYSTEM_BUSY = -10 /*
31+
TCF_ERR_SYSTEM_BUSY = -10, /*
3332
Indicates that the system is busy and
3433
the operation may be retried again. If
3534
retries fail this should be converted to
3635
a TCF_ERR_SYSTEM for reporting.
3736
*/
37+
TCF_ERR_CRYPTO = -11,
38+
TCF_ERR_INVALID_WORKLOAD = -12 /* Invalid workload id */
3839
} tcf_err_t;
3940

4041
typedef enum {

common/python/error_code/enclave_error.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ class EnclaveError(IntEnum):
2929
ENCLAVE_ERR_SYSTEM = -9,
3030
ENCLAVE_ERR_CRYPTO = -11,
3131
ENCLAVE_ERR_SYSTEM_BUSY = -10
32+
ENCLAVE_ERR_INVALID_WORKLOAD = -12

common/python/error_code/error_status.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class WorkOrderStatus(IntEnum):
3232
SCHEDULED = 6
3333
PROCESSING = 7
3434
BUSY = 8
35-
UNKNOWN_ERROR = 9
35+
INVALID_WORKLOAD = 9
36+
UNKNOWN_ERROR = 10
3637

3738

3839
@unique

listener/avalon_listener/tcs_work_order_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def WorkOrderGetResult(self, **params):
136136
WorkOrderStatus.INVALID_PARAMETER_FORMAT_OR_VALUE
137137
elif err_code == EnclaveError.ENCLAVE_ERR_UNKNOWN:
138138
err_code = WorkOrderStatus.UNKNOWN_ERROR
139+
elif err_code == EnclaveError.ENCLAVE_ERR_INVALID_WORKLOAD:
140+
err_code = WorkOrderStatus.INVALID_WORKLOAD
139141
else:
140142
err_code = WorkOrderStatus.FAILED
141143
raise JSONRPCDispatchException(err_code, err_msg)

tc/sgx/trusted_worker_manager/enclave/work_order_processor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ namespace tcf {
260260
std::string workload_type(workload_bytes.begin(), workload_bytes.end());
261261
WorkloadProcessor *processor =
262262
WorkloadProcessor::CreateWorkloadProcessor(workload_type);
263-
tcf::error::ThrowIfNull(processor, "CreateWorkloadProcessor function returned null");
263+
tcf::error::ThrowIf<tcf::error::WorkloadError>(
264+
processor == nullptr, "Invalid workload id");
264265
processor->ProcessWorkOrder(
265266
workload_type,
266267
StrToByteArray(requester_id),

0 commit comments

Comments
 (0)