Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix don't swallow the error when building zap logger #4102

Merged

Conversation

git-hulk
Copy link
Contributor

@git-hulk git-hulk commented Apr 1, 2021

What changed?
Fix don't swallow the error when building zap logger

Why?

Currently, start the cadence server would be panic when
failed to build the zap logger. It will cause confusion since
the error was swallowed.

How did you test it?

test local with no permission log dir

Potential risks
no

Currently, start the cadence server would be panic when
failed to build the zap logger. It will cause confusion since
the error was swallowed.
@meiliang86 meiliang86 requested review from a team and longquanzheng April 1, 2021 23:05
@@ -299,7 +299,8 @@ func initializeDomainHandler(
func initializeLogger(
serviceConfig *config.Config,
) log.Logger {
return loggerimpl.NewLogger(serviceConfig.Log.NewZapLogger())
zapLogger, _ := serviceConfig.Log.NewZapLogger()
Copy link
Contributor

Choose a reason for hiding this comment

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

log fatal or panic here in case of error?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you don't have a logger, so the only thing you can do is to panic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I have used the ErrorAndExited to log the error and exit

@meiliang86 meiliang86 requested a review from a team April 1, 2021 23:13
@coveralls
Copy link

coveralls commented Apr 1, 2021

Pull Request Test Coverage Report for Build 6f97086c-b2ec-43a0-84a0-eedca1d3a7df

  • 2 of 18 (11.11%) changed or added relevant lines in 5 files are covered.
  • 80 unchanged lines in 13 files lost coverage.
  • Overall coverage decreased (-0.02%) to 67.963%

Changes Missing Coverage Covered Lines Changed/Added Lines %
bench/lib/context.go 0 1 0.0%
canary/runner.go 0 4 0.0%
tools/cli/domainUtils.go 0 5 0.0%
cmd/server/cadence/server.go 0 6 0.0%
Files with Coverage Reduction New Missed Lines %
common/task/weightedRoundRobinTaskScheduler.go 1 89.64%
host/signalworkflowTest.go 1 95.53%
service/history/execution/mutable_state_task_refresher.go 1 75.29%
common/persistence/cassandra/cassandraPersistenceUtil.go 2 92.62%
common/persistence/executionStore.go 2 73.9%
common/task/fifoTaskScheduler.go 2 87.63%
service/history/execution/mutable_state_builder.go 2 69.85%
service/history/task/transfer_standby_task_executor.go 2 90.77%
service/history/queue/processor_base.go 7 61.82%
service/history/shard/context.go 8 61.88%
Totals Coverage Status
Change from base Build 57b85506-5696-4904-9735-e8a190fcf0ff: -0.02%
Covered Lines: 98645
Relevant Lines: 145146

💛 - Coveralls

@Groxx
Copy link
Member

Groxx commented Apr 7, 2021

Huh. Why don't we have this passed in? Constructing a logger seems doomed to be over-complicated (as we expose more and more logger-configuration fields) and less flexible (zap loggers can do effectively anything, there's no reason for us to limit them).

Accepting a logger would also simplify the log, _ := config.NewZapLogger() case in tests: pass in a zaptest.NewLogger(t) instead of constructing one and trying to work around the test environment.

@longquanzheng
Copy link
Contributor

Huh. Why don't we have this passed in? Constructing a logger seems doomed to be over-complicated (as we expose more and more logger-configuration fields) and less flexible (zap loggers can do effectively anything, there's no reason for us to limit them).

Accepting a logger would also simplify the log, _ := config.NewZapLogger() case in tests: pass in a zaptest.NewLogger(t) instead of constructing one and trying to work around the test environment.

Which one are you referring to? I think we have to do this way because they are in from different main() : server, bench, canary and CLI. So we can't pass a logger from server to cli code, hehe.
Or in other words, we already try the best to pass around/initiate only once.

@longquanzheng longquanzheng merged commit 07d5371 into cadence-workflow:master Apr 7, 2021
@longquanzheng
Copy link
Contributor

@Groxx I merged this PR but if you see a way that we can improve by passing around logger, we make do a refactoring

yux0 pushed a commit to yux0/cadence that referenced this pull request May 4, 2021
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