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 c7522cc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/openstackconfigversion/git_util.go
Expand Up @@ -30,6 +30,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 +153,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 && err == transport.ErrEmptyUploadPackRequest {

Check failure on line 159 in pkg/openstackconfigversion/git_util.go

View workflow job for this annotation

GitHub Actions / github (golangci)

comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
log.Info(fmt.Sprintf("set capability.ThinPack transport capability, required for Azure DevOps."))

Check failure on line 160 in pkg/openstackconfigversion/git_util.go

View workflow job for this annotation

GitHub Actions / github (golangci)

S1039: unnecessary use of fmt.Sprintf (gosimple)
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 c7522cc

Please sign in to comment.