Skip to content

Commit

Permalink
Fixes #18534: Skip non-standard moint FS for free-space check
Browse files Browse the repository at this point in the history
  • Loading branch information
ElaadF committed Nov 9, 2020
1 parent cd56dd0 commit f8a64ac
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ object HealthcheckUtils {

class HealthcheckService(checks: List[Check]) {

def runAll: ZIO[Any, Nothing, List[HealthcheckResult]] = ZIO.foreach(checks) { c =>
for {
res <- c.run.catchAll { err =>
HealthcheckResult.Critical(
CheckName("All checks run")
, s"A fatal error was encountered when running check '${c.name.value}': ${err.fullMsg}"
).succeed
}
_ <- logHealthcheck(c.name, res)
} yield res
def runAll: ZIO[Any, Nothing, List[HealthcheckResult]] = ZIO.foreach(checks) { c =>
for {
res <- c.run.catchAll { err =>
HealthcheckResult.Critical(
CheckName("All checks run")
, s"A fatal error was encountered when running check '${c.name.value}': ${err.fullMsg}"
).succeed
}
_ <- logHealthcheck(c.name, res)
} yield res
}

private[this] def logHealthcheck(name: CheckName, check: HealthcheckResult): UIO[Unit] = {
Expand Down Expand Up @@ -96,7 +96,9 @@ final object CheckFreeSpace extends Check {

def run: IOResult[HealthcheckResult] = {
val file = root / "proc" / "mounts"
val mountsContent = file.lines.map(x => x.split(" ")(1)).toList

// Here we want to keep lines for standard mounting point, see: https://issues.rudder.io/issues/18534
val mountsContent = file.lines.filter(_.head == '/').map(x => x.split(" ")(1)).toList

// We want to check `/var/*` if none exist take `/`
val partitionToCheck = {
Expand All @@ -106,11 +108,11 @@ final object CheckFreeSpace extends Check {

for {
paritionSpaceInfos <- IOResult.effect {
partitionToCheck.map { x =>
val file = new io.File(x)
SpaceInfo(x, file.getUsableSpace, file.getTotalSpace)
}
}
partitionToCheck.map { x =>
val file = new io.File(x)
SpaceInfo(x, file.getUsableSpace, file.getTotalSpace)
}
}
} yield {
val pcSpaceLeft = paritionSpaceInfos.map(x => (x.path, x.percent)).sortBy(_._2)
pcSpaceLeft match {
Expand Down Expand Up @@ -143,7 +145,6 @@ final class CheckFileDescriptorLimit(val nodeInfoService: NodeInfoService) exten
for {
fdLimitCmd <- RunNuCommand.run(cmd)
res <- fdLimitCmd.await

_ <- ZIO.when(res.code != 0) {
Inconsistency(
s"An error occurred while getting file descriptor soft limit with command '${cmd.display}':\n code: ${res.code}\n stderr: ${res.stderr}\n stdout: ${res.stdout}"
Expand Down

0 comments on commit f8a64ac

Please sign in to comment.