Skip to content

Conversation

@yifeih
Copy link

@yifeih yifeih commented Oct 23, 2018

@robert3005 is this what you were thinking of?

@yifeih yifeih requested review from mccheah and robert3005 October 23, 2018 15:50
@yifeih
Copy link
Author

yifeih commented Oct 23, 2018

chatted with @mccheah , will modify this to use palantir safelogging so we can get unsafe args and also so we're not throwing when the unsafe log line accidentally gets called


package org.apache.spark.internal

trait SafeLogging extends Logging {

Choose a reason for hiding this comment

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

don't extend Logging. You want uses of logInfo et al to be compile-time errors (which you can then address post-merge upstream), rather than runtime.

" executors. Not scaling up further.")
} else if (newlyCreatedExecutors.nonEmpty || currentPendingExecutors != 0) {
logDebug(s"Still waiting for ${newlyCreatedExecutors.size + currentPendingExecutors}" +
safeLogDebug(s"Still waiting for ${newlyCreatedExecutors.size + currentPendingExecutors}" +

Choose a reason for hiding this comment

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

Also rewrite all of these to replace the inline ${} with named SafeArg parameters. Otherwise we'd have to needlessly parse them out later

}


// You can only safelog to SafeLogging logs, everything else is unsupported

Choose a reason for hiding this comment

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

just remove everything below this line, and don't extend Logging

s"com.palantir.${this.getClass.getName.stripSuffix("$")}"
}

protected def safeLogInfo(msg: => String) {
Copy link

@dansanduleac dansanduleac Oct 23, 2018

Choose a reason for hiding this comment

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

have these take a msg: String, params: (=> Arg[_])*
Then pass msg, *params to the log.x method

Choose a reason for hiding this comment

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

That will force the parameters to be safe-logging Arg and not other stuff.
And you can have an override that also takes a throwable after msg

" executors to begin running before requesting for more executors. # of executors in" +
" pending status in the cluster: {currentPendingExecutors}. # of executors that we have" +
" created but we have not observed as being present in the cluster yet:" +
" ${newlyCreatedExecutors}.",
Copy link

Choose a reason for hiding this comment

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

Still a $ here

@mccheah
Copy link

mccheah commented Oct 25, 2018

@vinooganesh

import org.apache.spark.deploy.k8s.Constants._
import org.apache.spark.deploy.k8s.KubernetesConf
import org.apache.spark.internal.Logging
import org.apache.spark.logging.SafeLogging

Choose a reason for hiding this comment

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

maybe we should put this under internal too, to make it obvious it's not for outside consumption

logWarning(s"Executor with id $execId was not detected in the Kubernetes" +
s" cluster after $podCreationTimeout milliseconds despite the fact that a" +
safeLogWarning("Executor with id {execId} was not detected in the Kubernetes" +
" cluster after {podCreationTimeout} milliseconds despite the fact that a" +

Choose a reason for hiding this comment

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

We shouldn't use {named} things inside the message, they won't be templated in by our logging infrastructure.
Better to make units clear in the Arg name e.g.

-SafeArg.of("execId", execId),
-SafeArg.of("podCreationTimeout", podCreationTimeout)
+SafeArg.of("executorId", execId),
+SafeArg.of("podCreationTimeoutMs", podCreationTimeout)

and simplify the message. Something like

Executor was not detected in the Kubernetes cluster after timeout, despite the fact that a previous allocation attempt tried to create it. The executor may have been deleted but the application missed the deletion event.

core/pom.xml Outdated
</dependency>

<!--
The following dependency is used for safe logging

Choose a reason for hiding this comment

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

can you expand on this? :)

@yifeih yifeih merged commit 6975726 into master Oct 30, 2018
@robert3005
Copy link

I am going to comment here again - please squash all merges

@robert3005 robert3005 deleted the yh/logging-v2 branch November 5, 2018 16:32
bulldozer-bot bot pushed a commit that referenced this pull request Jan 7, 2019
## What changes were proposed in this pull request?
Add SafeLogging (similar to #425) to more classes that can be useful:
- k8s classes
- CoarseGrainedSchedulerBackend
- SparkContext
- MemoryStore
- Executor
- CoarseGrainedExecutorBackend
- TorrentBroadCast and Broadcast
robert3005 pushed a commit that referenced this pull request Jan 9, 2019
Add SafeLogging (similar to #425) to more classes that can be useful:
- k8s classes
- CoarseGrainedSchedulerBackend
- SparkContext
- MemoryStore
- Executor
- CoarseGrainedExecutorBackend
- TorrentBroadCast and Broadcast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants