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-5968): Container and Kubernetes Awareness #4005

Merged
merged 16 commits into from
Mar 6, 2024

Conversation

aditi-khare-mongoDB
Copy link
Contributor

@aditi-khare-mongoDB aditi-khare-mongoDB commented Feb 27, 2024

Description

Track user usage of containers.

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 title EOD commit feat(NODE-5968): Container and Kubernetes Awareness Feb 27, 2024
@aditi-khare-mongoDB aditi-khare-mongoDB marked this pull request as ready for review February 29, 2024 19:10
@nbbeeken nbbeeken self-assigned this Feb 29, 2024
@nbbeeken nbbeeken added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Feb 29, 2024
@nbbeeken nbbeeken self-requested a review February 29, 2024 19:11
lint fix 2
@aditi-khare-mongoDB aditi-khare-mongoDB force-pushed the NODE-5968/6.x-container-and-kubernetes-awareness branch from 6da9072 to 7140454 Compare February 29, 2024 19:42
added tests - no docker tests

removed extraneous export and newline

removed extraneous export and newline

removed unnecesary helper funcs

removed unnecesary let, changed to const

added more tests to comply w kickoff - no docker tests still

cleared up logic
@aditi-khare-mongoDB aditi-khare-mongoDB force-pushed the NODE-5968/6.x-container-and-kubernetes-awareness branch from 7140454 to 03e5e13 Compare February 29, 2024 19:44
src/cmap/handshake/client_metadata.ts Outdated Show resolved Hide resolved
src/cmap/handshake/client_metadata.ts Show resolved Hide resolved
test/unit/cmap/connect.test.ts Outdated Show resolved Hide resolved
test/unit/cmap/connect.test.ts Outdated Show resolved Hide resolved
test/unit/cmap/connect.test.ts Outdated Show resolved Hide resolved
test/unit/cmap/connect.test.ts Show resolved Hide resolved
src/cmap/handshake/client_metadata.ts Outdated Show resolved Hide resolved
src/cmap/handshake/client_metadata.ts Outdated Show resolved Hide resolved
src/cmap/handshake/client_metadata.ts Outdated Show resolved Hide resolved
test/unit/cmap/connect.test.ts Outdated Show resolved Hide resolved
test/unit/cmap/connect.test.ts Outdated Show resolved Hide resolved
@nbbeeken nbbeeken added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Mar 4, 2024
test/unit/cmap/connect.test.ts Outdated Show resolved Hide resolved
test/unit/cmap/connect.test.ts Outdated Show resolved Hide resolved
@aditi-khare-mongoDB aditi-khare-mongoDB force-pushed the NODE-5968/6.x-container-and-kubernetes-awareness branch from 6355e4e to 25d1b44 Compare March 4, 2024 19:48
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
Development

Successfully merging this pull request may close these issues.

4 participants