-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 logging output for teleport configure
commands.
#38257
Conversation
567c130
to
93e71bd
Compare
|
||
"github.com/aws/aws-sdk-go-v2/config" | ||
"github.com/aws/aws-sdk-go-v2/service/iam" | ||
"github.com/gravitational/trace" | ||
log "github.com/sirupsen/logrus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't alias the import and require using logrus.Debugf
explicitly it'd be a bit more obvious that we were using the wrong log package.
log "github.com/sirupsen/logrus" | |
"github.com/sirupsen/logrus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
tool/teleport/common/teleport.go
Outdated
@@ -958,6 +958,9 @@ func onJoinOpenSSH(clf config.CommandLineFlags, conf *servicecfg.Config) error { | |||
func onIntegrationConfDeployService(params config.IntegrationConfDeployServiceIAM) error { | |||
ctx := context.Background() | |||
|
|||
// Ensure we print output to the user. LogLevel at this point was set to Error. | |||
log.SetLevel(log.InfoLevel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we respect -d
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we reuse the same logger as teleport and change only if debug is set?
Not sure if users want to see info related logs when running something on cloud shell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought -d
was global, but we actually don't have -d
for integration commands. But I changed setting of the level to be flexible, so if the future there will be -d
it will not get overwritten.
And I think showing those logs by default is helpful for the user, it tells useful information (policies names).
@@ -108,6 +108,6 @@ func ConfigureAccessGraphSyncIAM(ctx context.Context, clt AccessGraphIAMConfigur | |||
return trace.Wrap(err) | |||
} | |||
|
|||
log.Printf("IntegrationRole: IAM Policy %q added to Role %q\n", req.IntegrationRoleTAGPolicy, req.IntegrationRole) | |||
logrus.Printf("IntegrationRole: IAM Policy %q added to Role %q\n", req.IntegrationRoleTAGPolicy, req.IntegrationRole) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Use Infof
instead of Printf
to be consistent with the rest of our logging code. Same suggestion for other commands below.
logrus.Printf("IntegrationRole: IAM Policy %q added to Role %q\n", req.IntegrationRoleTAGPolicy, req.IntegrationRole) | |
logrus.Infof("IntegrationRole: IAM Policy %q added to Role %q\n", req.IntegrationRoleTAGPolicy, req.IntegrationRole) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 8789535
@@ -958,6 +958,9 @@ func onJoinOpenSSH(clf config.CommandLineFlags, conf *servicecfg.Config) error { | |||
func onIntegrationConfDeployService(params config.IntegrationConfDeployServiceIAM) error { | |||
ctx := context.Background() | |||
|
|||
// Ensure we print output to the user. LogLevel at this point was set to Error. | |||
utils.InitLogger(utils.LoggingForDaemon, slog.LevelInfo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rosstimothy done as discussed 0ea804f
* Fix logging output for 'teleport configure' commands. * Change imported log package name and don't overwrite debug level. * Use Infof() instead of Printf() * Use InitLogger to reset loglevel * Remove unneeded code.
* Fix logging output for 'teleport configure' commands. * Change imported log package name and don't overwrite debug level. * Use Infof() instead of Printf() * Use InitLogger to reset loglevel * Remove unneeded code.
* Fix logging output for 'teleport configure' commands. * Change imported log package name and don't overwrite debug level. * Use Infof() instead of Printf() * Use InitLogger to reset loglevel * Remove unneeded code.
* Fix logging output for 'teleport configure' commands. * Change imported log package name and don't overwrite debug level. * Use Infof() instead of Printf() * Use InitLogger to reset loglevel * Remove unneeded code.
* Fix logging output for 'teleport configure' commands. * Change imported log package name and don't overwrite debug level. * Use Infof() instead of Printf() * Use InitLogger to reset loglevel * Remove unneeded code.
This PR fixes printing of the log output to the user when they are running most
teleport configure ...
commands. Log package used was wrong and also log level needed to be adjusted for those commands.As an alternative fix, we can just turn all
log.Printf()
usage in codepath of those commands intofmt.Pritnf()
, but it doesn't feel that good to usefmt.Printf()
inside/lib/integrations/awsoidc
code. On the other hand, log output looks better for user in that case (no INFO label and no filename:linenumber stuff at the end) and we already do it for theexternalauditstorage
command, which I didn't touch.Changelog: Fix logging output for
teleport configure ...
commands.