-
Notifications
You must be signed in to change notification settings - Fork 0
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 node autodetection via IP address #11
Conversation
This function takes a node xname (among other args), which allows us to build other callers that can determine the xname in different ways (e.g. auto-detection via the initiating HTTP request's source IP). This also moves the responsibility for doing SMD MAC lookups away from the memstore's get-data function, and out into the "get user/meta/vendor data" function.
Due to Go HTTP handler weirdness, we return a function which itself handles the actual requests. This reduces code duplication substantially.
This still provides the MAC address that we need, and includes an IP address that we'll use shortly.
Data structures are hard.
The new SMD interface (particularly, decoding the new response from JSON to a slice of structs) is tested and functional on the teaching cluster. Should be fully ready for review now! |
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. One thing to note is that it might make sense to change the non-secure /cloud-init[-secure]
endpoint to specific routes to be clear what's being fetched in the future. For example, if I'm looking to fetch public keys, then it might make sense to have a separate /keys
endpoint and leave the /cloud-init
endpoint to be secure/non-secure based on the JWKS_URL
environment variable being set. This is of course more so relevant to the other PR that was merged previously.
This PR adds a class of endpoints (below) which do not require the querying node to specify its own MAC address for lookup purposes.
This should dramatically simplify the process of getting cloud-init data onto the node, since the server can now use the node's IP address (extracted from the HTTP request) to look up its xname from SMD.
This requires much less special effort on the node's part (i.e. logic that would need to be built into the boot image).
The new endpoints (i.e. those which perform IP-based SMD lookups) are:
/cloud-init[-secure]/user-data
/cloud-init[-secure]/meta-data
/cloud-init[-secure]/vendor-data
The existing
/cloud-init[-secure]/<MAC address>/{user,meta,vendor}-data
endpoints continue to function normally.