-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Add hack for Docker cgroups #22757
Add hack for Docker cgroups #22757
Conversation
Also, I should point out that I built a new Docker image from a SNAPSHOT build of Elasticsearch with this fix, and I was able to obtain the expected cgroup stats. |
Docker cgroups are mounted in the wrong place (i.e., inconsistently with /proc/self/cgroup). This commit adds an undocumented hack for working around, for now.
b77482e
to
1401bef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a few minor comments.
@@ -191,6 +191,11 @@ private String readSingleLine(final Path path) throws IOException { | |||
// pattern for lines in /proc/self/cgroup | |||
private static final Pattern CONTROL_GROUP_PATTERN = Pattern.compile("\\d+:([^:,]+(?:,[^:,]+)?):(/.*)"); | |||
|
|||
// this property is to support a hack to workaround an issue with Docker containers not mounting the cgroups hierarchy inconsistently |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be "not mounting...consistently" or "mounting...inconsistently"? But I would think not the current double negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll fix in the morning before merging.
// this property is to support a hack to workaround an issue with Docker containers not mounting the cgroups hierarchy inconsistently | ||
// with respect to /proc/self/cgroup; for Docker containers this should be set to "/" | ||
private static final String CONTROL_GROUPS_PATH_OVERRRIDE = | ||
(String) BootstrapInfo.getSystemProperties().get("es.cgroups.path.override"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be System.getProperty
? I thought the point of BootstrapInfo.getSystemProperties()
was when you wanted to call System.getProperties()
(which we have in forbidden apis)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I'll change.
This commit cleans up a few issues with the cgroups hierarchy hack: - renames the property from es.cgroups.path.override to es.cgroups.hierarchy.override - fixes a double negative in a comment - just uses System#getProperty instead of BootstrapInfo#getSystemProperties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@elasticmachine test this please |
thanks for verifying. it's hard to test I guess... I wonder if we should port this to 5.1.x - but I might be mistaking that this exists already in 5.1.x.. not sure |
+1, I'll port to 5.1 as well (you're not mistaken). |
retest this please |
Docker cgroups are mounted in the wrong place (i.e., inconsistently with /proc/self/cgroup). This commit adds an undocumented hack for working around, for now. Relates #22757
Docker cgroups are mounted in the wrong place (i.e., inconsistently with /proc/self/cgroup). This commit adds an undocumented hack for working around, for now. Relates #22757
Docker cgroups are mounted in the wrong place (i.e., inconsistently with /proc/self/cgroup). This commit adds an undocumented hack for working around, for now. Relates #22757
controllerMap.put(controller, matcher.group(2)); | ||
if (CONTROL_GROUPS_HIERARCHY_OVERRIDE != null) { | ||
/* | ||
* Docker violates the relationship between /proc/self/cgroups and the /sys/fs/cgroup hierarchy. It's possible that this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasontedor Very minor typo, but should be /proc/self/cgroup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker mounts cgroup stats inconsistently with the hierarchy in /proc/self/cgroup. This breaks the logic for traversing from /proc/self/cgroup to the stats for a process running inside a container. In core Elasticsearch, an undocumented hack was added to support this, for now. Thus, for cgroup stats to be available from Elasticsearch running inside a Docker container, the Elasticsearch process should be started with `-Des.cgroups.hierarchy.override=/`. Add hack for obtaining cgroup stats and comment it. Relates #25 Relates elastic/elasticsearch#22757
Docker mounts cgroup stats inconsistently with the hierarchy in /proc/self/cgroup. This breaks the logic for traversing from /proc/self/cgroup to the stats for a process running inside a container. In core Elasticsearch, an undocumented hack was added to support this, for now. Thus, for cgroup stats to be available from Elasticsearch running inside a Docker container, the Elasticsearch process should be started with `-Des.cgroups.hierarchy.override=/`. Add hack for obtaining cgroup stats and comment it. Relates #25 Relates elastic/elasticsearch#22757
Docker mounts cgroup stats inconsistently with the hierarchy in /proc/self/cgroup. This breaks the logic for traversing from /proc/self/cgroup to the stats for a process running inside a container. In core Elasticsearch, an undocumented hack was added to support this, for now. Thus, for cgroup stats to be available from Elasticsearch running inside a Docker container, the Elasticsearch process should be started with `-Des.cgroups.hierarchy.override=/`. Add hack for obtaining cgroup stats and comment it. Relates #25 Relates elastic/elasticsearch#22757
Docker cgroups are mounted in the wrong place (i.e., inconsistently with /proc/self/cgroup). This commit adds an undocumented hack for working around, for now.
Relates #21029