aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
235 stars 78 forks source link

Unwanted output from Read-GLCJobOutput when vault inventory is In Progress #187

Closed bpevandro closed 2 years ago

bpevandro commented 3 years ago

Description

When reading a Glacier vault inventory that has not yet been completed, the CLI outputs errors:

PS C:\Users\Administrator> Read-GLCJobOutput  -VaultName <vault-name> -JobId <job-id> -FilePath "C:\tmp\output2.json" -AccountId <account-id>
Error and going to retry: The job is not currently available for download: 9OLdalI_Bgc90a8MuyAwbF5Z6g3vknyJ8LZhN70Tj46gS0bM1xBhXRNzZcFym0KJz-SUnvW5z_Q91dBI-10hOwisEQjr
   at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, Http
ErrorResponseException exception)
   at Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext executionContext, Exception exception)
   at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

However no error is thrown if the inventory is already completed.

Reproduction Steps

  1. Install AWS.Tools.Glacier 4.1.7.0
  2. Start the job: Start-GLCJob -VaultName <vault-name> -JobType inventory-retrieval
  3. Try and read the job immediately after:
    Read-GLCJobOutput  -VaultName <vault-name> -JobId <job-id> -FilePath "C:\tmp\output2.json" -AccountId <account-id>

Logs

Error and going to retry: The job is not currently available for download: 9OLdalI_Bgc90a8MuyAwbF5Z6g3vknyJ8LZhN70Tj46gS0bM1xBhXRNzZcFym0KJz-SUnvW5z_Q91dBI-10hOwisEQjr
   at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, Http
ErrorResponseException exception)
   at Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext executionContext, Exception exception)
   at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Amazon.Runtime.Internal.EndpointDiscoveryHandler.<InvokeAsync>d__2`1.MoveNext()      
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Amazon.Runtime.Internal.MetricsHandler.<InvokeAsync>d__1`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Amazon.Glacier.Transfer.Internal.DownloadJobCommand.<ExecuteAsync>d__7.MoveNext()
Error and going to retry: The job is not currently available for download: 9OLdalI_Bgc90a8MuyAwbF5Z6g3vknyJ8LZhN70Tj46gS0bM1xBhXRNzZcFym0KJz-SUnvW5z_Q91dBI-10hOwisEQjr
   at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, HttpErrorResponseException exception)

Environment

This is a :bug: bug-report

ashishdhingra commented 3 years ago

Hi @bpevandro,

Good morning.

I'm not sure if I understand the problem. This is the error is returned by the service and PowerShell CmdLet simply returns it in the output. Do you see the similar error via AWS CLI?

Thanks, Ashish

ppittle commented 3 years ago

Think this behavior should be reviewed; we should provide a nicer experience when Read-GLCJobOutput can't complete because the Job is still in progress.

bpevandro commented 3 years ago

100% agree with @ppittle, this is not the service's API response, this is how Read-GLCJobOutput is handling it. No reason to print the stack trace at all.

normj commented 3 years ago

Adding a bit more context. Unlike most of the other PowerShell cmdlets the Read-GLCOutput is not generated and actually uses the AWS .NET SDK high level library ArchiveTransferManager. Since it is handcoded that gives us hooks to handle how the service returns back a non 200 status code when requesting to read a job that isn't complete.

github-actions[bot] commented 2 years ago

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.