Workaround for JDK bug with total mem on Debian8#68542
Workaround for JDK bug with total mem on Debian8#68542danhermann merged 2 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/es-core-features (Team:Core/Features) |
| * on some Linux variants such as Debian8. | ||
| */ | ||
| @SuppressForbidden(reason = "access /proc/meminfo") | ||
| List<String> readProcMeminfo() throws IOException { |
There was a problem hiding this comment.
I'm not thrilled by everything that happens here, but by default, the value is cached so that this method shouldn't be called more than once per second and probably less frequently on systems with appropriate monitoring intervals.
|
@elasticmachine run elasticsearch-ci/1 |
|
@elasticmachine run elasticsearch-ci/default-distro |
henningandersen
left a comment
There was a problem hiding this comment.
LGTM, thanks for fixing this @danhermann
I wonder if we should reenable various tests on debian 8 that were previously disabled due to this, for instance TransportGetAutoscalingCapacityActionIT and some of the ML rest tests? Can definitely also be handled in a follow-up.
| final Optional<String> maybeMemTotalLine = memTotalLines.size() == 1 ? Optional.of(memTotalLines.get(0)) : Optional.empty(); | ||
| if (maybeMemTotalLine.isPresent()) { | ||
| final String memTotalLine = maybeMemTotalLine.get(); |
There was a problem hiding this comment.
| final Optional<String> maybeMemTotalLine = memTotalLines.size() == 1 ? Optional.of(memTotalLines.get(0)) : Optional.empty(); | |
| if (maybeMemTotalLine.isPresent()) { | |
| final String memTotalLine = maybeMemTotalLine.get(); | |
| if (memTotalLines.size() == 1) { | |
| final String memTotalLine = memTotalLines.get(0); |
| OsProbe probe = buildStubOsProbe(true, "", List.of(), meminfoLines); | ||
| assertThat(probe.getTotalMemFromProcMeminfo(), equalTo(0L)); | ||
|
|
||
| // MemTotal line with invalid value |
There was a problem hiding this comment.
Let us for completeness also add a case of having wrong unit.
| assertNull(cgroup); | ||
| } | ||
|
|
||
| public void testGetTotalMemFromProcMeminfo() throws Exception { |
There was a problem hiding this comment.
Can we also add a test that does not stub out /proc/meminfo and verify that it gives us something > 0? It should run on debian 8 only.
|
@elasticmachine run elasticsearch-ci/bwc |
|
Thanks, @henningandersen! I've made the changes you requested and will open another PR to re-enable the tests that were failing due to this issue. Let me know if you see anything else related to this that needs to be addressed. |
Unmute the YAML tests that were muted due to the problem of elastic#66885. The underlying problem was fixed by elastic#68542.
Reads total system memory from
/proc/meminfoon Debian8 systems if the JDK reports0total memory. See #66885 (comment) for more background.Fixes #66629.