craigcondit commented on code in PR #773:
URL: https://github.com/apache/yunikorn-core/pull/773#discussion_r1454178038
##########
pkg/log/rate_limited_logger_test.go:
##########
@@ -48,7 +48,7 @@ func TestRateLimitedLog(t *testing.T) {
),
)
// log once within one minute
- logger := &rateLimitedLogger{
+ logger := &RateLimitedLogger{
Review Comment:
Use the public constructor function we've already created for this.
##########
pkg/scheduler/objects/application.go:
##########
@@ -2063,3 +2064,11 @@ func (sa *Application)
SetTimedOutPlaceholder(taskGroupName string, timedOut int
sa.placeholderData[taskGroupName].TimedOut = timedOut
}
}
+
+// GetAppLog lazy initializes the application logger the first time is needed.
See YUNIKORN-2320.
+func GetAppLog() *log.RateLimitedLogger {
Review Comment:
Rename to `getRateLimitedAppLog()` to match var name. If possible refactor
`entrypoint` test to not need this value to be public, or add a secondary test
in the `scheduler/objects` to call this.
##########
pkg/scheduler/objects/application.go:
##########
@@ -2063,3 +2064,11 @@ func (sa *Application)
SetTimedOutPlaceholder(taskGroupName string, timedOut int
sa.placeholderData[taskGroupName].TimedOut = timedOut
}
}
+
+// GetAppLog lazy initializes the application logger the first time is needed.
See YUNIKORN-2320.
Review Comment:
Nit: remove the YUNIKORN-2320 reference from the comment. Git history is all
we need here, not extra comments.
##########
pkg/scheduler/objects/application.go:
##########
@@ -973,7 +974,7 @@ func (sa *Application) tryAllocate(headRoom
*resources.Resource, allowPreemption
// the iterator might not have the node we need as it
could be reserved, or we have not added it yet
node := getNodeFn(requiredNode)
if node == nil {
- rateLimitedLog.Warn("required node is not found
(could be transient)",
+ GetAppLog().Warn("required node is not found
(could be transient)",
Review Comment:
Remembering why this was rate-limited in the first place, we really need to
use `Info()` here rather than `Warn()`. `Warn()` generates stack traces, which
is really not appropriate here, especially when this is a (somewhat) common
occurrence. It's nice to know about, but should not spam the logs with stack
traces, even when rate limited.
##########
pkg/scheduler/objects/application.go:
##########
@@ -51,7 +51,8 @@ var (
defaultPlaceholderTimeout = 15 * time.Minute
)
-var rateLimitedLog = log.RateLimitedLog(log.SchedApplication, time.Second)
+var initAppLogOnce sync.Once
+var appLog *log.RateLimitedLogger
Review Comment:
Now that I'm seeing this, I realize this is not the only app log (just the
rate-limited one). Probably `rateLimitedAppLog` would be better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]