Skip to content

Commit

Permalink
Fix max file size check to use getMaxFileSize (#113723)
Browse files Browse the repository at this point in the history
* Fix max file size check to use getMaxFileSize

* Update docs/changelog/113723.yaml

* CURSE YOU SPOTLESS
  • Loading branch information
prdoyle committed Sep 30, 2024
1 parent 9365efb commit a6b104d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/changelog/113723.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 113723
summary: Fix max file size check to use `getMaxFileSize`
area: Infra/Core
type: bug
issues:
- 113705
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,12 @@ static class MaxFileSizeCheck implements BootstrapCheck {

@Override
public BootstrapCheckResult check(BootstrapContext context) {
final long maxFileSize = getMaxFileSize();
final long maxFileSize = getProcessLimits().maxFileSize();
if (maxFileSize != Long.MIN_VALUE && maxFileSize != ProcessLimits.UNLIMITED) {
final String message = String.format(
Locale.ROOT,
"max file size [%d] for user [%s] is too low, increase to [unlimited]",
getMaxFileSize(),
maxFileSize,
BootstrapInfo.getSystemProperties().get("user.name")
);
return BootstrapCheckResult.failure(message);
Expand All @@ -426,8 +426,8 @@ public BootstrapCheckResult check(BootstrapContext context) {
}
}

long getMaxFileSize() {
return NativeAccess.instance().getProcessLimits().maxVirtualMemorySize();
protected ProcessLimits getProcessLimits() {
return NativeAccess.instance().getProcessLimits();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ public void testMaxFileSizeCheck() throws NodeValidationException {
final AtomicLong maxFileSize = new AtomicLong(randomIntBetween(0, Integer.MAX_VALUE));
final BootstrapChecks.MaxFileSizeCheck check = new BootstrapChecks.MaxFileSizeCheck() {
@Override
long getMaxFileSize() {
return maxFileSize.get();
protected ProcessLimits getProcessLimits() {
return new ProcessLimits(ProcessLimits.UNKNOWN, ProcessLimits.UNKNOWN, maxFileSize.get());
}
};

Expand Down

0 comments on commit a6b104d

Please sign in to comment.