Skip to content

Pass PROC_ROOT as environment variable to ss#7095

Merged
L3n41c merged 9 commits into
masterfrom
lenaic/network_check_on_containers
Sep 7, 2020
Merged

Pass PROC_ROOT as environment variable to ss#7095
L3n41c merged 9 commits into
masterfrom
lenaic/network_check_on_containers

Conversation

@L3n41c

@L3n41c L3n41c commented Jul 9, 2020

Copy link
Copy Markdown
Member

What does this PR do?

Pass the PROC_ROOT environment variable to ss

Motivation

When the agent is running inside a container, the host procfs is mounted under /host/proc

Additional Notes

Here is how ss uses an alternate path for procfs:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/misc/ss.c#n474

This PR requires DataDog/datadog-agent#5987 to support the extra env parameter passed to _util.subprocess_output.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have changelog/ and integration/ labels attached

@codecov

codecov Bot commented Jul 9, 2020

Copy link
Copy Markdown

`ss` can use a non-standard procfs location thanks to the `PROC_ROOT` environment variable.
This is useful when the agent runs inside a container where the host procfs is mounted in `/host/proc`.

See https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/misc/ss.c#n474
@L3n41c
L3n41c force-pushed the lenaic/network_check_on_containers branch from 56286cb to 1101fad Compare July 9, 2020 10:36
Comment thread datadog_checks_base/datadog_checks/base/stubs/_util.py
hush-hush
hush-hush previously approved these changes Aug 14, 2020
Comment thread datadog_checks_base/datadog_checks/base/utils/subprocess_output.py
Comment thread network/datadog_checks/network/network.py Outdated
Comment thread network/datadog_checks/network/network.py Outdated
@L3n41c
L3n41c force-pushed the lenaic/network_check_on_containers branch from 73898f7 to a691bf1 Compare September 1, 2020 15:28
Comment thread network/datadog_checks/network/network.py Outdated
Comment thread network/datadog_checks/network/network.py Outdated
Comment thread datadog_checks_base/datadog_checks/base/stubs/_util.py
Comment thread network/datadog_checks/network/network.py
olivielpeau
olivielpeau previously approved these changes Sep 1, 2020

@olivielpeau olivielpeau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@AlexandreYang made relevant comments, overall the logic looks good to me 👍

@AlexandreYang AlexandreYang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thx for the changes ! 👍

One last thing :)

Comment thread network/datadog_checks/network/network.py
@L3n41c
L3n41c force-pushed the lenaic/network_check_on_containers branch from 94514b3 to 2290772 Compare September 3, 2020 15:47
@L3n41c
L3n41c requested a review from AlexandreYang September 3, 2020 15:49
AlexandreYang
AlexandreYang previously approved these changes Sep 4, 2020
@L3n41c
L3n41c force-pushed the lenaic/network_check_on_containers branch from 493d2cf to 5c864e4 Compare September 4, 2020 09:42
@AlexandreYang
AlexandreYang self-requested a review September 4, 2020 11:33

@AlexandreYang AlexandreYang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Last 2 things:

1/ Any reason the label is changelog/Changed (will trigger a major version bump, breaking changes) instead of changelog/Added (will trigger a minor version bump, enhancements) ?

Same comment for #7479 it's not too late to change since the base is not released yet.

We follow semver for versionning.

2/ We need to release datadog_checks_base, I can help for that, but we need to address 1/ first.

Once done, we need to update

CHECKS_BASE_REQ = 'datadog_checks_base'

to CHECKS_BASE_REQ = 'datadog_checks_base>=XXX' to the newly released version.

This helps preventing people installing network check (agent integration install datadog-network...) on older agents that doesn't support passing env to get_subprocess_output.

@AlexandreYang AlexandreYang changed the title [network] Pass PROC_ROOT to ss Pass PROC_ROOT to ss Sep 4, 2020
@AlexandreYang AlexandreYang changed the title Pass PROC_ROOT to ss Pass PROC_ROOT as environment variable to ss Sep 4, 2020
@L3n41c
L3n41c merged commit 2337e66 into master Sep 7, 2020
@L3n41c
L3n41c deleted the lenaic/network_check_on_containers branch September 7, 2020 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants