-
Notifications
You must be signed in to change notification settings - Fork 91
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
Support direct upload/download to Image I/O daemon on oVirt node #35
Conversation
Hello contributor, thanks for submitting a PR for this project! I am the bot who triggers "standard-CI" builds for this project. In order to allow automated tests to run, please ask one of the project maintainers to review the code and then do one of the following:
|
ci test please |
Thank you for the PR! |
when trying your changes on 4.4 I get
Will do more investigation. |
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.
Resolved my env issues. And tested it on 4.4 and 4.3.
Another solution is to use the imageio client but that would add another dependency.
LGTM
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.
Looks like good change in the right direction.
But the upload code should be dropped, it is not efficient and not correct. Not detecting zeroes in uploaded image, sending zeroes over the wire, and always creating preallocated images even when the user asked to create sparse volume.
All these issues will be solved if you will drop the upload code and replace it with imageio client.
Bottom line is that this ansible script should not be used by anyone until it is modified to use imageio client.
Thank you for the info, I will create another PR with the imageio client. |
ci test please |
ci test please |
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.
Nice!
@@ -347,6 +347,25 @@ def _search_by_lun(disks_service, lun_id): | |||
return res[0] if res else None | |||
|
|||
|
|||
def create_transfer_connection(module, transfer, context, connect_timeout=10, read_timeout=60): |
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.
It can be useful to expose the timeouts to the user so they can override the timeouts if needed.
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.
yeah thought about that but we have default timeout 3min and not sure if it would be best to wait that long
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 would this to future work.
plugins/modules/ovirt_disk.py
Outdated
@@ -355,7 +355,8 @@ def create_transfer_connection(module, transfer, context, connect_timeout=10, re | |||
connection.connect() | |||
except OSError as e: | |||
# Typically ConnectionRefusedError or socket.gaierror. | |||
module.warn("Cannot connect to %s, trying %s: %s", transfer.transfer_url, transfer.proxy_url, e) | |||
module.warn("Cannot connect to {}, trying {}: {}" | |||
.format(transfer.transfer_url, transfer.proxy_url, e)) |
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.
Formatting messages for logs is bad idea. Formatting is expensive and should be done only when the log message is actually logged. For warnings this is usually the case, but for debug message it is always not and having 2 ways to log in the same code is bad.
I hope this is not the way ansible scripts use logging. If it is I guess we want to keep this consistent with other logs here.
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 is not for logging it just shows a user warning message.
And around formatting, I don't mind to use it as it was before.
@@ -355,8 +355,7 @@ def create_transfer_connection(module, transfer, context, connect_timeout=10, re | |||
connection.connect() | |||
except OSError as e: | |||
# Typically ConnectionRefusedError or socket.gaierror. | |||
module.warn("Cannot connect to {}, trying {}: {}" | |||
.format(transfer.transfer_url, transfer.proxy_url, e)) | |||
module.warn("Cannot connect to %s, trying %s: %s" % (transfer.transfer_url, transfer.proxy_url, e)) |
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 is the same as using {}. Please check module.warn() interface - does it work like Pyhon logging, accepting
fmt, *args or it a single srting?
Then check how other code in this area generate messages and use the same style.
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.
Oh that was your question it only accepts one string no other args.
And it is only message the warning styling is done automatically.
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.
Tested on 4.3 and 4.4, merging so we can get it to 2.9 if there is something to change we can fix it later.
Fixes #29 and therefore fixes image down-/upload on oVirt 4.4 engines also see RHBZ 1801710.
I verified this code with the following testing playbook:
Before this patch this playbook would fail with the following error when run against a oVirt 4.4 API:
I also needed to remove the authentication header from the download request. Otherwise I would get an error like:
I don't don't understand what is going wrong here. Maybe someone can make some sense of this?
Unfortunately I don't have a oVirt 4.3 environment around for testing the
use_proxy
flag.Also not sure if this should be enabled or disabled by default. Is there some way to autodetect this and do the right thing for 4.3 and 4.4?