-
Notifications
You must be signed in to change notification settings - Fork 80
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
kafkabp: Support AWS IMDS v2 for rack id #657
Conversation
5182e4a
to
41f1885
Compare
const ( | ||
// References: | ||
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html | ||
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html |
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.
🔕 is there a reference for the IMDSv2 / token API to add?
tokenURL = "http://169.254.169.254/latest/api/token" | ||
azURL = "http://169.254.169.254/latest/meta-data/placement/availability-zone" | ||
|
||
timeout = time.Second |
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 think units should always come with a scalar too for readability, even if it's 1
timeout = time.Second | |
timeout = 1*time.Second |
ctx, cancel := context.WithTimeout(context.Background(), timeout) | ||
defer cancel() | ||
|
||
token, err := func(ctx context.Context) (string, error) { |
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.
Same comments as the rack
API: not sure I am seeing the reason for the anonymous function, and that header should be normalized
id, err := awsRackID() | ||
if err != nil { | ||
awsRackFailure.Inc() | ||
slog.Warn("Failed to get AWS availability zone as rack id", "err", 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.
🔕 is v0 ready for slog?
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 think we want to gradually shift v0 to use slog directly, which will use ctxlog if services have ctxlog set up in their main (as v0 cannot use ctxlog directly)
41f1885
to
94d07bd
Compare
Also modernize the code a bit (use sync.OnceValues, etc.).
94d07bd
to
379642d
Compare
Also modernize the code a bit (use sync.OnceValues, etc.).