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

Log peer config upon startup (#4118) #4122

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 19 additions & 3 deletions internal/peer/node/start.go
Expand Up @@ -98,6 +98,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"google.golang.org/grpc"
"gopkg.in/yaml.v2"
)

const (
Expand Down Expand Up @@ -185,6 +186,23 @@ func (c custodianLauncherAdapter) Stop(ccid string) error {
}

func serve(args []string) error {
logger.Infof("Starting %s", version.GetInfo())

// Info logging for peer config, includes core.yaml settings and environment variable overrides
allSettings := viper.AllSettings()
settingsYaml, err := yaml.Marshal(allSettings)
if err != nil {
return err
}
logger.Infof("Peer config with combined core.yaml settings and environment variable overrides:\n%s", settingsYaml)

// Debug logging for peer environment variables
logger.Debugf("Environment variables:")
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry Dave, a nit: any specific reason why we use debug for this but info for the previous?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was debating this myself. In my opinion the exact peer config should be easily knowable by every user and support engineer hence Info level. This is consistent with what orderer node provides but for some reason peer never provided it.
The wider set of environment variables may be less important and potentially could leak sensitive information about the operating environment hence Debug level.
However, showing the environment variables will help a user or support engineer know whether a certain config setting came from core.yaml or from an environment variable override, so it is valuable information when troubleshooting a peer config.
I could go either way, WDYT?

envVars := os.Environ()
for _, envVar := range envVars {
logger.Debug(envVar)
}

// currently the peer only works with the standard MSP
// because in certain scenarios the MSP has to make sure
// that from a single credential you only have a single 'identity'.
Expand All @@ -201,9 +219,7 @@ func serve(args []string) error {
// and was racy with respect to initialization of gRPC clients and servers.
grpc.EnableTracing = true

logger.Infof("Starting %s", version.GetInfo())

//obtain coreConfiguration
// obtain coreConfiguration
coreConfig, err := peer.GlobalConfig()
if err != nil {
return err
Expand Down