[KYUUBI #1330] fix tool cleaner process bug
<!--
Thanks for sending a pull request!
Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
-->
### _Why are the changes needed?_
<!--
Please clarify why the changes are needed. For instance,
1. If you add a feature, you can talk about the use case of it.
2. If you fix a bug, you can clarify why it is a bug.
-->
When using the tool to help clean up spark on K8s residual cache files, I encountered unreported sleep conditions.
After analysis, it was found that the SSD mounted when `needToDeepClean` was run encountered an incorrect catch exception.
Now, `Try Catch` is added to ensure the normal operation of the function, and deep cleaning is performed by default if a problem occurs. In this case, the disk space still overruns after the cleaning opportunity is missed.
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [x] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request
Closes #1330 from zwangsheng/tools/fix-process.
Closes #1330
6daf483c [zwangsheng] catch nonfatal
89caf897 [zwangsheng] fix tool cleaner process bug
b487cf8c [zwangsheng] fix tool cleaner process bug
Authored-by: zwangsheng <2213335496@qq.com>
Signed-off-by: ulysses-you <ulyssesyou@apache.org>
(cherry picked from commit 60392349a7)
Signed-off-by: ulysses-you <ulyssesyou@apache.org>
This commit is contained in:
parent
603977c7b2
commit
bb9aa660c8
@ -154,13 +154,20 @@ object KubernetesSparkBlockCleaner extends Logging {
|
||||
import scala.sys.process._
|
||||
|
||||
private def needToDeepClean(dir: String): Boolean = {
|
||||
val used = (s"df $dir" #| s"grep $dir").!!
|
||||
.split(" ").filter(_.endsWith("%")) {
|
||||
0
|
||||
}.replace("%", "")
|
||||
info(s"$dir now used $used% space")
|
||||
try {
|
||||
val used = (s"df $dir" #| s"grep $dir").!!
|
||||
.split(" ").filter(_.endsWith("%")) {
|
||||
0
|
||||
}.replace("%", "")
|
||||
info(s"$dir now used $used% space")
|
||||
|
||||
used.toInt > (100 - freeSpaceThreshold)
|
||||
used.toInt > (100 - freeSpaceThreshold)
|
||||
} catch {
|
||||
case NonFatal(e) =>
|
||||
error(s"An error occurs when querying the disk $dir capacity, " +
|
||||
s"return true to make sure the disk space will not overruns: ${e.getMessage}")
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private def doCleanJob(dir: String): Unit = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user