-
Notifications
You must be signed in to change notification settings - Fork 73
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
Fixes #18357: Add check for free space #3301
Fixes #18357: Add check for free space #3301
Conversation
final case class SpaceInfo(val partition: String, val free: Long, val available: Long){ | ||
def pourcentage: Double = | ||
if (available != 0) { | ||
(free * 100 / BigDecimal(available)).setScale(2, BigDecimal.RoundingMode.HALF_UP).toDouble |
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.
not sur why the BigDecimal here? BigDecimal(free * 100)
if you want to avoid an overflow on the mult, but why on the denominator?
partitionsList <- IOResult.effect{ | ||
partc.map { x => | ||
val file = new io.File(x) | ||
SpaceInfo(x, file.getFreeSpace, file.getTotalSpace) |
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 should do that only once you have filtered partition and found what you want.
} | ||
} | ||
} yield { | ||
val (varSpaceInfo, rootSpaceInfo) = partitionsList.partition(_.partition.regionMatches(true, 0, "/var", 0, 4)) |
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.
I have an hard time followinf what is done, while it's (should be) simple.
Perhaps can you add comments for the four big steps:
- find partition
- get memory info
- find problems (do math)
- transform to result
PR rebased |
23e31fd
to
465cae5
Compare
def name: CheckName = CheckName("Disk free space available") | ||
|
||
final case class SpaceInfo(val partition: String, val free: Long, val available: Long){ | ||
def pourcentage: Double = |
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.
percent
fc88cd4
to
afd003f
Compare
afd003f
to
b2b1ada
Compare
b2f9f68
to
957398d
Compare
957398d
to
1d281b1
Compare
Commit modified |
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.
WOUAH! The changes are striking since last time. Now, the logic is super clear and the code feels much shorter/concise. Nice work!
This PR is not mergeable to upper versions. |
OK, merging this PR |
https://issues.rudder.io/issues/18357