Skip to content

Commit

Permalink
Merge pull request #372 from fluxcd/git-timeout
Browse files Browse the repository at this point in the history
Reinstate Git cloning timeout
  • Loading branch information
stefanprodan authored Jun 2, 2021
2 parents 4087834 + b8128cf commit bfd7247
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controllers/gitrepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,15 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, repository sour
if err != nil {
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
}
commit, revision, err := checkoutStrategy.Checkout(ctx, tmpGit, repository.Spec.URL, auth)

gitCtx, cancel := context.WithTimeout(ctx, repository.Spec.Timeout.Duration)
defer cancel()

commit, revision, err := checkoutStrategy.Checkout(gitCtx, tmpGit, repository.Spec.URL, auth)
if err != nil {
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
}

artifact := r.Storage.NewArtifactFor(repository.Kind, repository.GetObjectMeta(), revision, fmt.Sprintf("%s.tar.gz", commit.Hash()))

// copy all included repository into the artifact
Expand Down

0 comments on commit bfd7247

Please sign in to comment.