PowerCLI command times out after 5 minutes resulting in 'task canceled'.
search cancel

PowerCLI command times out after 5 minutes resulting in 'task canceled'.

book

Article ID: 325785

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

PowerCLI commands like Get-ContentLibrary and Get-ContentLibraryItem do not succeed resulting in error: 'A task was canceled'.
  • OVF deployment through PowerCLI succeeds at vCenter end but fails at PowerCLI end.
Severity : Error
TargetSite :
Message : New-VM A task was canceled.
Data : {[ParameterValues, VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.CmdletParametersDictionary]}
InnerException : System.Threading.Tasks.TaskCanceledException: A task was canceled.
      at System.Threading.Tasks.Task.GetExceptions(Boolean includeTaskCanceledExceptions)
      at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
      at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
      at vmware.vapi.bindings.Stub.InvokeMethod[R](MethodIdentifier methodId, StructValueBuilder
      structValueBuilder, StructType inputType, IType outputType, IEnumerable`1 errorTypes, InvocationConfig
         invocationConfig, Action`1 progressHandle)
         at vmware.vcenter.ovf.LibraryItemStub.Deploy(String clientToken, String ovfLibraryItemId,
         DeploymentTarget target, ResourcePoolDeploymentSpec deploymentSpec, Action`1 _progress, InvocationConfig
         _invocationConfig)
         at vmware.vcenter.ovf.LibraryItemStub.Deploy(String clientToken, String ovfLibraryItemId,
         DeploymentTarget target, ResourcePoolDeploymentSpec deploymentSpec)
         at VMware.VimAutomation.ViCore.Impl.V1.Service.VmServiceImpl.<>c__DisplayClass35_0.<DeployFromLibraryItem>b__0(ClientSideTask task, Object taskResult)
         at VMware.VimAutomation.Sdk.Util10.Task.ClientSideTaskImpl.ThreadProc(Object obj)
         at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback
         callback, Object state)
         --- End of stack trace from previous location ---
  • Still, the task succeeds on the vCenter.
  • No errors logged in content-library logs.
  • Manual deployment of VMs work fine.
  • Deploying OVF through content-library also succeeds.



Environment

VMware vCenter Server 6.5.x
VMware vCenter Server 6.7.x
VMware vCenter Server 6.0.x
VMware vCenter Server 7.0.x
VMware vCenter Server 8.0.x

Cause

PowerCLI is configured to timeout if a server operation takes more than 5 minutes. Hence, VM deployments fail at PowerCLI end as the deployment process takes more than 5 minutes.

Resolution

Increase the web operation timeout setting to an appropriate value.
Set-PowerCLIConfiguration -WebOperationTimeoutSeconds 600
The above command sets the timeout to 10 minutes.

In order to wait for the server response indefinitely, the timeout could be increased to infinity.
 
Set-PowerCLIConfiguration -WebOperationTimeoutSeconds -1 
This command will make PowerCLI wait indefinitely (no timeout error will be produced).

Please Note: If using a PowerCLI script, the script may "hang" if the server does not return a response if the timeout is set to infinity.

Additional Information