storj-sim configs (#1140)

This commit is contained in:
Egon Elbre 2019-01-28 16:48:49 +02:00 committed by GitHub
parent 702cf75af1
commit 04d3699107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 36 deletions

View File

@ -91,7 +91,7 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) {
ctx := process.Ctx(cmd)
if err := process.InitMetricsWithCertPath(ctx, nil, runCfg.Identity.CertPath); err != nil {
zap.S().Errorf("Failed to initialize telemetry batcher: %+v", err)
zap.S().Error("Failed to initialize telemetry batcher: ", err)
}
db, err := bootstrapdb.New(bootstrapdb.Config{
@ -133,9 +133,16 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
return err
}
overrides := map[string]interface{}{
"identity.server.address": defaultServerAddr,
"kademlia.bootstrap-addr": "localhost" + defaultServerAddr,
overrides := map[string]interface{}{}
serverAddress := cmd.Flag("server.address")
if !serverAddress.Changed {
overrides[serverAddress.Name] = defaultServerAddr
}
kademliaBootstrapAddr := cmd.Flag("kademlia.bootstrap-addr")
if !kademliaBootstrapAddr.Changed {
overrides[kademliaBootstrapAddr.Name] = "localhost" + defaultServerAddr
}
return process.SaveConfigWithAllDefaults(cmd.Flags(), filepath.Join(setupDir, "config.yaml"), overrides)

View File

@ -65,12 +65,12 @@ func cmdSetup(cmd *cobra.Command, args []string) error {
return errors.New("identity is missing")
}
o := map[string]interface{}{
overrides := map[string]interface{}{
"ca.cert-path": config.CA.CertPath,
"ca.key-path": config.CA.KeyPath,
"identity.cert-path": config.Identity.CertPath,
"identity.key-path": config.Identity.KeyPath,
"log.level": "info",
}
return process.SaveConfigWithAllDefaults(cmd.Flags(), filepath.Join(setupDir, "config.yaml"), o)
return process.SaveConfigWithAllDefaults(cmd.Flags(), filepath.Join(setupDir, "config.yaml"), overrides)
}

View File

@ -118,7 +118,7 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) {
ctx := process.Ctx(cmd)
if err := process.InitMetricsWithCertPath(ctx, nil, runCfg.Identity.CertPath); err != nil {
zap.S().Errorf("Failed to initialize telemetry batcher: %+v", err)
zap.S().Error("Failed to initialize telemetry batcher: ", err)
}
db, err := satellitedb.New(runCfg.Database)

View File

@ -100,6 +100,7 @@ func newNetwork(flags *Flags) (*Processes, error) {
withCommon := func(all Arguments) Arguments {
for command, args := range all {
all[command] = append([]string{
"--metrics.app-suffix", "sim",
"--log.level", "debug",
"--config-dir", ".",
command,
@ -129,13 +130,13 @@ func newNetwork(flags *Flags) (*Processes, error) {
bootstrap.Arguments = withCommon(Arguments{
"setup": {
"--identity-dir", bootstrap.Directory,
},
"run": {
"--server.address", bootstrap.Address,
"--kademlia.bootstrap-addr", bootstrap.Address,
"--kademlia.operator.email", "bootstrap@example.com",
"--kademlia.operator.wallet", "0x0123456789012345678901234567890123456789",
"--server.address", bootstrap.Address,
},
"run": {},
})
// Create satellites making all satellites wait for bootstrap to start
@ -155,15 +156,14 @@ func newNetwork(flags *Flags) (*Processes, error) {
process.Arguments = withCommon(Arguments{
"setup": {
"--identity-dir", process.Directory,
},
"run": {
"--console.address", net.JoinHostPort(host, strconv.Itoa(consolePort+i)),
"--kademlia.bootstrap-addr", bootstrap.Address,
"--server.address", process.Address,
"--kademlia.bootstrap-addr", bootstrap.Address,
"--repairer.overlay-addr", process.Address,
"--repairer.pointer-db-addr", process.Address,
},
"run": {},
})
}
@ -188,11 +188,8 @@ func newNetwork(flags *Flags) (*Processes, error) {
"setup": {
"--identity-dir", process.Directory,
"--satellite-addr", satellite.Address,
},
"run": {
"--server.address", process.Address,
"--minio.access-key", accessKey,
"--minio.secret-key", secretKey,
"--client.overlay-addr", satellite.Address,
"--client.pointer-db-addr", satellite.Address,
@ -202,6 +199,11 @@ func newNetwork(flags *Flags) (*Processes, error) {
"--rs.success-threshold", strconv.Itoa(3 * flags.StorageNodeCount / 5),
"--rs.max-threshold", strconv.Itoa(4 * flags.StorageNodeCount / 5),
},
"run": {
// TODO: do not regenerate keys every time, but read from config file instead
"--minio.access-key", accessKey,
"--minio.secret-key", secretKey,
},
})
}
@ -220,13 +222,13 @@ func newNetwork(flags *Flags) (*Processes, error) {
process.Arguments = withCommon(Arguments{
"setup": {
"--identity-dir", process.Directory,
},
"run": {
"--server.address", process.Address,
"--kademlia.bootstrap-addr", bootstrap.Address,
"--kademlia.operator.email", fmt.Sprintf("storage%d@example.com", i),
"--kademlia.operator.wallet", "0x0123456789012345678901234567890123456789",
"--server.address", process.Address,
},
"run": {},
})
}

View File

@ -52,7 +52,7 @@ func mountBucket(cmd *cobra.Command, args []string) (err error) {
}
if err := process.InitMetricsWithCertPath(ctx, nil, cfg.Identity.CertPath); err != nil {
zap.S().Errorf("Failed to initialize telemetry batcher: %v", err)
zap.S().Error("Failed to initialize telemetry batcher: ", err)
}
src, err := fpath.New(args[0])

View File

@ -52,7 +52,7 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) {
}
if err := process.InitMetricsWithCertPath(ctx, nil, cfg.Identity.CertPath); err != nil {
zap.S().Errorf("Failed to initialize telemetry batcher: %v", err)
zap.S().Error("Failed to initialize telemetry batcher: ", err)
}
_, err = metainfo.ListBuckets(ctx, storj.BucketListOptions{Direction: storj.After})
if err != nil {

View File

@ -110,26 +110,31 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
}
}
accessKey, err := generateAWSKey()
if err != nil {
return err
}
secretKey, err := generateAWSKey()
if err != nil {
return err
}
o := map[string]interface{}{
overrides := map[string]interface{}{
"client.api-key": setupCfg.APIKey,
"client.pointer-db-addr": setupCfg.SatelliteAddr,
"client.overlay-addr": setupCfg.SatelliteAddr,
"minio.access-key": accessKey,
"minio.secret-key": secretKey,
"enc.key": setupCfg.EncKey,
}
return process.SaveConfigWithAllDefaults(cmd.Flags(), filepath.Join(setupDir, "config.yaml"), o)
accessKeyFlag := cmd.Flag("minio.access-key")
if !accessKeyFlag.Changed {
accessKey, err := generateAWSKey()
if err != nil {
return err
}
overrides[accessKeyFlag.Name] = accessKey
}
secretKeyFlag := cmd.Flag("minio.secret-key")
if !secretKeyFlag.Changed {
secretKey, err := generateAWSKey()
if err != nil {
return err
}
overrides[secretKeyFlag.Name] = secretKey
}
return process.SaveConfigWithAllDefaults(cmd.Flags(), filepath.Join(setupDir, "config.yaml"), overrides)
}
func generateAWSKey() (key string, err error) {