Esempio n. 1
0
        /// <summary>
        /// Runs the container. Returns the merged contents of stdout/stderr.
        /// </summary>
        private async Task <ProcessResult> RunContainerAsync(
            string containerName,
            IDictionary <string, string> environmentVariables)
        {
            var dockerArgs = GetDockerArguments(containerName, environmentVariables);

            var processResult = await _processRunner.RunProcessAsync
                                (
                _hostConfig.DockerLibraryPath,
                dockerArgs,
                _containerConfig.MaxLifetime
                                );

            await Task.Delay(c_waitForProcessExitDelay);

            if (!processResult.Completed)
            {
                await _operationRunner.RetryOperationIfNeededAsync
                (
                    async() => await _processRunner.RunProcessAsync
                    (
                        _hostConfig.DockerLibraryPath,
                        new[] { $"rm -f {containerName}" },
                        timeout: null
                    ),
                    exception => true,
                    c_killDockerContainerRetryAttempts,
                    c_retryAttemptDelay,
                    defaultResultIfFailed : false
                );
            }

            return(processResult);
        }
Esempio n. 2
0
 /// <summary>
 /// Executes an operation, retrying the operation if an optimistic
 /// concurrency exception is encountered.
 /// </summary>
 private Task RetryOperationIfNeededAsync(
     Func <Task> operation)
 {
     return(_operationRunner.RetryOperationIfNeededAsync
            (
                operation,
                ex => ex is DbUpdateConcurrencyException,
                c_numAttempts,
                c_delayBetweenAttempts,
                defaultResultIfFailed: false
            ));
 }
 /// <summary>
 /// Executes a GitHub operation, retrying the operation if it
 /// fails with an ApiException.
 /// </summary>
 private async Task <TResult> RetryGitHubOperationIfNeededAsync <TResult>(
     Func <Task <TResult> > operation)
 {
     return(await _operationRunner.RetryOperationIfNeededAsync
            (
                operation,
                ex => ex is ApiException,
                c_numAttempts,
                c_delayBetweenAttempts,
                defaultResultIfFailed : false
            ));
 }