Skip to content

Commit

Permalink
Retry for Azure GitOps with capability.ThinPack
Browse files Browse the repository at this point in the history
More info in go-git/go-git#613 .
  • Loading branch information
stuggi committed Aug 4, 2023
1 parent 906f3e9 commit 67e00a3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/openstackconfigversion/git_util.go
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,20 @@ 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("hit error %s, retrying with capability.ThinPack transport capability, required for Azure DevOps", err.Error()))
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 67e00a3

Please sign in to comment.