Skip to content

Commit

Permalink
Merge pull request #892 from openshift-cherrypick-robot/cherry-pick-8…
Browse files Browse the repository at this point in the history
…91-to-v1.3.x

[v1.3.x] Retry for Azure GitOps with capability.ThinPack
  • Loading branch information
openshift-merge-robot authored Aug 4, 2023
2 parents 016d4a5 + 01fc4ac commit 415c31f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/openstackconfigversion/git_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package openstackconfigversion
import (
"bytes"
"context"
"errors"
"fmt"
"regexp"
"strings"
Expand All @@ -30,6 +31,7 @@ import (
git "github.com/go-git/go-git/v5"
config "github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing/format/diff"
"github.com/go-git/go-git/v5/plumbing/protocol/packp/capability"
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/go-git/go-git/v5/storage/memory"
Expand Down Expand Up @@ -152,6 +154,21 @@ func SyncGit(
URL: gitURL,
Auth: publicKeys,
})
// if Azure DevOps is used it can fail with as azure is not compatible to go-git, https://github.com/go-git/go-git/pull/613
// "2023-08-04T13:16:19.264Z INFO controllers.OpenStackConfigGenerator Failed to create Git repo: empty git-upload-pack given"
// retry with workaround setting capability.ThinPack
if err != nil && errors.Is(err, transport.ErrEmptyUploadPackRequest) {
log.Info(fmt.Sprintf("Failed to create Git repo: %s\n", err.Error()))
log.Info("retrying with capability.ThinPack transport capability, required for Azure DevOps")
transport.UnsupportedCapabilities = []capability.Capability{
capability.ThinPack,
}

repo, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: gitURL,
Auth: publicKeys,
})
}
// Failed to create Git repo: URL field is required
if err != nil {
log.Info(fmt.Sprintf("Failed to create Git repo: %s\n", err.Error()))
Expand Down

0 comments on commit 415c31f

Please sign in to comment.