-
Notifications
You must be signed in to change notification settings - Fork 27
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
Optimize cloud detection #483
Conversation
nit: you should be able to reliably detect cloud based on DMI data - from https://coroot.com/blog/cloud-metadata :
|
I also considered that, it would works well on AWS / GCP, but on Azure DMI conteints are exactly same as baremetal Hyper-V. see: https://stackoverflow.com/questions/11570965/how-to-detect-azure-amazon-vm Maybe we can wait metadata server access just for Azure, since it will likely success because in that case we already know it's not AWS nor GCP. Or, maybe we can ignore about non-cloud environment, since scylla-machine-image script will does not work on such environment at some point. |
We can ignore Hyper-V, or treat it just like Azure - either path is fine, IMHO. |
We could do something similar to https://github.com/dgzlopes/cloud-detect/blob/master/cloud_detect/providers/azure_provider.py |
This needs the networking stack to be up (and IPv4 configured, what about IPv6 only?) - we'd like to avoid that. |
There are also metal instances, which might be different. |
That could be the fallback if above detection fails. |
d231cb2
to
e13c807
Compare
Pushed new implementation which uses DMI for the detection, and async/await for metadata server access (when DMI probe failed).
|
Ah, it breaking the unittest, fixing... |
e13c807
to
d884d41
Compare
Testcase fixed. |
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.
LGTM
even that I would prefer using https://github.com/dgzlopes/cloud-detect directly
and not copying it's implementation (even it's MIT license, and we could do it legally)
@syuu1228 Please rebase and re-test the verification job |
We actually can package cloud-detect package into scylla-python3 by updating install-dependencies.sh in scylla repo, but I did not prefer to update that just for scylla-machine-image so I haven't added any package for scylla-machine-image scripts. But if we copy scylla-cqlsh implementation which adds zipped pip package into relocatable package, then we can use pip packages on scylla-machine-image too, that would be alternative way to implement this. |
A simple vendoring of the code as a submodule, might also work in this case. |
Tried to add cloud-detect as submodule and load from scylla-machine-image, but it seems difficult because the module is hevily depend with aiohttp, witch contains C extension. |
Is there no simple way to do this without adding complicated packages? |
I think current patch on this PR does this. |
@syuu1228 if there is nothing else to add for this change - please verify it and make sure the slowness issue resolved so we can merge it |
d884d41
to
f99bef1
Compare
5a0c2cc
to
bbc0f3a
Compare
Currently get_cloud_instance() is very slow on GCE / Azure, since it fails to detect AWS metadata server, and retrying multiple times in curl(). To speed up cloud detection, we will introduce following: - Use DMI parameters for the detection when it's available - Use async/await for metadata server access Fixes scylladb#481
bbc0f3a
to
a2b8abe
Compare
@yaronkaikov Tested on https://jenkins.scylladb.com/job/scylla-master/job/releng-testing/job/next-machine-image/264/, please merge this. |
Currently get_cloud_instance() is very slow on GCE / Azure, since it fails to detect AWS metadata server, and retrying multiple times in curl().
Actually we don't really need to do detection, we can specify target cloud name statically when we build machine-image.
To do so, adding target cloud name to machine_image_info.yaml while building machine-image, and reference it from scylla_cloud.py.
Note that we still need to fallback to metadata server based detection, since there are users who manually install scylla-machine-image package , not using our machine-image.
Fixes #481