Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

logs: make log level configurable through meshconfig #3650

Merged
merged 1 commit into from
Jun 23, 2021

Conversation

eduser25
Copy link
Contributor

@eduser25 eduser25 commented Jun 23, 2021

New osmLogLevel option has been added under observability meshconfig
spec (seems the most related and relevant to the available categories)
to allow changing the log level of OSM at runtime.

The initial log level flag has been kept as it still mandates boot log
level up to the point configurator and the log level handler are both
up, which then meshconfig value takes over.

The handler can't be easilly moved to the logger package as it
introduces a hard dependency cycle between logger<->configurator, hence
the handler has been left on osm-controller main.

Adds a unit test, and see below a working example on a running deployment.

Fixes #3646

Signed-off-by: Eduard Serra [email protected]

Description:

Affected area:

Functional Area
Control Plane [x]

Please answer the following questions with yes/no.

  1. Does this change contain code from or inspired by another project?

    • Did you notify the maintainers and provide attribution?
  2. Is this a breaking change?

@eduser25 eduser25 requested a review from a team as a code owner June 23, 2021 19:15
@eduser25
Copy link
Contributor Author

...
{"level":"info","component":"envoy/rds","time":"2021-06-23T19:07:17Z","file":"response.go:105","message":"RDS did not fulfill all requested resources (diff: Set{}). Fulfill with empty RouteConfigs."}
{"level":"info","component":"envoy/rds","time":"2021-06-23T19:07:17Z","file":"response.go:105","message":"RDS did not fulfill all requested resources (diff: Set{}). Fulfill with empty RouteConfigs."}
<only info logs til around now>

change to trace through kubectl edit meshconfig

{"level":"info","component":"osm-controller/main","time":"2021-06-23T19:07:58Z","file":"osm-controller.go:371","message":"Global log level changed to: trace"}
{"level":"trace","component":"certificate/CertRotor","time":"2021-06-23T19:08:02Z","file":"rotor.go:51","message":"Cert ads will not be rotated; expires in 87599h58m50.3121094s; renewBeforeCertExpires is 30s"}
{"level":"trace","component":"certificate/CertRotor","time":"2021-06-23T19:08:02Z","file":"rotor.go:51","message":"Cert osm-validator.osm-system.svc will not be rotated; expires in 87599h58m50.429469332s; renewBeforeCertExpires is 30s"}
{"level":"trace","component":"certificate/CertRotor","time":"2021-06-23T19:08:02Z","file":"rotor.go:51","message":"Cert server-0-1.server-0.cluster.local will not be rotated; expires in 23h59m10.113151758s; renewBeforeCertExpires is 30s"}
{"level":"trace","component":"certificate/CertRotor","time":"2021-06-23T19:08:02Z","file":"rotor.go:51","message":"Cert server-0-0.server-0.cluster.local will not be rotated; expires in 23h59m10.272788317s; renewBeforeCertExpires is 30s"}
{"level":"trace","component":"certificate/CertRotor","time":"2021-06-23T19:08:07Z","file":"rotor.go:51","message":"Cert server-0-1.server-0.cluster.local will not be rotated; expires in 23h59m5.112912093s; renewBeforeCertExpires is 30s"}
{"level":"trace","component":"certificate/CertRotor","time":"2021-06-23T19:08:07Z","file":"rotor.go:51","message":"Cert server-0-0.server-0.cluster.local will not be rotated; expires in 23h59m5.272500951s; renewBeforeCertExpires is 30s"}
{"level":"trace","component":"certificate/CertRotor","time":"2021-06-23T19:08:07Z","file":"rotor.go:51","message":"Cert ads will not be rotated; expires in 87599h58m45.311669134s; renewBeforeCertExpires is 30s"}
{"level":"trace","component":"certificate/CertRotor","time":"2021-06-23T19:08:07Z","file":"rotor.go:51","message":"Cert osm-validator.osm-system.svc will not be rotated; expires in 87599h58m45.429139366s; renewBeforeCertExpires is 30s"}
....

reset to info through kubectl edit meshconfig

{"level":"info","component":"osm-controller/main","time":"2021-06-23T19:08:12Z","file":"osm-controller.go:371","message":"Global log level changed to: info"}
<no more trace logs>

@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2021

Codecov Report

Merging #3650 (0411db4) into main (3d2ec16) will increase coverage by 0.12%.
The diff coverage is 67.64%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3650      +/-   ##
==========================================
+ Coverage   67.05%   67.17%   +0.12%     
==========================================
  Files         179      180       +1     
  Lines        8705     8741      +36     
==========================================
+ Hits         5837     5872      +35     
+ Misses       2837     2836       -1     
- Partials       31       33       +2     
Flag Coverage Δ
unittests 67.17% <67.64%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/configurator/mock_client_generated.go 0.00% <0.00%> (ø)
cmd/osm-controller/osm-controller.go 14.28% <50.00%> (-0.10%) ⬇️
cmd/osm-controller/log_handler.go 84.00% <84.00%> (ø)
pkg/configurator/methods.go 69.44% <100.00%> (+0.43%) ⬆️
pkg/catalog/outbound_traffic_policies.go 86.98% <0.00%> (+0.23%) ⬆️
pkg/configurator/client.go 84.48% <0.00%> (+8.62%) ⬆️

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 3d2ec16...0411db4. Read the comment docs.

Copy link
Contributor

@snehachhabria snehachhabria left a comment

Choose a reason for hiding this comment

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

Lets back port this to v0.9 as well ?

Comment on lines 371 to 373
log.Info().Msgf("Global log level changed to: %s", logLevel)
currentLogLevel = logLevel
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: seems unnecessary to log this because we would otherwise see an error.

New `osmLogLevel` option has been added under observability meshconfig
spec (seems the most related and relevant to the available categories)
to allow changing the log level of OSM at runtime.

The initial log level flag has been kept at it still mandates boot log
level up to the point configurator and the log level handler are both
up, which then meshconfig value takes over.

The handler can't be easilly moved to the `logger` package as it
introduces a hard dependency cycle between logger<->configurator, hence
the handler has been left on osm-controller main.

Adds a unit test, and see below a working example on a running deployment.

Fixes openservicemesh#3646

Signed-off-by: Eduard Serra <[email protected]>
@eduser25 eduser25 merged commit 7620d30 into openservicemesh:main Jun 23, 2021
@eduser25 eduser25 deleted the log-fix branch June 23, 2021 21:03
@eduser25
Copy link
Contributor Author

@Mergifyio backport release-v0.9

@mergify
Copy link
Contributor

mergify bot commented Jun 23, 2021

Command backport release-v0.9: success

Backports have been created

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OSM Controller's log level should be configurable via MeshConfig
4 participants