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

moved ConnectionWatcherType from p2p.toml to prefs.toml #4299

Merged

Conversation

raduchis
Copy link
Contributor

the ConnectionWatcherType was overwritten on upgrade and so was moved to prefs.toml
added emptyConnectionsWatcher const so that if the ConnectionWatcherType is not set, there should be no need to add it to the prefs.toml

@codecov-commenter
Copy link

codecov-commenter commented Jul 15, 2022

Codecov Report

❗ No coverage uploaded for pull request base (rc/2022-july@dcb5d50). Click here to learn what that means.
The diff coverage is n/a.

@@               Coverage Diff               @@
##             rc/2022-july    #4299   +/-   ##
===============================================
  Coverage                ?   73.67%           
===============================================
  Files                   ?      662           
  Lines                   ?    86132           
  Branches                ?        0           
===============================================
  Hits                    ?    63458           
  Misses                  ?    17917           
  Partials                ?     4757           

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 dcb5d50...da95fe1. Read the comment docs.

@bogdan-rosianu bogdan-rosianu self-requested a review July 18, 2022 07:02
PreferredPeersHolder: disabled.NewPreferredPeersHolder(),
NodeOperationMode: p2p.NormalOperation,
PeersRatingHandler: disabled.NewDisabledPeersRatingHandler(),
ConnectionWatcherType: "disabled",
Copy link
Contributor

Choose a reason for hiding this comment

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

that flag hasn't been altered in the previous code. also, might use constants

Copy link
Contributor Author

@raduchis raduchis Jul 18, 2022

Choose a reason for hiding this comment

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

seednode will not work with ConnectionWatcherType

Copy link
Contributor

Choose a reason for hiding this comment

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

one more config for the seednode :(
Since it won't work on the seednode binary anyway, I suggest to leave it as a const.

@@ -13,4 +13,5 @@ type PreferencesConfig struct {
RedundancyLevel int64
PreferredConnections []string
FullArchive bool
ConnectionWatcherType string
Copy link
Contributor

Choose a reason for hiding this comment

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

please leave FullArchive bool the last one due to memory alignment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved up one position

@@ -52,6 +52,7 @@ func CreateDefaultConfig() *config.Configs {

p2pConfig.KadDhtPeerDiscovery.Enabled = false
prefsConfig.Preferences.DestinationShardAsObserver = "0"
prefsConfig.Preferences.ConnectionWatcherType = "print"
Copy link
Contributor

Choose a reason for hiding this comment

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

please define constants somewhere for these values

Copy link
Contributor Author

@raduchis raduchis Jul 18, 2022

Choose a reason for hiding this comment

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

added them to p2p (ConnectionWatcherType interface is declared here) constants and used them everywhere

const printConnectionsWatcher = "print"
const disabledConnectionsWatcher = "disabled"
const (
printConnectionsWatcher = "print"
Copy link
Contributor

Choose a reason for hiding this comment

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

move them in a new package and export them & use everywhere

Copy link
Contributor

Choose a reason for hiding this comment

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

why exported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added them to p2p and used everywhere


// NewConnectionsWatcher creates a new ConnectionWatcher instance based on the input parameters
func NewConnectionsWatcher(connectionsWatcherType string, timeToLive time.Duration) (p2p.ConnectionsWatcher, error) {
switch connectionsWatcherType {
case printConnectionsWatcher:
return metrics.NewPrintConnectionsWatcher(timeToLive)
case disabledConnectionsWatcher:
case disabledConnectionsWatcher, emptyConnectionsWatcher:
Copy link
Contributor

Choose a reason for hiding this comment

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

might use a new case for emptyConnectionsWatcher because it can only be empty due to bad configuration. therefore, we'd want to see a log warn

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree to be left as it is now: the config misconfiguration will be hit because the prefs.toml is not overwritten on upgrade.

Copy link
Contributor Author

@raduchis raduchis Jul 18, 2022

Choose a reason for hiding this comment

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

yes, the idea to add the emptyConnectionsWatcher without any error is that the prefs.toml is not overwritten and has to be added manually. Update log.Trace to log.Debug on the connectionsWatcherTypeFactory

@iulianpascalau iulianpascalau self-requested a review July 18, 2022 07:48
Copy link
Contributor

@iulianpascalau iulianpascalau left a comment

Choose a reason for hiding this comment

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

minor stuff 👍

const printConnectionsWatcher = "print"
const disabledConnectionsWatcher = "disabled"
const (
printConnectionsWatcher = "print"
Copy link
Contributor

Choose a reason for hiding this comment

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

why exported?


// NewConnectionsWatcher creates a new ConnectionWatcher instance based on the input parameters
func NewConnectionsWatcher(connectionsWatcherType string, timeToLive time.Duration) (p2p.ConnectionsWatcher, error) {
switch connectionsWatcherType {
case printConnectionsWatcher:
return metrics.NewPrintConnectionsWatcher(timeToLive)
case disabledConnectionsWatcher:
case disabledConnectionsWatcher, emptyConnectionsWatcher:
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree to be left as it is now: the config misconfiguration will be hit because the prefs.toml is not overwritten on upgrade.

@@ -182,7 +183,8 @@ func constructNode(
return nil, err
}

connWatcher, err := metricsFactory.NewConnectionsWatcher(args.P2pConfig.Node.ConnectionWatcherType, ttlConnectionsWatcher)
log.Trace("connectionWatcherType", "type", args.ConnectionWatcherType)
Copy link
Contributor

Choose a reason for hiding this comment

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

can be log.Debug as it is a one-time print

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to Debug

SyncTimer: &libp2p.LocalSyncTimer{},
PreferredPeersHolder: &p2pmocks.PeersHolderStub{},
PeersRatingHandler: &p2pmocks.PeersRatingHandlerStub{},
ConnectionWatcherType: "print",
Copy link
Contributor

Choose a reason for hiding this comment

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

can be an exported const in export_test.go that will be equal to the unexported const

Copy link
Contributor Author

@raduchis raduchis Jul 18, 2022

Choose a reason for hiding this comment

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

added to p2p as constant (where ConnectionWatcherType interface is declared) and used everywhere

Copy link
Contributor

@popenta popenta left a comment

Choose a reason for hiding this comment

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

@@ Log scanner @@

EN-12618-move-connectionWatcherType-prefs.toml##

================================================================================

  • Known Warnings 22
  • New Warnings 0
  • Known Errors 0
  • New Errors 2
  • Panics 0
    ================================================================================

@raduchis raduchis self-assigned this Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants