Skip to content
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

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

fishy
Copy link
Member

@fishy fishy commented Jun 11, 2024

Also modernize the code a bit (use sync.OnceValues, etc.).

@fishy fishy requested a review from a team as a code owner June 11, 2024 17:39
@fishy fishy requested review from kylelemons, konradreiche and pacejackson and removed request for a team June 11, 2024 17:39
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
Copy link
Contributor

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
Copy link
Contributor

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

Suggested change
timeout = time.Second
timeout = 1*time.Second

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

token, err := func(ctx context.Context) (string, error) {
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Member Author

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)

Also modernize the code a bit (use sync.OnceValues, etc.).
@fishy fishy merged commit 63f8545 into reddit:master Jun 11, 2024
2 checks passed
@fishy fishy deleted the kafkabp-aws-rack-imds-v2 branch June 11, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants