-
Notifications
You must be signed in to change notification settings - Fork 898
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
[WIP] Add ServiceAnsiblePlaybook.check_connection #20645
[WIP] Add ServiceAnsiblePlaybook.check_connection #20645
Conversation
This method takes a `url` and uses that to create an anonymous remote to use the `rugged`/`libgit2` to check the connection of a given remote. Will make use of any credentials that are configured for the worktree.
For a given repository record, check the connection for the configured url. In this case, an existing repository is not used or created, and simply a "stub repository" is created in a tmpdir to allow calling `check_connection` with the configured url for the repo record.
Allows calling `.check_connection` from a given `ServiceAnsiblePlaybook` instance. A new `.repository` method was created to allow fetching the `GitRepository` record and calling `GitRepository#check_connection` from the `ServiceAnsiblePlaybook`.
@tinaafitz @d-m-u Hopefully this helps with the BZ you are working on. |
Checked commits NickLaMuro/manageiq@f65b139~...ff7eb86 with ruby 2.6.3, rubocop 0.69.0, haml-lint 0.28.0, and yamllint |
Thanks so much @NickLaMuro. We'll start testing the changes. |
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.
Just a few notes on what I did for context.
@@ -18,6 +18,10 @@ def execute(action) | |||
launch_ansible_job_queue(action) | |||
end | |||
|
|||
def check_connection(action) |
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.
The action
argument here is just in line with how playbook
also works. If this interface, and the one in ServiceTemplateAnsiblePlaybook
, are incorrect, we can change, but it seems like this is how these methods function.
(by that, I mean they pass around a :provision
keyword to access specific attributes in config_info
)
# repo in a temp path to check the remote to see if it can accept | ||
# connections. | ||
def check_connection | ||
Dir.mktmpdir do |tmp_repo_dir| |
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.
Doing this as a block to make sure the tmp dir is removed once we are done with the .check_connection
call.
The result of the block is what is returned, so the directory being deleted is just a side effect of that.
with_remote_options do |remote_options| | ||
@repo.remotes | ||
.create_anonymous(url) | ||
.check_connection(:fetch, remote_options) |
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.
remote_options
here has our credentials and proxy info, so if that is configured, it will be used as it is with other methods in this class.
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.
Is check_connection here a rugged method?
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.
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.
code checks out for me.
Like the approach and am happy we are not over optimizing this before we even get the thing up and running. The point that seals the deal for me is knowing that if there were a performance problem, Nick would not be the only one able to diagnose and fix this problem.
This looks great.
Tina - let me know if this checks out on your side and I can merge.
Or if you are not able to test, ping me and I can take a look
Not sure why the enhancement label, pretty sure this is a bug: see the linked bz in the description (https://bugzilla.redhat.com/show_bug.cgi?id=1835226). |
@d-m-u while this PR itself is addressing a bug, but the addition is a enhancement that didn't exist previously. |
Marking this as |
So I wanted to give an update on this... I have been unable to replicate the I think Drew has replicated this issue multiple times now, but I honestly don't know where to start on fixing the segfault and have been spinning my wheels a bit on where to start. I might consider a shell out to Anyway, thought I would give a bit of an update since this has been staled as a result of me not being able to figure this bug out... 😞 |
Leaving this as a note for myself. I think this might be a inter-opt issue with DRb, but not positive. If we are trying to work with a That said, I currently haven't been able to recreate and setting something up to do just that has been a bit of a nightmare, so will probably work with Drew and Tina next week to work on this. |
Hi @NickLaMuro, Thanks so much for your work on this and for the update. I know we discussed it briefly on our call on Friday, but I'm happy to get on a call to discuss it whenever it works best for you. I was hoping this simplified way of running the Automate check_connection method through the rails console would reproduce the segfault, but it didn't. :-( #setup the Automate workspace #get the service model wrapped Service object
|
After some major troubles with |
@@ -258,6 +258,14 @@ def checkout | |||
end | |||
end | |||
|
|||
def check_connection(url) |
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.
I know this is closed, but just as a note for me so I don't lose context, we were in the process of replacing this method with Net::Ping::HTTP.new(url).ping?
when we hit the subsequent error about the job not existing.
Allows a
ServiceAnsiblePlaybook
instance to check the remote endpoint for a repo to see if it can connect prior to attempting a clone.This PR also creates some internals in
GitRepository
andGitWorktree
to facilitate this and call into therugged
/libgit2
internals (all sharing the same method name:.check_connection
)Links
Steps for Testing/QA
I tested this by running it in a jansa VM with this patch applied:
EmbeddedAnsible
rails console
: