Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAS request error for blob upload cannot be handled #2614

Closed
opekhovskiy-zf opened this issue Apr 29, 2024 · 3 comments
Closed

SAS request error for blob upload cannot be handled #2614

opekhovskiy-zf opened this issue Apr 29, 2024 · 3 comments
Assignees
Labels

Comments

@opekhovskiy-zf
Copy link

opekhovskiy-zf commented Apr 29, 2024

Development Machine, OS, Compiler (and Other Relevant Toolchain Info)

Ubuntu 22.04.1 LTS
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

SDK Version

1.11.0
Commit SHA: 97fef57
Release 2023-08-07

Protocol

MQTT

Describe the Bug

There is no way to get error status on SAS request for blob upload.

So when we call IoTHubDeviceClient_UploadMultipleBlocksToBlobAsync, it invokes the following chain:
IoTHubDeviceClient_UploadMultipleBlocksToBlobAsync
IoTHubClientCore_UploadMultipleBlocksToBlobAsync
startHttpWorkerThread
ThreadAPI_Create [here we lose error returned by uploadMultipleBlock_thread]
uploadMultipleBlock_thread [int, IOTHUB_CLIENT_ERROR]
IoTHubClientCore_LL_UploadMultipleBlocksToBlobEx [IOTHUB_CLIENT_RESULT, IOTHUB_CLIENT_ERROR]
IoTHubClient_LL_UploadToBlob_InitializeUpload [IOTHUB_CLIENT_RESULT, IOTHUB_CLIENT_ERROR]
IoTHubClient_LL_UploadToBlob_GetBlobCredentialsFromIoTHub [int, MU_FAILURE]
send_http_sas_request [int, MU_FAILURE]
HTTPAPIEX_SAS_ExecuteRequest

SAS request is asynchronous, so we cannot get result immediately. And we never call IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX with this error.
So right now the calling routine waits forever.

Moreover even synchronous call doesn't return an error because invocation of ThreadAPI_Join (that returns exit code of a thread function) just passes unused variable for return code, e.g. in the following chain.
IoTHubDeviceClient_Destroy
IoTHubClientCore_Destroy

Seems like the best way to inform the caller routine about the error is to invocate IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX (and IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK)
function and pass the error through IOTHUB_CLIENT_FILE_UPLOAD_RESULT result parameter.

@ewertons ewertons self-assigned this May 6, 2024
@ewertons ewertons added the bug label May 6, 2024
@ewertons
Copy link
Contributor

ewertons commented May 6, 2024

Hi @opekhovskiy-zf you are correct, we apologize for that error.
This issue is somehow related to #2569, and a fix for both is being worked on.

@ewertons
Copy link
Contributor

ewertons commented May 6, 2024

Indeed the branch with the proposed fix is here: https://github.com/Azure/azure-iot-sdk-c/tree/ewertons/FixThreadedUploadToBlob

In summary, we are trapping both the return code from IoTHubClientCore_LL_UploadMultipleBlocksToBlobEx and callback result (if invoked) and firing the IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX from uploadMultipleBlock_thread after calling IoTHubClientCore_LL_UploadMultipleBlocksToBlobEx with the composite result. Would you be able to validate this branch as well before we move to merge it?

@ewertons
Copy link
Contributor

A change has been merged to address this issue. Please feel free to reopen this case if you would like to follow up.
Thanks,
Azure IoT SDKs Team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants