-
Notifications
You must be signed in to change notification settings - Fork 108
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
openstack: Add attribute OPENSTACK_INSTANCE_UUID #931
Conversation
16d6ff3
to
ec1046d
Compare
I have tested this patch on an OpenStack VM. Metadata endpoint:
Config drive:
|
Could do with a couple of unit tests (one each for network and config drive), but I think it's in good enough shape to remove the scary warning in the description. I agree with the design decision to add a new parameter rather than fix the existing one. Although the existing value can't be used anywhere in the openstack API, it does still potentially serve as an opaque unique identifier: changing it could potentially break any server which had previously registered the old value. |
ec1046d
to
92b76a5
Compare
Aaaand here they are! |
92b76a5
to
7525052
Compare
7525052
to
c4c66b4
Compare
I believe this patch to be ready for a review. Shall I assign @bgilbert? |
209c215
to
70badef
Compare
.mock("GET", "/openstack/2012-08-10/meta_data.json") | ||
.with_status(200) | ||
.with_header("content-type", "application/json") | ||
.with_body(r#"{"uuid": "99dcf33b-6eb5-4acf-9abb-d81723e0c949", "public_keys": {"pprinett": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC/Zc+pyRoKWVS1CVx2soRe7Ia7RGkASpXZE495H2XuS3gF4Vb9JdATkJ4NURmAQhUN8TYCbfqTcf2Fpm/5mtG6Dn8Avua1mXgNRvrufVYBvWkOn9qPEYkwELSG0WcqjpISwsKRAU0d7Mcqo0aDmp/wpgbXHCBG03Q8w0uhRTdI7jEj/EzatbtkgUJnE79OHUImxdG+11oKH0Ul2lQlSo+pMa0fwS3GrHKIxxZmMckSpT+gua0AttuGpr+JYIZKNkoWn7bMqpYpJAlKxjzaB6ympaIAOgd/CxXnXPzc8ntIm/MubDUbGzo7dpq39MmxtWb1bahS/zeyFq0ZR43FbHexZyj21PiurtFOXl93r+wgBLBcVjBogi23p8i+SrjOVb+nJJ5XEUaLDYYE7T4xnrmT/T0ODQQbh6W+F+/mCSwOpRsZV0+FYcWg34InQM177eBweAv5Lwtct6B0xzCCXYpNTjWpBUe46dP7FO0ltzD57CGglRyx7whff96Og7Zx61/YfR/zrfI4NYiP+4EbiN24NuTn0DvND/anCpvA1Zpsd7bNMvL9YrlCRD2lfcQl3p6Kqi48jLNpqjEMYEmgYzzGjE1hFuVqdjY63bAmD3+NPlfARsgbMiPpLAmb3nE5FTCWktUTE8fnoWIojUYm7/4HoVQlwWxRhLKji5NiJGMgYw== cardno:9_040_793\n"}, "keys": [{"name": "pprinett", "type": "ssh", "data": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC/Zc+pyRoKWVS1CVx2soRe7Ia7RGkASpXZE495H2XuS3gF4Vb9JdATkJ4NURmAQhUN8TYCbfqTcf2Fpm/5mtG6Dn8Avua1mXgNRvrufVYBvWkOn9qPEYkwELSG0WcqjpISwsKRAU0d7Mcqo0aDmp/wpgbXHCBG03Q8w0uhRTdI7jEj/EzatbtkgUJnE79OHUImxdG+11oKH0Ul2lQlSo+pMa0fwS3GrHKIxxZmMckSpT+gua0AttuGpr+JYIZKNkoWn7bMqpYpJAlKxjzaB6ympaIAOgd/CxXnXPzc8ntIm/MubDUbGzo7dpq39MmxtWb1bahS/zeyFq0ZR43FbHexZyj21PiurtFOXl93r+wgBLBcVjBogi23p8i+SrjOVb+nJJ5XEUaLDYYE7T4xnrmT/T0ODQQbh6W+F+/mCSwOpRsZV0+FYcWg34InQM177eBweAv5Lwtct6B0xzCCXYpNTjWpBUe46dP7FO0ltzD57CGglRyx7whff96Og7Zx61/YfR/zrfI4NYiP+4EbiN24NuTn0DvND/anCpvA1Zpsd7bNMvL9YrlCRD2lfcQl3p6Kqi48jLNpqjEMYEmgYzzGjE1hFuVqdjY63bAmD3+NPlfARsgbMiPpLAmb3nE5FTCWktUTE8fnoWIojUYm7/4HoVQlwWxRhLKji5NiJGMgYw== cardno:9_040_793\n"}], "hostname": "mule", "name": "mule", "launch_index": 0, "availability_zone": "nova"}"#) |
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'll leave this up to the maintainers, but given that there's already a fixtures directory containing related data I feel this blob would be better placed there and read from file.
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.
If I understand correctly, the fixture folder contains files meant to be passed to the tests as files. While we could move this string literal into a .json
file and dynamically load it in the test, I wouldn't necessarily see that as an improvement.
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 agree that this isn't especially legible here, and the fixture could be nice to reuse for additional tests in the future. Let's move it into the fixtures directory and use with_body_from_file()
.
70badef
to
37058a3
Compare
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 good to me! I'm not familiar enough with the code base (or rust for that matter) to say anything about the specifics, but on a high level it looks like a good solution.
Thanks for working on this @pierreprinetti ! 🙂
/lgtm I'm hoping we can get an E2E test of this solving our root issue from @tormath1 later. |
FWIW I tested with a patched Flatcar image in the Cluster API OpenStack project - the UUID is fetched as expected (kubernetes-sigs/cluster-api-provider-openstack#1564 (comment)). |
Firstly thank you for doing this! Second, regarding your question about getting the tests working: If you do a |
37058a3
to
2566a39
Compare
OK! I have run the below command in the expectation that the tests will now run: git commit --amend --no-edit && git push --force |
Are we missing an /ok-to-test label or something? |
So since you have not contributed to the repo before it looks like GitHub wanted a maintainer to approve the CI for you to run. You can read about it here => https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks |
2566a39
to
6418459
Compare
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.
Generally looks good to me, I have a few nits and a few questions.
Thank you so much for putting this up!
6418459
to
c4ba9f7
Compare
Thanks for the review, @prestist! I think I have applied all of your suggestions. |
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 good! Thanks @pierreprinetti for the contribution and @mdbooth for the reviews. Just a few nits and then I think we can land this.
.mock("GET", "/openstack/2012-08-10/meta_data.json") | ||
.with_status(200) | ||
.with_header("content-type", "application/json") | ||
.with_body(r#"{"uuid": "99dcf33b-6eb5-4acf-9abb-d81723e0c949", "public_keys": {"pprinett": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC/Zc+pyRoKWVS1CVx2soRe7Ia7RGkASpXZE495H2XuS3gF4Vb9JdATkJ4NURmAQhUN8TYCbfqTcf2Fpm/5mtG6Dn8Avua1mXgNRvrufVYBvWkOn9qPEYkwELSG0WcqjpISwsKRAU0d7Mcqo0aDmp/wpgbXHCBG03Q8w0uhRTdI7jEj/EzatbtkgUJnE79OHUImxdG+11oKH0Ul2lQlSo+pMa0fwS3GrHKIxxZmMckSpT+gua0AttuGpr+JYIZKNkoWn7bMqpYpJAlKxjzaB6ympaIAOgd/CxXnXPzc8ntIm/MubDUbGzo7dpq39MmxtWb1bahS/zeyFq0ZR43FbHexZyj21PiurtFOXl93r+wgBLBcVjBogi23p8i+SrjOVb+nJJ5XEUaLDYYE7T4xnrmT/T0ODQQbh6W+F+/mCSwOpRsZV0+FYcWg34InQM177eBweAv5Lwtct6B0xzCCXYpNTjWpBUe46dP7FO0ltzD57CGglRyx7whff96Og7Zx61/YfR/zrfI4NYiP+4EbiN24NuTn0DvND/anCpvA1Zpsd7bNMvL9YrlCRD2lfcQl3p6Kqi48jLNpqjEMYEmgYzzGjE1hFuVqdjY63bAmD3+NPlfARsgbMiPpLAmb3nE5FTCWktUTE8fnoWIojUYm7/4HoVQlwWxRhLKji5NiJGMgYw== cardno:9_040_793\n"}, "keys": [{"name": "pprinett", "type": "ssh", "data": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC/Zc+pyRoKWVS1CVx2soRe7Ia7RGkASpXZE495H2XuS3gF4Vb9JdATkJ4NURmAQhUN8TYCbfqTcf2Fpm/5mtG6Dn8Avua1mXgNRvrufVYBvWkOn9qPEYkwELSG0WcqjpISwsKRAU0d7Mcqo0aDmp/wpgbXHCBG03Q8w0uhRTdI7jEj/EzatbtkgUJnE79OHUImxdG+11oKH0Ul2lQlSo+pMa0fwS3GrHKIxxZmMckSpT+gua0AttuGpr+JYIZKNkoWn7bMqpYpJAlKxjzaB6ympaIAOgd/CxXnXPzc8ntIm/MubDUbGzo7dpq39MmxtWb1bahS/zeyFq0ZR43FbHexZyj21PiurtFOXl93r+wgBLBcVjBogi23p8i+SrjOVb+nJJ5XEUaLDYYE7T4xnrmT/T0ODQQbh6W+F+/mCSwOpRsZV0+FYcWg34InQM177eBweAv5Lwtct6B0xzCCXYpNTjWpBUe46dP7FO0ltzD57CGglRyx7whff96Og7Zx61/YfR/zrfI4NYiP+4EbiN24NuTn0DvND/anCpvA1Zpsd7bNMvL9YrlCRD2lfcQl3p6Kqi48jLNpqjEMYEmgYzzGjE1hFuVqdjY63bAmD3+NPlfARsgbMiPpLAmb3nE5FTCWktUTE8fnoWIojUYm7/4HoVQlwWxRhLKji5NiJGMgYw== cardno:9_040_793\n"}], "hostname": "mule", "name": "mule", "launch_index": 0, "availability_zone": "nova"}"#) |
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 agree that this isn't especially legible here, and the fixture could be nice to reuse for additional tests in the future. Let's move it into the fixtures directory and use with_body_from_file()
.
c4ba9f7
to
c27b26d
Compare
Here's another try! Let's see if we get closer... 😁 |
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!
In the OpenStack attributes, the field `OPENSTACK_INSTANCE_ID` reports the instance ID fetched from the EC2-compatibility-layer metadata. However, that identifier (in the format `i-something`) does not match the one used to refer to machines in the OpenStack API. With this patch, I propose to add a new OpenStack attribute `OPENSTACK_INSTANCE_UUID` that reports the actual identifier for OpenStack instances in the context of the OpenStack API. Implementation-wise, this patch adds enables fetching the UUID from both the config-drive and from the Nova metadata service endpoint. In order to retain compatibility with old versions of the metadata service, this patch uses the old endpoint `2012-08-10`. Fixes coreos#930
c27b26d
to
6a06a02
Compare
In the OpenStack attributes, the field
OPENSTACK_INSTANCE_ID
reportsthe instance ID fetched from the EC2-compatibility-layer metadata.
However, that identifier (in the format
i-something
) does not matchthe one used to refer to machines in the OpenStack API.
With this patch, I propose to add a new OpenStack attribute
OPENSTACK_INSTANCE_UUID
that reports the actual identifier forOpenStack instances in the context of the OpenStack API.
Implementation-wise, this patch adds enables fetching the UUID from both
the config-drive and from the Nova metadata service endpoint. In order
to retain compatibility with old versions of the metadata service, this
patch uses the old endpoint
2012-08-10
.Fixes #930