Config as code: Clone timeout

If a repo takes more than 100s to clone, it times out.

Here’s the full error message from the logs:

2022-07-18 16:25:19.8423   3632    258  INFO  "Failed to clone repository: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.

Inner Exception:
    The operation was canceled.

    Inner Exception:
        The operation was canceled.

        Inner Exception:
            Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..

            Inner Exception:
                The I/O operation has been aborted because of either a thread exit or an application request."
Octopus.Core.Model.Exceptions.DomainException: Failed to clone repository: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.

Inner Exception:
    The operation was canceled.

    Inner Exception:
        The operation was canceled.

        Inner Exception:
            Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..

            Inner Exception:
                The I/O operation has been aborted because of either a thread exit or an application request.
 ---> LibGit2Sharp.LibGit2SharpException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.

Inner Exception:
    The operation was canceled.

    Inner Exception:
        The operation was canceled.

        Inner Exception:
            Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..

            Inner Exception:
                The I/O operation has been aborted because of either a thread exit or an application request.
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)
   at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)
   at Octopus.Core.Git.Repositories.RepositoryRoot.<>c__DisplayClass36_0.<CreateAndCloneRepository>b__1(TransferProgressHandler progressHandler) in ./source/Octopus.Core/Git/Repositories/RepositoryRoot.cs:line 475
   at Octopus.Core.Git.GitSpaceLimit.DoOperationWithProgressHandler(Action`1 operation, Func`1 onUserCancelledOperation) in ./source/Octopus.Core/Git/GitSpaceLimit.cs:line 81
   at Octopus.Core.Git.Repositories.RepositoryRoot.<>c__DisplayClass36_0.<CreateAndCloneRepository>b__0() in ./source/Octopus.Core/Git/Repositories/RepositoryRoot.cs:line 463
   --- End of inner exception stack trace ---
   at Octopus.Core.Git.Repositories.RepositoryRoot.<>c__DisplayClass36_0.<CreateAndCloneRepository>b__0() in ./source/Octopus.Core/Git/Repositories/RepositoryRoot.cs:line 481
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Octopus.Core.Git.Repositories.RepositoryRoot.CreateAndCloneRepository(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/RepositoryRoot.cs:line 447
   at Octopus.Core.Tasks.AsyncLazy`1.Value(CancellationToken cancellationToken) in ./source/Octopus.Core/Tasks/AsyncLazy.cs:line 38
   at Octopus.Core.Git.Repositories.RepositoryRoot.EnsureRepositoryIsCurrent(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/RepositoryRoot.cs:line 325
   at Octopus.Core.Git.Repositories.ErrorHandlingRepositoryRootDecorator.<EnsureRepositoryIsCurrent>b__17_0(CancellationToken ct) in ./source/Octopus.Core/Git/Repositories/ErrorHandlingRepositoryRootDecorator.cs:line 69
   at Octopus.Core.Git.Repositories.ErrorHandlingRepositoryRootDecorator.HandleLibGit2SharpExceptions(Func`2 action, String defaultErrorMessage, CancellationToken cancellationToken, List`1 statusErrorList) in ./source/Octopus.Core/Git/Repositories/ErrorHandlingRepositoryRootDecorator.cs:line 118
   at Octopus.Core.Git.Repositories.ErrorHandlingRepositoryRootDecorator.EnsureRepositoryIsCurrent(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/ErrorHandlingRepositoryRootDecorator.cs:line 73
   at Octopus.Core.Git.Repositories.FileSystemLoggingRepositoryRootDecorator.EnsureRepositoryIsCurrent(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/FileSystemLoggingRepositoryRootDecorator.cs:line 85
   at Octopus.Core.Git.Repositories.SpaceLimitRepositoryRootDecorator.EnsureRepositoryIsCurrent(CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/SpaceLimitRepositoryRootDecorator.cs:line 69
   at Octopus.Core.Git.Repositories.GitRepository.PrepareWorkTree(GitRef gitRef, CancellationToken cancellationToken) in ./source/Octopus.Core/Git/Repositories/GitRepository.cs:line 144
   at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task`1 task)
   at Octopus.Core.Persistence.Git.GitTransactionFactory.BeginOrAdoptExisting() in ./source/Octopus.Core/Persistence/Git/GitTransactionFactory.cs:line 75
   at Autofac.Builder.RegistrationBuilder.<>c__DisplayClass0_0`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p)
   at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget)

For now, I’m working around this problem by keeping my Octopus config in a separate repo, but I would prefer to version it with the rest of my code.

Hi @borigas,

Thanks for reaching out and for all of the information.

How many branches do you have in the repo where it wasn’t working vs the one where it is?

We currently have a known performance problem when a repo has a large number of branches and it’s on our radar and is being worked on.

Please let me know!

Best,
Jeremy

There is a large number of branches, but I think this may be a separate issue. The repo is fairly large. I think it’s timing out during the download portion of the clone. 100s is the default timeout of HttpClient, but I know a fresh clone of our repo takes more than 100s

Thanks for the update. I’ll pass this feedback along to our Config as Code team. I’ll let you know if they have any other questions. They’re based in Australia so there might be some delay on the response.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.