-
Notifications
You must be signed in to change notification settings - Fork 900
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
Add git remote connection check code #20759
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for doing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much, @djberg96
Cool idea. @NickLaMuro Please review. |
This set ups the framework, but how do you envision this method to be used? (I don't see anything ultimately calling check_connection in a flow). |
I think @tinaafitz, @billfitzgerald0120 or @d-m-u can provide an example. |
@Fryguy this is intended to be called from the generic state machine, the automate side: module ManageIQ
module Automate
module Service
module Generic
module StateMachines
module GenericLifecycle
class CheckConnection
...
def check_connection(service)
rc = service.check_connection(action = "Provision")
# check_connection returns true if connection is successful, false otherwise
if !rc
@handle.root['ae_result'] = 'retry'
retry_interval
else
@handle.root['ae_result'] = 'ok'
end
end so that when running a playbook if the connectivity isn't present we can handle the retry more gracefully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few changes.
Also, I wanted to clarify something that was mentioned in the PR description:
Since the original issue was really a generic connectivity issue, and not specifically about the github API failing to return expected data, I felt the original rugged code was too heavy. It's the equivalent of a git ls-remote, which fetches data under the hood, and we don't need to fetch data, we just need to test for connectivity.
The intent with going with the check_connection
code, while yes, a bit heavier than your standard ping
, would avoid false positives or false negatives (compared to a ping
) depending on how the endpoint's firewall is configured.
For example: If the remote host is super locked down, most likely only git protocols would be allowed, and a simple ping
might not get through. Or, conversely, if it is a little more permissive and allows a ping
, but git
is run on a non-standard port (but that isn't configured in MIQ), that won't be tested here and the ping
would pass, but the eventual clone would still fail.
That said, not invalidating where is here and what is here is better than nothing, just giving some more context as to why the .check_connection
was originally chosen for a solution.
Then I wonder if it's better to rename the method to be a predicate. Something like |
I renamed it to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me now. Stinks we can't use rugged
, but we have mucked around with that segfault
long enough. 👍
Checked commits https://github.com/djberg96/manageiq/compare/439b41f938fe2cb219e24831ed585be2c2d25fa4~...874902f033528ff1d6e14c2f5f285d3929b5d1a0 with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint spec/models/git_repository_spec.rb
|
@djberg96 Can this be |
@dmetzger57 what say you? |
Yes to ivanchuk/yes |
@miq-bot add_label ivanchuk/yes |
Add git remote connection check code (cherry picked from commit 41f40f8) https://bugzilla.redhat.com/show_bug.cgi?id=1835226
Ivanchuk backport details:
|
Add git remote connection check code (cherry picked from commit 41f40f8)
Jansa backport details:
|
Add git remote connection check code (cherry picked from commit 41f40f8)
Kasparov backport details:
|
Slight reworking of #20645
This is basically @NickLaMuro's PR, but with the
check_connection
method modified. Instead of making a Rugged connection on the API endpoint, we just perform an http ping on the repo.I made these changes to Nick's PR for a couple reasons. First and foremost, the Rugged code was segfaulting with a difficult to diagnose error that indicates that, somewhere in the guts of either rugged or libgit2, it's trying to
free
something that it didn't allocate. Issue reported here: libgit2/rugged#859. Unable to solve that, we had to find a different way.Since the original issue was really a generic connectivity issue, and not specifically about the github API failing to return expected data, I felt the original rugged code was too heavy. It's the equivalent of a
git ls-remote
, which fetches data under the hood, and we don't need to fetch data, we just need to test for connectivity.I chose net-ping as the solution because it was already a dependency in ManageIQ, because I'm the original author, and because it solves our needs. Although I have not been the maintainer for many years now, the code hasn't changed dramatically, so I have good familiarity with it.
@tinaafitz, @billfitzgerald0120, @d-m-u and I tested this on a vmware host where we temporarily disabled the network in the middle of provisioning a catalog item and it worked as expected, i.e. it would check the connection X number of times, and proceed if the connection was restored.
Original bug: https://bugzilla.redhat.com/show_bug.cgi?id=1835226