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

DRIVERS-2570 Report docker or kubernetes environment in handshake #1454

Merged
merged 5 commits into from
Aug 28, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions source/mongodb-handshake/handshake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,15 @@ provided as a BSON object. This object has the following structure::
platform: "<string>",
/* OPTIONAL */
env: {
name: "<string>", /* REQUIRED */
name: "<string>", /* OPTIONAL */
abr-egn marked this conversation as resolved.
Show resolved Hide resolved
timeout_sec: 42, /* OPTIONAL */
memory_mb: 1024, /* OPTIONAL */
region: "<string>" /* OPTIONAL */
region: "<string>", /* OPTIONAL */
/* OPTIONAL */
container: {
runtime: "<string>", /* OPTIONAL */
orchestrator: "<string>" /* OPTIONAL */
}
}
}
}
Expand Down Expand Up @@ -313,8 +318,19 @@ client.env

This value is optional and is not application configurable.

Information about the Function-as-a-Service (FaaS) environment, captured from environment
variables. The ``client.env.name`` field is determined by which of the following environment
Information about the execution environment, including Function-as-a-Service (FaaS)
identification and container runtime.

The contents of ``client.env`` MUST be adjusted to keep the handshake below the size limit;
see `Limitations`_ for specifics.

If no fields of ``client.env`` would be populated, ``client.env`` MUST be entirely omitted.

FaaS
^^^^

FaaS details are captured in the ``name``, ``timeout_sec``, ``memory_mb``, and ``region`` fields
of ``client.env``. The ``name`` field is determined by which of the following environment
variables are populated:

+----------------+----------------------------------------------------------+
Expand All @@ -329,12 +345,12 @@ variables are populated:

.. [#] ``AWS_EXECUTION_ENV`` must start with the string ``"AWS_Lambda_"``.

If none of those variables are populated the ``client.env`` value MUST be entirely omitted. When
If none of those variables are populated the other FaaS values MUST be entirely omitted. When
variables for multiple ``client.env.name`` values are present, ``vercel`` takes precedence over
``aws.lambda``; any other combination MUST cause ``client.env`` to be entirely omitted.
``aws.lambda``; any other combination MUST cause the other FaaS values to be entirely omitted.

Depending on which ``client.env.name`` has been selected, other fields in ``client.env`` SHOULD
be populated:
Depending on which ``client.env.name`` has been selected, other FaaS fields in ``client.env``
SHOULD be populated:

+----------------+----------------------------+-------------------------------------+---------------+
| Name | Field | Environment Variable | Expected Type |
Expand All @@ -355,8 +371,19 @@ be populated:
Missing variables or variables with values not matching the expected type MUST cause the
corresponding ``client.env`` field to be omitted and MUST NOT cause a user-visible error.

The contents of ``client.env`` MUST be adjusted to keep the handshake below the size limit;
see `Limitations`_ for specifics.
Container
^^^^^^^^^

Container runtime information is captured in ``client.env.container``.

``client.env.container.runtime`` SHOULD be set to ``"docker"`` if the file ``.dockerenv``
abr-egn marked this conversation as resolved.
Show resolved Hide resolved
exists in the root directory.

``client.env.container.orchestrator`` SHOULD be set to ``"kubernetes"`` if the environment
abr-egn marked this conversation as resolved.
Show resolved Hide resolved
variable ``KUBERNETES_SERVICE_HOST`` is populated.

If no fields of ``client.env.container`` would be populated, ``client.env.container`` MUST
be entirely omitted.

--------------------------
Speculative Authentication
Expand Down Expand Up @@ -647,3 +674,4 @@ Changelog
:2023-03-13: Add ``env`` to ``client`` document
:2023-04-03: Simplify truncation for metadata
:2023-05-04: ``AWS_EXECUTION_ENV`` must start with ``"AWS_Lambda_"``
:2023-08-24: Added container awareness
Loading