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

Test git over SSH too, and correct hard-wired implementation causing SSH/libgit2 problems #109

Merged
merged 3 commits into from
Feb 12, 2021

Conversation

squaremo
Copy link
Member

@squaremo squaremo commented Feb 11, 2021

This extends the tests so that the main battery is run with {libgit2,go-git} x {HTTP,SSH}. Fixes #106.

This was provoked by SSH-over-libgit2 failing for people (e.g., in #106). It turns out the culprit is a remnant, hard-wired value that meant libgit2 didn't get the authentication (and host key check) callbacks needed for SSH. (So the bulk of the work, here, in fluxcd/pkg, and in fluxcd/source-controller was in getting SSH tests to work at all!)

(This won't build and pass tests until there's a source-controller module version with fluxcd/source-controller#288 merged)

squaremo and others added 3 commits February 11, 2021 13:44
The "auth strategy", which depends on the GitImplementation, was
hard-wired to the "gogit" constant, but it should come from the
GitRepository spec. When the implementation is "libgit2" and the git
URL entails SSH, the result would normally include a callback for
checking the host key against known_hosts; but since it was
hard-wired, it was missing that callback.

This explains at least some instances of the error `user cancelled
hostkey check` from #106. The error, or a close relative, might also
arise if the callback rejects the host key because the host as it
appears in the known_hosts doesn't match that host as passed to the
callback -- see
fluxcd/source-controller#287.

Signed-off-by: Michael Bridgen <michael@weave.works>
This commit rearranges update tests so that those that check that
updates are made can be run against a git server using SSH as well as
HTTP.

The local clone, used to provoke automated updates and to check
results, still uses HTTP. Those operations are not under test.

libgit2 wants to be asked for authentication when using SSH, and will
balk if it's not requested by the server. To avoid that, auth must be
switched on for the git test server.

This also switches auth on for HTTP, so it's necessary to use a git
URL that includes credentials for setting things up with a local
clone. I have also used that URL for the git-over-HTTP tests -- it's
arguable whether it's necessary to test that works, here.

Signed-off-by: Michael Bridgen <michael@weave.works>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

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

With the updated dependencies all lights are green, thank you @squaremo for your thorough work on this across the projects 💯

@hiddeco hiddeco merged commit b35b9e3 into main Feb 12, 2021
@hiddeco hiddeco deleted the test-ssh-too branch February 12, 2021 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User cancelled hostkey check on Azure DevOps
2 participants