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

fix(kubernetes_logs source): Set user-agent for k8s apiserver requests. #21905

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

ganelo
Copy link

@ganelo ganelo commented Nov 27, 2024

Summary

When querying the k8s api server for pods, the client created by the kubernetes_log source failed to specify a user agent, making it difficult to correctly attribute load on the api server to vector. By bumping the version of the kube and k8s-openapi crates, we get access to sending arbitrary headers with our requests. This PR uses this functionality to set a user-agent header to the value vector/<vector version>.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

I built vector from source on this branch and deployed it via a helm chart in a k8s cluster to confirm that queries against the k8s api server were being generated with user agent set as intended. I also confirmed that logs from the kubernetes_log source continue to be processed as expected.

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Checklist

  • Please read our Vector contributor resources.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run dd-rust-license-tool write to regenerate the license inventory and commit the changes (if any). More details here.

References

@ganelo ganelo requested a review from a team as a code owner November 27, 2024 18:58
@bits-bot
Copy link

bits-bot commented Nov 27, 2024

CLA assistant check
All committers have signed the CLA.

@ganelo ganelo force-pushed the og/kubernetes-user-agent branch from b0cc62f to 735e4c9 Compare November 27, 2024 20:14
Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This looks good to me. I have just one question about the deprecation allows.

src/aws/auth.rs Outdated Show resolved Hide resolved
src/sources/kubernetes_logs/mod.rs Show resolved Hide resolved
@pront
Copy link
Member

pront commented Dec 5, 2024

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

Also, please take a look at this.

Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ganelo !

@jszwedko jszwedko enabled auto-merge December 6, 2024 21:04
@ganelo ganelo changed the title fix(kubernetes_log source): Set user-agent for k8s apiserver requests. fix(kubernetes_logs source): Set user-agent for k8s apiserver requests. Dec 6, 2024
auto-merge was automatically disabled December 6, 2024 21:28

Head branch was pushed to by a user without write access

@pront pront enabled auto-merge December 6, 2024 22:00
Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ganelo It looks like the AWS integration tests are failing here. You can run these locally via make test-integration-aws (requires Docker). I think it is likely due to the bump to aws-config since we've been trying to bump it separately in #20663 without success (also failing integration tests).

If it is possible to bump aws-config back down, that might unblock this PR.

auto-merge was automatically disabled December 10, 2024 18:48

Head branch was pushed to by a user without write access

@jszwedko jszwedko enabled auto-merge December 11, 2024 09:54
auto-merge was automatically disabled December 13, 2024 17:02

Head branch was pushed to by a user without write access

@ganelo
Copy link
Author

ganelo commented Dec 16, 2024

@ganelo It looks like the AWS integration tests are failing here. You can run these locally via make test-integration-aws (requires Docker). I think it is likely due to the bump to aws-config since we've been trying to bump it separately in #20663 without success (also failing integration tests).

If it is possible to bump aws-config back down, that might unblock this PR.

@jszwedko It looks like all relevant tests are passing now - mind merging?

Cargo.toml Outdated
aws-sdk-firehose = { version = "1.3.0", default-features = false, features = ["behavior-version-latest", "rt-tokio"], optional = true }
aws-sdk-kinesis = { version = "1.3.0", default-features = false, features = ["behavior-version-latest", "rt-tokio"], optional = true }
aws-sdk-secretsmanager = { version = "1.3.0", default-features = false, features = ["behavior-version-latest", "rt-tokio"], optional = true }
aws-sdk-sqs = { version = "~1.3.0", default-features = false, features = ["behavior-version-latest", "rt-tokio"], optional = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if we need all of these ~s rather than just not updating aws-config when adding the new crates. Did you find them to be required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Truthfully I was having a hard time running the test locally (was seeing the same result of test failures whether running on tip of master or on this branch) so I may have been a little overzealous here. I'd be happy to try just aws-config if you don't mind triggering the integration test here to check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 the integration tests will run during the merge so we should get feedback then. Unfortunately it isn't possible to trigger them on external PRs otherwise at the moment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Okay I'll go ahead and revert the extra version pins and echo back.

@jszwedko jszwedko enabled auto-merge December 16, 2024 23:14
@jszwedko jszwedko added this pull request to the merge queue Dec 17, 2024
github-merge-queue bot pushed a commit that referenced this pull request Dec 17, 2024
…s. (#21905)

* fix(kubernetes_log source): Set user-agent for k8s apiserver requests.

* Update changelog.d/21864_kubernetes_logs_user_agent.fix.md

Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>

* Switch away from deprecated structs

* Update 21864_kubernetes_logs_user_agent.fix.md

* Try manually updating version via crate update

* Specify using tilde in Cargo.toml

* Rip out unused aws-runtime dep

* Try to limit dep bumps

* Revert superfluous import change

* Remove superfluous pins

---------

Co-authored-by: Orri Ganel <oganel@palantir.com>
Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 17, 2024
@ganelo
Copy link
Author

ganelo commented Dec 17, 2024

@jszwedko I added features = ["std"] to try to fix the http-1 compilation errors from the merge jobs, not really sure what the issue is with awscli not being found.

@jszwedko
Copy link
Member

not really sure what the issue is with awscli not being found.

That is actually fixed by #22044 . Let me try to merge this again.

@jszwedko jszwedko enabled auto-merge December 17, 2024 19:15
@jszwedko jszwedko added this pull request to the merge queue Dec 17, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: sources Anything related to the Vector's sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants