Cleanup agreement sender (#630)

* Signature verification

* code review comments & lint warnings

* Clean up agreement sender to have less errors

* overlay address in captnplanet
This commit is contained in:
Alexander Leitner 2018-11-13 10:37:49 -05:00 committed by GitHub
parent 514ca50611
commit 50d657af11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View File

@ -131,6 +131,8 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
startingPort := setupCfg.StartingPort
overlayAddr := joinHostPort(setupCfg.ListenHost, startingPort+1)
overrides := map[string]interface{}{
"satellite.identity.cert-path": setupCfg.HCIdentity.CertPath,
"satellite.identity.key-path": setupCfg.HCIdentity.KeyPath,
@ -145,8 +147,7 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
"satellite.overlay.database-url": "bolt://" + filepath.Join(
setupCfg.BasePath, "satellite", "overlay.db"),
"satellite.repairer.queue-address": "redis://127.0.0.1:6378?db=1&password=abc123",
"satellite.repairer.overlay-addr": joinHostPort(
setupCfg.ListenHost, startingPort+1),
"satellite.repairer.overlay-addr": overlayAddr,
"satellite.repairer.pointer-db-addr": joinHostPort(
setupCfg.ListenHost, startingPort+1),
"satellite.repairer.api-key": setupCfg.APIKey,
@ -163,6 +164,9 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
"uplink.enc-key": setupCfg.EncKey,
"uplink.api-key": setupCfg.APIKey,
"pointer-db.auth.api-key": setupCfg.APIKey,
// Repairer
"piecestore.agreementsender.overlay_addr": overlayAddr,
}
for i := 0; i < len(runCfg.StorageNodes); i++ {

View File

@ -80,7 +80,7 @@ func (as *AgreementSender) Run(ctx context.Context) error {
return utils.CombineErrors(as.errs...)
case agreementGroup := <-c:
go func() {
zap.S().Info("Sending %v agreements to satellite %s\n", len(agreementGroup.agreements), agreementGroup.satellite)
zap.S().Infof("Sending %v agreements to satellite %s\n", len(agreementGroup.agreements), agreementGroup.satellite)
// Get satellite ip from overlay by Lookup agreementGroup.satellite
satellite, err := as.overlay.Lookup(ctx, node.IDFromString(agreementGroup.satellite))
@ -111,7 +111,7 @@ func (as *AgreementSender) Run(ctx context.Context) error {
defer func() {
if _, closeErr := stream.CloseAndRecv(); closeErr != nil {
zap.S().Error("error closing stream %s :: %v.Send() = %v", closeErr, stream, closeErr)
zap.S().Errorf("error closing stream %s :: %v.Send() = %v", closeErr, stream, closeErr)
}
}()

View File

@ -282,12 +282,16 @@ func (db *DB) GetBandwidthAllocations() (map[string][]*Agreement, error) {
agreements := make(map[string][]*Agreement)
for rows.Next() {
agreement := &Agreement{}
var satellite string
var satellite sql.NullString
err := rows.Scan(&satellite, &agreement.Agreement, &agreement.Signature)
if err != nil {
return nil, err
return agreements, err
}
agreements[satellite] = append(agreements[satellite], agreement)
if !satellite.Valid {
return agreements, nil
}
agreements[satellite.String] = append(agreements[satellite.String], agreement)
}
return agreements, nil
}