Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Git operations and introduce go-git support for Azure DevOps and AWS CodeCommit #944

Merged
merged 6 commits into from
Oct 31, 2022

Conversation

pjbgf
Copy link
Member

@pjbgf pjbgf commented Oct 26, 2022

Changes of note:

  • Refactor reconciler to use fluxcd/pkg/git.
  • Bump golang-with-libgit2 to v0.4.0 which bumps libgit2 to 1.5.
  • Update to fluxcd/go-git to support multi_ack and multi_ack_detailed, enabling support to Azure DevOps when using go-git.

Relates to fluxcd/pkg#245

aryan9600 and others added 5 commits October 26, 2022 14:04
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
The new version uses libgit2 1.5.0 and requires git2go/v34.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
@pjbgf pjbgf added the area/git Git related issues and pull requests label Oct 26, 2022
@pjbgf pjbgf added this to the GA milestone Oct 26, 2022
Comment on lines +43 to +44
github.com/fluxcd/pkg/git/gogit v0.0.0-20221026111216-11a3405b2580
github.com/fluxcd/pkg/git/libgit2 v0.0.0-20221026111216-11a3405b2580
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking on keeping commit pinned, as there may be some follow-up changes. But then we tag and update them soon before releasing this version. Any thoughts on the approach?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we tag them before the next SC release, I'm Ok with it.

Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @pjbgf and @aryan9600 for all the hard work on the Git refactoring 🥇

@stefanprodan stefanprodan changed the title Git refactoring changes Refactor Git operations and introduce go-git support for Azure DevOps and AWS CodeCommit Oct 27, 2022
@pjbgf
Copy link
Member Author

pjbgf commented Oct 27, 2022

Waiting for @darkowlzz's review before merging it.

@pjbgf pjbgf requested a review from darkowlzz October 27, 2022 10:58
@pjbgf
Copy link
Member Author

pjbgf commented Oct 27, 2022

Users keen on testing source-controller with the git-refactoring changes can use the image:
ghcr.io/fluxcd/source-controller:rc-6b04907f.

go.mod Outdated Show resolved Hide resolved
controllers/gitrepository_controller.go Outdated Show resolved Hide resolved
controllers/gitrepository_controller.go Outdated Show resolved Hide resolved
controllers/gitrepository_controller.go Show resolved Hide resolved
controllers/gitrepository_controller.go Outdated Show resolved Hide resolved
@pjbgf pjbgf requested a review from darkowlzz October 28, 2022 16:57
go.mod Outdated Show resolved Hide resolved
controllers/helmchart_controller.go Outdated Show resolved Hide resolved
controllers/gitrepository_controller.go Show resolved Hide resolved
@pjbgf pjbgf force-pushed the git-refactoring branch 2 times, most recently from 95a6360 to 6d97d09 Compare October 31, 2022 09:19
@pjbgf pjbgf requested a review from darkowlzz October 31, 2022 09:33
This ensures that the event, notification and log
are configured correctly.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@pjbgf pjbgf merged commit ade77ec into main Oct 31, 2022
@pjbgf pjbgf deleted the git-refactoring branch October 31, 2022 12:36
@mestadler
Copy link

Because other will ask, can we add Gitea and Bitbucket.

@pjbgf
Copy link
Member Author

pjbgf commented Nov 2, 2022

This should support all Git servers we know of. More information on the tested servers can be found at fluxcd/go-git#4.

Err: fmt.Errorf("failed to configure checkout strategy for Git implementation '%s': %w", obj.Spec.GitImplementation, err),
Reason: sourcev1.GitOperationFailedReason,
}
e := serror.NewStalling(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While reviewing #945, I noticed that this stalling error may not be appropriate for the above operation. The old code had stalling error because CheckoutStrategyForImplementation() failure actually meant that retrying will not make any change. But for the above, new git client creation can fail due to various reasons and a subsequent retry may succeed.
It may be better to make sure it's an invalid git implementation error before returning stalling error. For other error while creating the git client, a generic error which results in a retry may be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/git Git related issues and pull requests
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants