-
Notifications
You must be signed in to change notification settings - Fork 33
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
Change default metadata endpoint handling #49
Change default metadata endpoint handling #49
Conversation
41a4be5
to
a132fc1
Compare
Codecov Report
@@ Coverage Diff @@
## master #49 +/- ##
==========================================
+ Coverage 23.95% 24.40% +0.45%
==========================================
Files 5 5
Lines 501 504 +3
==========================================
+ Hits 120 123 +3
Misses 359 359
Partials 22 22
Continue to review full report at Codecov.
|
main.go
Outdated
return errors.Wrap(err, "error in parsing custom endpoints") | ||
err = errors.Wrap(err, "error in parsing custom endpoints") | ||
logger.Fatal(err) | ||
panic(err) |
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.
why are both Fatal and panic used here? I thought fatal already exits the program?
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.
yep, thats left over from when I copy/pasted. Will fix.
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.
fixed, PTAL
http_server_test.go
Outdated
defer os.Setenv("CUSTOM_ENDPOINTS", customEndpoints) | ||
os.Setenv("CUSTOM_ENDPOINTS", `{"/metadata":".metadata.instance","/components":".metadata.components","/userdata":".metadata.userdata"}`) | ||
|
||
customEndPoints := map[string]string{ |
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.
super nitpicky i know, but can you lower case the the p here (customEndpoints
)?
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.
fixed, PTAL
http_server_test.go
Outdated
status: 404, | ||
error: "error in parsing custom endpoints: invalid character ':' after top-level value", | ||
json: tinkerbellDataModel, | ||
}, |
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's the reasoning for removing these two cases?
shouldn't we have a case that tests the default? and the second one is for covering the bases of all the possible invalid envvar formats
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 had originally done the CUSTOM_ENDPOINTS parsing in func main()
and so removed it. But I didn't want to affect codecoverage too much so put it behind the func we have now. But I forgot to bring this test back in. Will fix.
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.
fixed, PTAL. I left the default one out as thats done in func main()
now, as it should be :D.
With this change, would it make sense that we add in a I understand the reasoning behind this change but I'm still a little e_e. |
Yeah that is a good option. I kind of would rather merge this as is though and see if there are any problems with it. I'm not sure if any workflows are even using hegel/metadata (https://deploy-preview-162--suspicious-jackson-6c9a73.netlify.app/blog/2020/10/provisioning-flatcar-container-linux-with-tinkerbell/ just embeds the ignition straight into the template). So I'd rather err on the side of /metadata is same as /meta-data unless we need to come up with a work around. |
a132fc1
to
a2fe424
Compare
a2fe424
to
c2383c7
Compare
alrighty @kdeng3849 I think everything should all set now. |
Signed-off-by: Manuel Mendez <[email protected]>
This is more concise. Signed-off-by: Manuel Mendez <[email protected]>
This is easier to track down failures with. Signed-off-by: Manuel Mendez <[email protected]>
main is the correct place to parse out env vars and command line flags. Signed-off-by: Manuel Mendez <[email protected]>
So we have nicely aligned and sorted json. Signed-off-by: Manuel Mendez <[email protected]>
…nterface{} When the default handling for /metadata changes in an upcoming commit unmarshalling the json to packet.Metadata is not going to work. So we change the unmarshalling destination here instead so the next commit is doing only one thing. Signed-off-by: Manuel Mendez <[email protected]>
This is so we can avoid confusion when taking into account the handling of /meta-data. In EM Production today (Kant) /meta-data and /metadata both have the same output data. Making Hegel match by default is in line with the goal of Hegel as a Kant replacement. This is a bc-break and there's no current way to fetch the full hardware.metadata json field, but I'm ok with that. This should all go away when the Instance Proposal is implemented. Signed-off-by: Manuel Mendez <[email protected]>
c2383c7
to
4970c17
Compare
Description
Change the handling the /metadata endpoint so the data returned is of the same content as the /meta-data EC2 style endpoint.
Why is this needed
Hegel is meant as a replacement for what is used in EM Production today (Kant). The response from /metadata and /meta-data Kant returns is the same content. Its also arguably confusing to have 2 similarly named endpoints return very different data. This confusion is in part due to not having an Instance object yet expecting instance data somewhere. This should be cleaned up/made to make sense by tinkerbell/proposals#25.
How Has This Been Tested?
Unit tests still pass.
How are existing users impacted? What migration steps/scripts do we need?
This is a bc-break. If any users were using the /metadata endpoint in its default configuration their workflow would be broken. I'd like to wait and see if thats the case before prematurely having any workarounds.