-
Notifications
You must be signed in to change notification settings - Fork 39
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
Remove one call to get_ssh_client() #710
base: master
Are you sure you want to change the base?
Conversation
652856e
to
fe3baaa
Compare
Since in ssh_reachable() we already get a SSH client connection, let's save it in the (unused so far) _ssh_client var. Then reuse it, in _scp() command.
fe3baaa
to
b343dfd
Compare
ci test please |
ci test please |
ci please test |
ci test please |
password=self._spec.get('ssh-password'), | ||
) | ||
if self._ssh_client is not None: | ||
client = self._ssh_client |
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.
Can we use the same client in multiple threads?
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 think that it would be better to add try/catch
when trying to get the client in _scp
.
It will prevent a case where:
- You check if the vm is ssh reachable
- Something makes the vm go offline
- You call the
_scp
context manager.
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.
What am I supposed to do in this case? What do I do in the catch? Nothing I can do then if the VM is offline - we'll fail miserably anyway.
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.
- You can fall back to use
libguestfs
. - Print an explanation about the failure. It's better than to see the entire stack trace on screen.
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.
We cannot use the client in different threads - it is actually closed after the SCP.
I thought libguestfs doesn't work - but I guess I could once you get your new exception in.
Since in ssh_reachable() we already get a SSH client connection,
let's save it in the (unused so far) _ssh_client var.
Then reuse it, in _scp() command.