Skip to content

Commit bfd7247

Browse files
authored
Merge pull request #372 from fluxcd/git-timeout
Reinstate Git cloning timeout
2 parents 4087834 + b8128cf commit bfd7247

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

controllers/gitrepository_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,15 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, repository sour
272272
if err != nil {
273273
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
274274
}
275-
commit, revision, err := checkoutStrategy.Checkout(ctx, tmpGit, repository.Spec.URL, auth)
275+
276+
gitCtx, cancel := context.WithTimeout(ctx, repository.Spec.Timeout.Duration)
277+
defer cancel()
278+
279+
commit, revision, err := checkoutStrategy.Checkout(gitCtx, tmpGit, repository.Spec.URL, auth)
276280
if err != nil {
277281
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
278282
}
283+
279284
artifact := r.Storage.NewArtifactFor(repository.Kind, repository.GetObjectMeta(), revision, fmt.Sprintf("%s.tar.gz", commit.Hash()))
280285

281286
// copy all included repository into the artifact

0 commit comments

Comments
 (0)