Skip to content

Conversation

nmittler
Copy link
Contributor

@nmittler nmittler commented Dec 19, 2017

This completes the transition from the entire Istio code base over
to the new Istio logging library (replacing glog).

The mapping is roughly as follows:

glog.Debug -> log.Debug
glog.Info -> log.Info
glog.Warning -> log.Warn
glog.Error -> log.Error
glog.Fatal -> log.Error + os.Exit(-1)
glog.V(1) -> log.Info
glog.V(2) -> log.Info
glog.V(3+) -> log.Debug
glog.Flush -> log.Sync

Partially addresses #2174

None

args = append(args, "-l", "trace")
} else if glog.V(3) {
} /* TODO(nmittler): When should the "debug" flab be used?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kyessenov any thoughts on how to handle this?

Copy link
Contributor

Choose a reason for hiding this comment

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

This will require a new flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kyessenov I've created #2257 to address this.

@codecov
Copy link

codecov bot commented Dec 19, 2017

Codecov Report

Merging #2240 into master will decrease coverage by 0.17%.
The diff coverage is 51.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2240      +/-   ##
==========================================
- Coverage   76.42%   76.24%   -0.18%     
==========================================
  Files         221       69     -152     
  Lines       19810     5886   -13924     
==========================================
- Hits        15139     4488   -10651     
+ Misses       3846     1155    -2691     
+ Partials      825      243     -582
Flag Coverage Δ
#broker 47.27% <50%> (-28.1%) ⬇️
#mixer ?
#pilot 76.95% <46.56%> (-1.47%) ⬇️
#security 87.08% <79.16%> (+10.89%) ⬆️
Impacted Files Coverage Δ
broker/pkg/version/version.go 100% <ø> (ø) ⬆️
pilot/platform/cloudfoundry/config.go 94.73% <ø> (ø) ⬆️
broker/pkg/model/osb/catalog.go 100% <ø> (ø) ⬆️
pilot/platform/eureka/controller.go 90.62% <0%> (ø) ⬆️
pilot/platform/kube/client.go 40.9% <0%> (ø) ⬆️
pilot/cmd/pilot-discovery/server/monitoring.go 64% <0%> (ø) ⬆️
pilot/platform/consul/monitor.go 80.88% <0%> (+69.11%) ⬆️
pilot/platform/cloudfoundry/controller.go 64.28% <0%> (ø) ⬆️
pilot/platform/kube/register.go 43.13% <0%> (+0.41%) ⬆️
pilot/proxy/resolve.go 0% <0%> (ø) ⬆️
... and 170 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 87aa56e...599b50d. Read the comment docs.

@ldemailly
Copy link
Member

glog.V(1) -> log.Warn

That seems wrong, any Vlog should be Info or lower (verbose means verbose not warning)

Maybe this shows another level (Verbose) should be added ?

@kyessenov
Copy link
Contributor

glov.V(1) is not warn! It's all verbose. But we should not print every verbose log message, since there are tons per-request ones.

@nmittler
Copy link
Contributor Author

@ldemailly @kyessenov I've corrected the V(1) mapping in the description ... it was already Info in the code.

Copy link
Contributor

@kyessenov kyessenov left a comment

Choose a reason for hiding this comment

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

Please re-direct client-go log output to istio log. Without a single log output, we have a strict degradation in debuggability of Pilot. I want to be able to get a sequential trace across the stack, not two separate log streams.

@nmittler
Copy link
Contributor Author

Please re-direct client-go log output to istio log. Without a single log output, we have a strict degradation in debuggability of Pilot. I want to be able to get a sequential trace across the stack, not two separate log streams.

@kyessenov is that what glog was doing previously? If not, it would seem to be beyond the scope of this PR.

@kyessenov
Copy link
Contributor

If you try to debug k8s, there's a major difference between different log levels. Level 10 is per-request, typically. Can we preserve that in istio log? We have way too much logging already, and we're losing all the tuning we've done before.

@nmittler
Copy link
Contributor Author

If you try to debug k8s, there's a major difference between different log levels. Level 10 is per-request, typically. Can we preserve that in istio log? We have way too much logging already, and we're losing all the tuning we've done before.

@kyessenov so what do you propose as the mapping?

@kyessenov
Copy link
Contributor

Not sure, maybe @geeknoid has some ideas?..

@nmittler
Copy link
Contributor Author

@kyessenov @geeknoid IIRC, Martin's changes to Mixer mapped all V(x) logs to Debug. Would that address your concerns?

@nmittler
Copy link
Contributor Author

@geeknoid any thoughts on #2240 (comment)?

@nmittler
Copy link
Contributor Author

Please re-direct client-go log output to istio log.

@kyessenov can you provide me more detail on what would need to be done here?

@nmittler
Copy link
Contributor Author

nmittler commented Dec 19, 2017

@geeknoid I'm seeing that the pilot-integration-x tests are failing with Too long with no output. Do we need to redirect logs to stdout or something?

@geeknoid geeknoid removed their request for review December 19, 2017 18:25
@nmittler
Copy link
Contributor Author

/retest

@nmittler nmittler added the pilot label Dec 19, 2017
@ldemailly
Copy link
Member

@geeknoid what do you think about adding a level in between Debug and Info : Verbose ?

@nmittler nmittler force-pushed the logging branch 2 times, most recently from 18bb461 to 256ade5 Compare December 19, 2017 21:08
@geeknoid
Copy link
Contributor

@ldemailly We have limited flexibility in introducing new levels since our logging package is a layer on top of the Zap logger, which is where the levels are defined. What we have:

Error, Warning, Info: on all the time
Debug: all the extra stuff that must be explicitly turned on

If there's some Info-level things that we want to be conditionally enabled, you need to have a separate command-line option to control that specifically.

pilot/cmd/cmd.go Outdated
// AddFlags carries over glog flags with new defaults
func AddFlags(rootCmd *cobra.Command) {
// InitRootCommand Initializes the root command with logging configuration
func InitRootCommand(rootCmd *cobra.Command, loggingOptions *log.Options) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kyessenov please review the changes here for configuring istio logging and glogs

// Should be called right after flag.Parse().
func InitGlog() error {
func InitLogging() error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kyessenov Also please review here

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this should be done. @geeknoid?

Copy link
Contributor

Choose a reason for hiding this comment

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

So a couple things:

  • At the moment, Mixer does none of that. Output go to stdout unless the user redirects it to a specific file.

  • Uses of glog in Mixer need to be configured independently using glog options.

  • I'm playing right now with providing a replacement for glog which calls into the zap library directly. This would eliminate all classic glog command-line options and features from our builds.

  • I'm expecting to extend our logging package to support log rotation explicitly. It's fairly easy to do on top of zap. Adding this functionality will involve introducing new cmd-line flags to allow the user to select a target directory, max file size, num files to keep, etc.

So given all the above, I would probably just go with a simple story for the time being, like Mixer has. The smarts will then be introduced by silent upgrades to the log package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@geeknoid sgtm. I've updated the PR to remove some of the glog-specific gunk.

@kyessenov
Copy link
Contributor

Looks mostly OK from what I scanned over in pilot. Seems like you made V<=2 Info and V > 2 Debug. That means we get too much Info levels and too much for Debug levels, but that should not be blocking this PR.

I'd prefer if we had a discussion before undertaking the entire log swapping business. I don't see it as valuable since it makes it hard to separate code out of istio repository.

This completes the transition from the entire Istio code base over
to the new Istio logging library (replacing glog).

The mapping is roughly as follows:

glog.Debug -> log.Debug
glog.Info -> log.Info
glog.Warning -> log.Warn
glog.Error -> log.Error
glog.Fatal -> log.Error + os.Exit(-1)
glog.V(1) -> log.Info
glog.V(2) -> log.Info
glog.V(3+) -> log.Debug
glog.Flush -> log.Sync

Partially addresses istio#2174
@nmittler
Copy link
Contributor Author

nmittler commented Jan 2, 2018

@costinm I found and fixed the problem

@nmittler
Copy link
Contributor Author

nmittler commented Jan 2, 2018

@kyessenov mind re-lgtm/approving?

@ZackButcher
Copy link
Contributor

/lgtm
/approve

@istio-merge-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@kyessenov
Copy link
Contributor

/lgtm
/approve

@istio-merge-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kyessenov, ZackButcher

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@istio-merge-robot
Copy link

Automatic merge from submit-queue.

@istio-merge-robot istio-merge-robot merged commit b25c2e9 into istio:master Jan 2, 2018
@ldemailly
Copy link
Member

ldemailly commented Jan 2, 2018

glog.V(2) -> log.Info

that seems like way too many logs by default
also V(x) has short circuit logic / is often bracketted in if (glog.V(2) { ... calculate expensive debug... } what's the "istio logger" way of doing that ?

@ZackButcher
Copy link
Contributor

@ldemailly
Copy link
Member

ldemailly commented Jan 2, 2018

So are we going to run prod with warnings only ? as I mentioned earlier there are rare info messages one wants to always see in the logs without artificially labelling them as warning

@ZackButcher
Copy link
Contributor

ZackButcher commented Jan 2, 2018

IIRC, by default we log Error, Warning, and Info. I believe Pilot was originally running with -v 2 anyway, so this shouldn't result in more logging than today:

@ldemailly
Copy link
Member

for perf test I remove -v 2 so I get Info... what should I do now ?

Copy link
Contributor

@mattdelco mattdelco left a comment

Choose a reason for hiding this comment

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

Parts of the build (at least bazel_to_go) seem unhappy with the comments added to some of the BUILD files. E.g.

Step #1: ERROR: /workspace/go/src/istio.io/istio/broker/pkg/model/osb/BUILD:17:9: syntax error at '//': expected expression.

@@ -12,6 +12,9 @@ go_library(
"servicePlan.go",
],
deps = [
"//pkg/log:go_default_library",

// TODO(nmittler): Remove this
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be # not //

deps = [
"//pkg/log:go_default_library",

// TODO(nmittler): Remove this
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be # not //

nmittler added a commit to nmittler/istio that referenced this pull request Jan 2, 2018
@nmittler
Copy link
Contributor Author

nmittler commented Jan 2, 2018

@mattdelco Just filed #2373 to fix

@nmittler nmittler mentioned this pull request Jan 2, 2018
istio-merge-robot pushed a commit that referenced this pull request Jan 3, 2018
Automatic merge from submit-queue.

Fix BUILD files
@ldemailly
Copy link
Member

@ZackButcher for perf test I remove -v 2 so I get Info logging (pre 'new logger')... what should I do now ?

@ZackButcher
Copy link
Contributor

ZackButcher commented Jan 3, 2018

Use the flags in the new log package:

istio/pkg/log/options.go

Lines 188 to 189 in 337c240

cmd.PersistentFlags().StringVar(&o.outputLevel, "log_output_level", o.outputLevel,
"The minimum logging level of messages to output, can be one of debug, info, warning, error, or none")

Off topic of this PR: we really need to standardize our flag format; this mix of flag-name and flag_name sucks; personally I'm a much bigger fan of flag-name /cc @geeknoid

@ldemailly
Copy link
Member

so you are suggesting people run prod with warning, that seems wrong as some low volume info level are useful, we don’t have the right levels

@ZackButcher
Copy link
Contributor

No, our intent is that you can run at info in prod (and this is the default behavior). We likely need to rework some of our logging to make that a reality.

@ldemailly
Copy link
Member

Just to be clear it's a regression from 0.4.0 where running -v 0 would give you some amount of Info separated from verbose per request logging and we lost this now by merging v1,v2 and info into a single bucket

@ldemailly
Copy link
Member

let's move the levels discussion to #2400

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.

10 participants