Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add linux condition
  • Loading branch information
ulysses-you committed Nov 2, 2019
commit 266bd10fc6835675c32670878b037311d381decd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import scala.util.Try

import org.apache.hadoop.util.Shell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about checking os.name instead of using hadoop-commons?


import org.apache.spark.{SparkEnv, SparkException}
import org.apache.spark.internal.{config, Logging}
import org.apache.spark.util.Utils
Expand Down Expand Up @@ -62,13 +64,14 @@ private[spark] class ProcfsMetricsGetter(procfsDir: String = "/proc/") extends L
SparkEnv.get.conf.get(config.EVENT_LOG_STAGE_EXECUTOR_METRICS)
val shouldLogStageExecutorProcessTreeMetrics =
SparkEnv.get.conf.get(config.EVENT_LOG_PROCESS_TREE_METRICS)
procDirExists.get && shouldLogStageExecutorProcessTreeMetrics && shouldLogStageExecutorMetrics
procDirExists.get && shouldLogStageExecutorProcessTreeMetrics &&
shouldLogStageExecutorMetrics && Shell.LINUX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move the os check in the first condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure to support only Linux? Other Unix-like systems which have /proc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In hadoop ProcfsMetrics, it checks this ProcfsBasedProcessTree and it already exists long time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like in isProcfsAvailable, we check /proc existence instead of checking Linux like hadoop. Isn't it enough? And for other Unit-like systems which have /proc? We do not need to follow ProcfsBasedProcessTree.

Copy link
Contributor Author

@ulysses-you ulysses-you Nov 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIC the procfs is the linux feature, other unix-like os may be try to compatible with it. Check the /proc dir is not a better idea than check linux os. One point is that, someone can change the /proc information which os not support procfs native and it will be a vulnerability.

Copy link
Member

@viirya viirya Nov 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If /proc is in other Unix-like systems, this change actually removes the support on these systems. Unless we are sure current code does not work for such systems, I think we should not simply remove their support.

}
}

private def computePid(): Int = {
if (!isAvailable || testing) {
return -1;
return -1
}
try {
// This can be simplified in java9:
Expand All @@ -88,7 +91,7 @@ private[spark] class ProcfsMetricsGetter(procfsDir: String = "/proc/") extends L

private def computePageSize(): Long = {
if (testing) {
return 4096;
return 4096
}
try {
val cmd = Array("getconf", "PAGESIZE")
Expand Down