feat: create disk memory health checker#5781
Conversation
0e516c8 to
6655182
Compare
jrhee17
left a comment
There was a problem hiding this comment.
Looks good overall! Left a minor comment 👍
| * @param targetTotalDiskSpace Target total disk space in bytes. | ||
| * @return an instance of {@link HealthChecker} configured with the provided disk memory space targets. | ||
| */ | ||
| static HealthChecker ofDisk(long targetFreeDiskSpace, long targetTotalDiskSpace, String path) { |
There was a problem hiding this comment.
I'm not sure it would be very useful to allow users to specify the path.
What do you think of just setting this value as a new File(".") like done in spring-boot by default?
I also don't think accepting targetTotalDiskSpace would be very useful since it would be mostly static in most cases.
There was a problem hiding this comment.
Ideally, we should discover all disks in the system automatically (with options to specify or filter filesystem), detect the size of the filesystem. We should also allow a user to specify percentage values.
There was a problem hiding this comment.
I see, I prefer a single health checker is responsible for a single disk as the condition for health checking may become complex. I guess it's fine to leave the File parameter as is then.
There was a problem hiding this comment.
Yeah, we could indeed make use of composition of multiple health checkers to check multiple filesystems. Shall we focus on handling a single filesystem first and see how we could evolve this? That is, yeah, let's keep the File parameter.
There was a problem hiding this comment.
Thanks for all comments :) Unfortunately, I am not sure what I should do exactly.
Should I remove percentage values if then?
There was a problem hiding this comment.
| static HealthChecker ofDisk(long targetFreeDiskSpace, long targetTotalDiskSpace, String path) { | |
| static HealthChecker ofDisk(long targetFreeDiskSpace, File file) { |
Then we only need targetFreeDiskSpace and file as parameter at first?
I think we can enhance it in the future :)
There was a problem hiding this comment.
@injae-kim Thank you for your clarification. I get it. Will fix it within this weekend🙂
|
FYI) @AnneMayor is my opensource mentoring memeber, contributed on spring-projects/spring-data-redis#2905! Welcome to armeria! 😃 |
442e518 to
8070a07
Compare
|
I fixed it. Please, review it :) |
d9e7f3f to
f1e1716
Compare
jrhee17
left a comment
There was a problem hiding this comment.
Left some more comments 👍
| void setup() { | ||
| serverChannelPipeline.set(null); | ||
|
|
||
| bodyPublisher = new BodyPublisher() { |
There was a problem hiding this comment.
Can you revert unrelated changes in this PR? I prefer that flaky tests be handled separately - I think it's fine if some flaky tests don't pass in the CI run
| * Both free disk space must be (inclusive) lower than the specified threshold in order | ||
| * for the {@link HealthChecker} to report as healthy. | ||
| * | ||
| * @param targetFreeDiskSpace Target free disk space in bytes. |
There was a problem hiding this comment.
| * @param targetFreeDiskSpace Target free disk space in bytes. | |
| * @param diskSpacePercentage the target free disk space as a percentage (0 - 1). |
There was a problem hiding this comment.
I ammended targetDiskSpacePercentage as you suggested below. Please, consider it.
| * Creates a new instance of {@link HealthChecker} | ||
| * which reports health based on disk space of specific file path. |
There was a problem hiding this comment.
| * Creates a new instance of {@link HealthChecker} | |
| * which reports health based on disk space of specific file path. | |
| * Creates a new instance of {@link HealthChecker} which reports health based on free disk space | |
| * of the file system the specified path belongs to. |
| * @param targetFreeDiskSpace Target free disk space in bytes. | ||
| * @return an instance of {@link HealthChecker} configured with the provided disk memory space targets. | ||
| */ | ||
| static HealthChecker ofDisk(double targetFreeDiskSpace, File path) { |
There was a problem hiding this comment.
| static HealthChecker ofDisk(double targetFreeDiskSpace, File path) { | |
| static HealthChecker ofDisk(double targetDiskSpacePercentage, File path) { |
| private final File path; | ||
|
|
||
| DiskMemoryHealthChecker(double targetFreeDiskSpace, File path) { | ||
| checkArgument(targetFreeDiskSpace >= 0, "freeDiskSpace: %s (expected: >= 0)", targetFreeDiskSpace); |
There was a problem hiding this comment.
Since we are dealing with percentages, can you also validate that targetFreeDiskSpace <= 1?
| */ | ||
| @Override | ||
| public boolean isHealthy() { | ||
| return path.getUsableSpace() >= targetFreeDiskSpace; |
There was a problem hiding this comment.
Can you check the percentage of free space instead?
| return path.getUsableSpace() >= targetFreeDiskSpace; | |
| return targetFreeSpacePercentage * path.getTotalSpace() <= path.getUsableSpace(); |
f1e1716 to
539c119
Compare
|
comments resolved. |
539c119 to
5588b14
Compare
| * final DiskMemoryHealthChecker diskMemoryHealthChecker = HealthChecker.ofDisk(100, new File("/tmp")); | ||
| * | ||
| * // Returns false if a file disk usable memory space is less than 100 bytes, | ||
| * // or true if a file disk usable memory space is greater than or equal to 100 bytes. |
There was a problem hiding this comment.
| * final DiskMemoryHealthChecker diskMemoryHealthChecker = HealthChecker.ofDisk(100, new File("/tmp")); | |
| * | |
| * // Returns false if a file disk usable memory space is less than 100 bytes, | |
| * // or true if a file disk usable memory space is greater than or equal to 100 bytes. | |
| * final DiskMemoryHealthChecker diskMemoryHealthChecker = HealthChecker.ofDisk(0.8, new File("/tmp")); | |
| * | |
| * // Returns false if a file disk usable memory space is less than 80%. | |
| * // or true if a file disk usable memory space is greater than or equal to 80%. |
Can you update doc properly too here?
5588b14 to
8ce5606
Compare
|
@injae-kim comments resolved 🙇♀️ |
jrhee17
left a comment
There was a problem hiding this comment.
Left some final comments 👍
|
|
||
| DiskMemoryHealthChecker(double targetFreeSpacePercentage, File path) { | ||
| checkArgument(targetFreeSpacePercentage >= 0 && targetFreeSpacePercentage <= 1, | ||
| "freeDiskSpace: %s (expected < 0 or expected > 1)", targetFreeSpacePercentage); |
There was a problem hiding this comment.
Since that's what we expect
| "freeDiskSpace: %s (expected < 0 or expected > 1)", targetFreeSpacePercentage); | |
| "freeDiskSpacePercentage: %s (expected >= 0 and <= 1)", targetFreeSpacePercentage); |
There was a problem hiding this comment.
Oh, I just meant to express the error status. I didn't think of the normal value comments. Thanks.
| /** | ||
| * Creates a new instance of {@link HealthChecker} which reports health based on free disk space | ||
| * of the file system the specified path belongs to. | ||
| * Both free disk space must be (inclusive) lower than the specified threshold in order |
There was a problem hiding this comment.
| * Both free disk space must be (inclusive) lower than the specified threshold in order | |
| * There must be more free space (inclusive) than the specified threshold in order |
| * @param targetDiskSpacePercentage the target free disk space as a percentage (0 - 1). | ||
| * @return an instance of {@link HealthChecker} configured with the provided disk memory space targets. | ||
| */ | ||
| static HealthChecker ofDisk(double targetDiskSpacePercentage, File path) { | ||
| return new DiskMemoryHealthChecker(targetDiskSpacePercentage, path); | ||
| } |
There was a problem hiding this comment.
Sorry about changing my mind, but freeDiskSpacePercentage seems like a better term since it is analogous to the df linux command, and percentage denotes the type of value.
Can you also replace the name targetFreeSpacePercentage used in DiskMemoryHealthChecker to freeDiskSpacePercentage as well?
| * @param targetDiskSpacePercentage the target free disk space as a percentage (0 - 1). | |
| * @return an instance of {@link HealthChecker} configured with the provided disk memory space targets. | |
| */ | |
| static HealthChecker ofDisk(double targetDiskSpacePercentage, File path) { | |
| return new DiskMemoryHealthChecker(targetDiskSpacePercentage, path); | |
| } | |
| * @param freeDiskSpacePercentage the target free disk space as a percentage (0 - 1). | |
| * @return an instance of {@link HealthChecker} configured with the provided disk memory space targets. | |
| */ | |
| static HealthChecker ofDisk(double freeDiskSpacePercentage, File path) { | |
| return new DiskMemoryHealthChecker(freeDiskSpacePercentage, path); | |
| } |
| * when the target free disk space exceeds a file disk usable space. | ||
| * For example: | ||
| * <pre>{@code | ||
| * final DiskMemoryHealthChecker diskMemoryHealthChecker = HealthChecker.ofDisk(80, new File("/tmp")); |
There was a problem hiding this comment.
| * final DiskMemoryHealthChecker diskMemoryHealthChecker = HealthChecker.ofDisk(80, new File("/tmp")); | |
| * final DiskMemoryHealthChecker diskMemoryHealthChecker = HealthChecker.ofDisk(0.8, new File("/tmp")); |
f4c53c1 to
bf1bc4e
Compare
|
Tick the box to add this pull request to the merge queue (same as
|
Motivation:
HealthCheckerimplementations #1854 issue. I felt interested to solve the problem and opened this PR.Modifications:
Result:
HealthCheckerimplementations #1854 issue.