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

feat(NODE-5967): container and Kubernetes awareness in client metadata #4011

Merged
merged 5 commits into from
Mar 8, 2024

Conversation

aditi-khare-mongoDB
Copy link
Contributor

@aditi-khare-mongoDB aditi-khare-mongoDB commented Mar 1, 2024

Note: This PR's description and changes are almost identical to the one on the 6.x branch (NODE-5968).

Description

Track user usage of containers on 5.x branch.

What is changing?

When kubernetes is in process.env, we add a {orchestrator: 'kubernetes'} field to the client.env field of the handshake document (if this does not make the document exceed 512 bytes).

When '/.dockerenv' exists, we add a {runtime: 'docker'} field to the client.env field of the handshake document (if this does not make the document exceed 512 bytes).

Note: We do not unit test docker, but I tested our logic for detecting docker on an EVG Host, ran Docker and detection succeeds for both root and non-root user cases.

Is there new documentation needed for these changes?

No, non-user facing change.

What is the motivation for this change?

Product wants to track user usage of docker and kubernetes.

Release Highlight

Container and Kubernetes Awareness

The Node.js driver now keeps track of container metadata in the client.env.container field of the handshake document.

If space allows, the following metadata will be included in client.env.container:

env?: { 
  container?: {
    orchestrator?: 'kubernetes' // if process.env.KUBERNETES_SERVICE_HOST is set
    runtime?: 'docker' // if the '/.dockerenv' file exists
  } 
}

Note: If neither Kubernetes nor Docker is present, client.env will not have the container property.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@aditi-khare-mongoDB aditi-khare-mongoDB changed the base branch from main to 5.x March 1, 2024 21:15
@aditi-khare-mongoDB aditi-khare-mongoDB changed the title Node 5967/5.x container and kubernetes awareness feat(Node 5967): 5.x Container and Kubernetes Awareness Mar 1, 2024
@nbbeeken nbbeeken changed the title feat(Node 5967): 5.x Container and Kubernetes Awareness feat(NODE-5967): 5.x Container and Kubernetes Awareness Mar 4, 2024
@aditi-khare-mongoDB aditi-khare-mongoDB marked this pull request as ready for review March 7, 2024 16:29
@nbbeeken nbbeeken changed the title feat(NODE-5967): 5.x Container and Kubernetes Awareness feat(NODE-5967): container and Kubernetes awareness in client metadata Mar 8, 2024
@nbbeeken nbbeeken self-assigned this Mar 8, 2024
@nbbeeken nbbeeken added the Team Review Needs review from team label Mar 8, 2024
nbbeeken
nbbeeken previously approved these changes Mar 8, 2024
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

LGTM, I figure the txn test skips will merge very soon and we can rerun this PR on top of that to double check.

Side note, since this is merging into 5.x we don't need to mention 5.x in the title or release notes because of where it destined for it already has the context of the branch.

@aditi-khare-mongoDB
Copy link
Contributor Author

Good to know, I'll stop marking branches as 5.x in their ticket title or release notes.

@nbbeeken nbbeeken merged commit 55c290a into 5.x Mar 8, 2024
18 of 25 checks passed
@nbbeeken nbbeeken deleted the NODE-5967/5.x-container-and-kubernetes-awareness branch March 8, 2024 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
2 participants