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

skip connecting to invalid identities in the identity table and log error instead of fatal #1138

Merged
merged 5 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion network/p2p/libp2pConnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (e UnconvertibleIdentitiesError) Error() string {
for id, err := range e.errs {
multierr = multierror.Append(multierr, fmt.Errorf("failed to connect to %s: %w", id.String(), err))
}
return multierr.GoString()
return multierr.Error()
}

// IsUnconvertibleIdentitiesError returns whether the given error is an UnconvertibleIdentitiesError error
Expand Down
13 changes: 3 additions & 10 deletions network/p2p/peerManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,8 @@ func (pm *PeerManager) updatePeers() {

// ask the connector to connect to all peers in the list
err = pm.connector.UpdatePeers(pm.unit.Ctx(), ids)
if err == nil {
return
}

if IsUnconvertibleIdentitiesError(err) {
// log conversion error as fatal since it indicates a bad identity table
pm.logger.Fatal().Err(err).Msg("failed to connect to peers")
return
if err != nil {
// one of more identities in the identity table could not be connected to
pm.logger.Error().Err(err).Msg("failed to connect to one or more peers")
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this can only be an NewUnconvertableIdentitiesError in our implementation. Could we unpack this case and thereby maybe get a more usable error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so UnconvertableIdentitiesError is logged as multiple individual errors (multi-error) which will list out the Identity and the error reason.
Will that suffice?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep, all good!

}

pm.logger.Error().Err(err).Msg("failed to connect to peers")
}