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

[RSDK 9149] Use RDK Logger Across Interceptors #405

Merged
merged 29 commits into from
Jan 21, 2025

Conversation

bashar-515
Copy link
Member

Stop converting the logger into a zap logger and instead use the native zap compatible logger. See pics below for visible change (the error log in between the highlighted lines is the same as what's referenced in the ticket).

Note
re: all the 'from here' comments..
To no longer use an ordinary zap logger, I replaced calls to grpc interceptor methods with calls to copies of those methods that I modify to use an RDK logger instead. An effect of this change was the additional copying over of all private types employed by these functions in the grpc library we use,, is there a better way about this? It seems like this PR used a similar tactic to get client interceptors to use the preferred logger.

Before:
Screenshot 2025-01-08 at 11 01 25 AM

After: notice here that the logger (from goutils/logger.go)is outputting logs that are not ERROR level or higher. This is not desired behavior. This has since been fixed; the original behavior has been restored.
Screenshot 2025-01-08 at 11 03 04 AM

After:
Screenshot 2025-01-09 at 1 22 26 PM

Testing
Modify the the module.go RDK file in the simple module example custom resource so that the DoCommand() implementation always returns an error. Then, follow the instructions provided in the custom resources README.md file to see the logs output by the robot server.

Copy link

For security reasons, this PR must be labeled with safe to test in order for tests to run.

@viambot viambot added the safe to test Mark as safe to test label Jan 21, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 21, 2025
Copy link
Member Author

Choose a reason for hiding this comment

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

@dgottlieb @cheukt This, in addition to this, are the changes to stop the leaked goroutine in RDK testing from happening. The RDK PR cannot merge until this goutils PR does and the goutils version is bumped in RDK. Once this merges and goutils in RDK is bumped, the RDK tests will still fail (leak takes place) until the other PR merges.

@bashar-515 bashar-515 marked this pull request as ready for review January 21, 2025 17:06
rpc/server.go Outdated
@@ -404,6 +397,8 @@ func NewServer(logger utils.ZapCompatibleLogger, opts ...ServerOption) (Server,
serverOpts = append(serverOpts, grpc.StatsHandler(sOpts.statsHandler))
}

serverOpts = append(serverOpts, grpc.WaitForHandlers(sOpts.waitForHandlers))
Copy link
Member

Choose a reason for hiding this comment

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

@dgottlieb another option is to just have grpcServer call GracefulStop() instead of Stop() in L864. It is a riskier change but also not sure why that Stop() wasn't graceful, when all of the other stops in the function are.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, GracefulStop works too. I have no strong opinions on this. Just confirming: I expect all servers to be constructed from this NewServer call. Given that, I don't see any behavior difference between using an option vs GracefulStop.

@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 21, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 21, 2025
@@ -861,7 +856,7 @@ func (ss *simpleServer) Stop() error {
err = multierr.Combine(err, ss.signalingCallQueue.Close())
}
ss.logger.Debug("stopping gRPC server")
defer ss.grpcServer.Stop()
defer ss.grpcServer.GracefulStop()
Copy link
Member Author

Choose a reason for hiding this comment

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

Was causing a goroutine leak in RDK testing.

@bashar-515 bashar-515 requested a review from cheukt January 21, 2025 18:18
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 21, 2025
@bashar-515 bashar-515 merged commit a4a1e53 into viamrobotics:main Jan 21, 2025
6 checks passed
@bashar-515 bashar-515 deleted the RSDK-9149 branch January 21, 2025 18:27
@bashar-515 bashar-515 restored the RSDK-9149 branch January 21, 2025 19:04
@bashar-515 bashar-515 deleted the RSDK-9149 branch January 22, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test Mark as safe to test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants