2019-10-04 21:48:41 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information
|
|
|
|
|
|
|
|
package testplanet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"time"
|
|
|
|
|
2020-03-23 19:30:31 +00:00
|
|
|
"storj.io/private/version"
|
2019-11-14 19:46:15 +00:00
|
|
|
"storj.io/storj/private/version/checker"
|
2019-10-04 21:48:41 +01:00
|
|
|
"storj.io/storj/versioncontrol"
|
|
|
|
)
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// newVersionControlServer initializes the Versioning Server.
|
2019-10-04 21:48:41 +01:00
|
|
|
func (planet *Planet) newVersionControlServer() (peer *versioncontrol.Peer, err error) {
|
|
|
|
prefix := "versioncontrol"
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
dbDir := filepath.Join(planet.directory, prefix)
|
|
|
|
|
|
|
|
if err := os.MkdirAll(dbDir, 0700); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-07-16 15:40:48 +01:00
|
|
|
var minimum, suggested versioncontrol.VersionConfig
|
|
|
|
minimum.Version = "v0.0.1"
|
|
|
|
suggested.Version = "v0.0.1"
|
|
|
|
|
2020-03-03 10:32:08 +00:00
|
|
|
defaultProcessConfig := versioncontrol.ProcessConfig{
|
2020-07-16 15:40:48 +01:00
|
|
|
Minimum: minimum,
|
|
|
|
Suggested: suggested,
|
2020-03-03 10:32:08 +00:00
|
|
|
Rollout: versioncontrol.RolloutConfig{
|
|
|
|
Seed: "0000000000000000000000000000000000000000000000000000000000000001",
|
|
|
|
},
|
|
|
|
}
|
2019-10-04 21:48:41 +01:00
|
|
|
config := &versioncontrol.Config{
|
2022-03-28 19:05:53 +01:00
|
|
|
Address: planet.NewListenAddress(),
|
2019-10-21 11:50:59 +01:00
|
|
|
Versions: versioncontrol.OldVersionConfig{
|
2019-10-04 21:48:41 +01:00
|
|
|
Satellite: "v0.0.1",
|
|
|
|
Storagenode: "v0.0.1",
|
|
|
|
Uplink: "v0.0.1",
|
|
|
|
Gateway: "v0.0.1",
|
|
|
|
Identity: "v0.0.1",
|
|
|
|
},
|
2020-03-03 10:32:08 +00:00
|
|
|
Binary: versioncontrol.ProcessesConfig{
|
|
|
|
Satellite: defaultProcessConfig,
|
|
|
|
Storagenode: defaultProcessConfig,
|
|
|
|
StoragenodeUpdater: defaultProcessConfig,
|
|
|
|
Uplink: defaultProcessConfig,
|
|
|
|
Gateway: defaultProcessConfig,
|
|
|
|
Identity: defaultProcessConfig,
|
|
|
|
},
|
2019-10-04 21:48:41 +01:00
|
|
|
}
|
2020-07-16 15:40:48 +01:00
|
|
|
if planet.config.Reconfigure.VersionControl != nil {
|
|
|
|
planet.config.Reconfigure.VersionControl(config)
|
|
|
|
}
|
2019-10-04 21:48:41 +01:00
|
|
|
peer, err = versioncontrol.New(log, config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Debug(" addr= " + peer.Addr())
|
|
|
|
|
|
|
|
return peer, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewVersionInfo returns the Version Info for this planet with tuned metrics.
|
|
|
|
func (planet *Planet) NewVersionInfo() version.Info {
|
2019-10-21 11:50:59 +01:00
|
|
|
ver, err := version.NewSemVer("v0.0.1")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2019-10-04 21:48:41 +01:00
|
|
|
info := version.Info{
|
|
|
|
Timestamp: time.Now(),
|
|
|
|
CommitHash: "testplanet",
|
2019-10-21 11:50:59 +01:00
|
|
|
Version: ver,
|
|
|
|
Release: false,
|
2019-10-04 21:48:41 +01:00
|
|
|
}
|
|
|
|
return info
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewVersionConfig returns the Version Config for this planet with tuned metrics.
|
2019-10-20 08:56:23 +01:00
|
|
|
func (planet *Planet) NewVersionConfig() checker.Config {
|
|
|
|
config := checker.Config{
|
2020-01-14 10:56:26 +00:00
|
|
|
CheckInterval: defaultInterval,
|
2019-10-04 21:48:41 +01:00
|
|
|
}
|
2019-10-20 08:56:23 +01:00
|
|
|
|
|
|
|
config.ServerAddress = fmt.Sprintf("http://%s/", planet.VersionControl.Addr())
|
|
|
|
config.RequestTimeout = time.Second * 15
|
|
|
|
return config
|
2019-10-04 21:48:41 +01:00
|
|
|
}
|