Remove backwards compatibility hacks
The things removed here have been live for more than 2 releases. License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
This commit is contained in:
parent
f57c5e4066
commit
0fed61192a
|
@ -125,7 +125,7 @@ type Client interface {
|
|||
// Config allows to configure the parameters to connect
|
||||
// to the ipfs-cluster REST API.
|
||||
type Config struct {
|
||||
// Enable SSL support. Only valid without PeerAddr.
|
||||
// Enable SSL support. Only valid without APIAddr.
|
||||
SSL bool
|
||||
// Skip certificate verification (insecure)
|
||||
NoVerifyCert bool
|
||||
|
@ -141,17 +141,14 @@ type Config struct {
|
|||
// free. Using the libp2p tunnel will ignore any configurations.
|
||||
APIAddr ma.Multiaddr
|
||||
|
||||
// PeerAddr is deprecated. It's aliased to APIAddr
|
||||
PeerAddr ma.Multiaddr
|
||||
|
||||
// REST API endpoint host and port. Only valid without
|
||||
// APIAddr and PeerAddr
|
||||
// APIAddr.
|
||||
Host string
|
||||
Port string
|
||||
|
||||
// If PeerAddr is provided, and the peer uses private networks
|
||||
// (pnet), then we need to provide the key. If the peer is the
|
||||
// cluster peer, this corresponds to the cluster secret.
|
||||
// If APIAddr is provided, and the peer uses private networks (pnet),
|
||||
// then we need to provide the key. If the peer is the cluster peer,
|
||||
// this corresponds to the cluster secret.
|
||||
ProtectorKey []byte
|
||||
|
||||
// ProxyAddr is used to obtain a go-ipfs-api Shell instance pointing
|
||||
|
@ -192,10 +189,6 @@ func NewDefaultClient(cfg *Config) (Client, error) {
|
|||
config: cfg,
|
||||
}
|
||||
|
||||
if paddr := client.config.PeerAddr; paddr != nil {
|
||||
client.config.APIAddr = paddr
|
||||
}
|
||||
|
||||
if client.config.Port == "" {
|
||||
client.config.Port = fmt.Sprintf("%d", DefaultPort)
|
||||
}
|
||||
|
|
|
@ -118,7 +118,6 @@ type Config struct {
|
|||
}
|
||||
|
||||
type jsonConfig struct {
|
||||
ListenMultiaddress string `json:"listen_multiaddress,omitempty"` // backwards compat
|
||||
HTTPListenMultiaddress string `json:"http_listen_multiaddress"`
|
||||
SSLCertFile string `json:"ssl_cert_file,omitempty"`
|
||||
SSLKeyFile string `json:"ssl_key_file,omitempty"`
|
||||
|
@ -267,16 +266,7 @@ func (cfg *Config) applyJSONConfig(jcfg *jsonConfig) error {
|
|||
}
|
||||
|
||||
func (cfg *Config) loadHTTPOptions(jcfg *jsonConfig) error {
|
||||
// Deal with legacy ListenMultiaddress parameter
|
||||
httpListen := jcfg.ListenMultiaddress
|
||||
if httpListen != "" {
|
||||
logger.Warning("restapi.listen_multiaddress has been replaced with http_listen_multiaddress and has been deprecated")
|
||||
}
|
||||
if l := jcfg.HTTPListenMultiaddress; l != "" {
|
||||
httpListen = l
|
||||
}
|
||||
|
||||
if httpListen != "" {
|
||||
if httpListen := jcfg.HTTPListenMultiaddress; httpListen != "" {
|
||||
httpAddr, err := ma.NewMultiaddr(httpListen)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error parsing restapi.http_listen_multiaddress: %s", err)
|
||||
|
|
|
@ -729,17 +729,8 @@ func (po *PinOptions) ToQuery() string {
|
|||
func (po *PinOptions) FromQuery(q url.Values) {
|
||||
po.Name = q.Get("name")
|
||||
rplStr := q.Get("replication")
|
||||
if rplStr == "" { // compat <= 0.4.0
|
||||
rplStr = q.Get("replication_factor")
|
||||
}
|
||||
rplStrMin := q.Get("replication-min")
|
||||
if rplStrMin == "" { // compat <= 0.4.0
|
||||
rplStrMin = q.Get("replication_factor_min")
|
||||
}
|
||||
rplStrMax := q.Get("replication-max")
|
||||
if rplStrMax == "" { // compat <= 0.4.0
|
||||
rplStrMax = q.Get("replication_factor_max")
|
||||
}
|
||||
if rplStr != "" { // override
|
||||
rplStrMin = rplStr
|
||||
rplStrMax = rplStr
|
||||
|
|
|
@ -129,23 +129,20 @@ type Config struct {
|
|||
// saved using JSON. Most configuration keys are converted into simple types
|
||||
// like strings, and key names aim to be self-explanatory for the user.
|
||||
type configJSON struct {
|
||||
ID string `json:"id"`
|
||||
Peername string `json:"peername"`
|
||||
PrivateKey string `json:"private_key"`
|
||||
Secret string `json:"secret"`
|
||||
Peers []string `json:"peers,omitempty"` // DEPRECATED
|
||||
Bootstrap []string `json:"bootstrap,omitempty"` // DEPRECATED
|
||||
LeaveOnShutdown bool `json:"leave_on_shutdown"`
|
||||
ListenMultiaddress string `json:"listen_multiaddress"`
|
||||
StateSyncInterval string `json:"state_sync_interval"`
|
||||
IPFSSyncInterval string `json:"ipfs_sync_interval"`
|
||||
ReplicationFactor int `json:"replication_factor,omitempty"` // legacy
|
||||
ReplicationFactorMin int `json:"replication_factor_min"`
|
||||
ReplicationFactorMax int `json:"replication_factor_max"`
|
||||
MonitorPingInterval string `json:"monitor_ping_interval"`
|
||||
PeerWatchInterval string `json:"peer_watch_interval"`
|
||||
DisableRepinning bool `json:"disable_repinning"`
|
||||
PeerstoreFile string `json:"peerstore_file,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Peername string `json:"peername"`
|
||||
PrivateKey string `json:"private_key"`
|
||||
Secret string `json:"secret"`
|
||||
LeaveOnShutdown bool `json:"leave_on_shutdown"`
|
||||
ListenMultiaddress string `json:"listen_multiaddress"`
|
||||
StateSyncInterval string `json:"state_sync_interval"`
|
||||
IPFSSyncInterval string `json:"ipfs_sync_interval"`
|
||||
ReplicationFactorMin int `json:"replication_factor_min"`
|
||||
ReplicationFactorMax int `json:"replication_factor_max"`
|
||||
MonitorPingInterval string `json:"monitor_ping_interval"`
|
||||
PeerWatchInterval string `json:"peer_watch_interval"`
|
||||
DisableRepinning bool `json:"disable_repinning"`
|
||||
PeerstoreFile string `json:"peerstore_file,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigKey returns a human-readable string to identify
|
||||
|
@ -301,26 +298,6 @@ func (cfg *Config) LoadJSON(raw []byte) error {
|
|||
|
||||
cfg.setDefaults()
|
||||
|
||||
if jcfg.Peers != nil || jcfg.Bootstrap != nil {
|
||||
logger.Error(`
|
||||
Your configuration is using cluster.Peers and/or cluster.Bootstrap
|
||||
keys. Starting at version 0.4.0 these keys have been deprecated and replaced by
|
||||
the Peerstore file and the consensus.raft.InitialPeers key.
|
||||
|
||||
Bootstrap keeps working but only as a flag:
|
||||
|
||||
"ipfs-cluster-service daemon --bootstrap <comma-separated-multiaddresses>"
|
||||
|
||||
If you want to upgrade the existing peers that belong to a cluster:
|
||||
|
||||
* Write your peers multiaddresses in the peerstore file (1 per line): ~/.ipfs-cluster/peerstore
|
||||
* Remove Peers and Bootstrap from your configuration
|
||||
|
||||
Please check the docs (https://cluster.ipfs.io/documentation/configuration/)
|
||||
for more information.`)
|
||||
return errors.New("cluster.Peers and cluster.Bootstrap keys have been deprecated")
|
||||
}
|
||||
|
||||
return cfg.applyConfigJSON(jcfg)
|
||||
}
|
||||
|
||||
|
@ -364,10 +341,6 @@ func (cfg *Config) applyConfigJSON(jcfg *configJSON) error {
|
|||
|
||||
rplMin := jcfg.ReplicationFactorMin
|
||||
rplMax := jcfg.ReplicationFactorMax
|
||||
if jcfg.ReplicationFactor != 0 { // read min and max
|
||||
rplMin = jcfg.ReplicationFactor
|
||||
rplMax = rplMin
|
||||
}
|
||||
config.SetIfNotDefault(rplMin, &cfg.ReplicationFactorMin)
|
||||
config.SetIfNotDefault(rplMax, &cfg.ReplicationFactorMax)
|
||||
|
||||
|
|
|
@ -129,7 +129,6 @@ func TestLoadJSON(t *testing.T) {
|
|||
cfg, err := loadJSON2(
|
||||
t,
|
||||
func(j *configJSON) {
|
||||
j.ReplicationFactor = 0
|
||||
j.ReplicationFactorMin = 0
|
||||
j.ReplicationFactorMax = 0
|
||||
},
|
||||
|
@ -142,16 +141,6 @@ func TestLoadJSON(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
t.Run("replication factor min/max override", func(t *testing.T) {
|
||||
cfg, err := loadJSON2(t, func(j *configJSON) { j.ReplicationFactor = 3 })
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if cfg.ReplicationFactorMin != 3 || cfg.ReplicationFactorMax != 3 {
|
||||
t.Error("expected replicationFactor Min/Max override")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("only replication factor min set to -1", func(t *testing.T) {
|
||||
_, err := loadJSON2(t, func(j *configJSON) { j.ReplicationFactorMin = -1 })
|
||||
if err == nil {
|
||||
|
|
|
@ -399,18 +399,6 @@ func (cfg *Manager) LoadJSON(bs []byte) error {
|
|||
}
|
||||
}
|
||||
|
||||
// Should we change hardcoded "ipfsproxy" to something else
|
||||
if _, ok := jcfg.API["ipfsproxy"]; !ok {
|
||||
loadCompJSON("ipfshttp", sections[API]["ipfsproxy"], jcfg.IPFSConn)
|
||||
logger.Warning(`
|
||||
The IPFS proxy functionality has been extracted as a separate component
|
||||
and now uses its own configuration section ("ipfsproxy" in the "api" section).
|
||||
|
||||
To keep compatibility, since you did not define an "ipfsproxy" section, the
|
||||
proxy configuration is taken from the "ipfshttp" section as before, but this
|
||||
will be removed in future versions.
|
||||
`)
|
||||
}
|
||||
return cfg.Validate()
|
||||
}
|
||||
|
||||
|
|
|
@ -118,28 +118,10 @@ func newRaftWrapper(
|
|||
return raftW, nil
|
||||
}
|
||||
|
||||
// makeDataFolder creates the folder that is meant
|
||||
// to store Raft data.
|
||||
// makeDataFolder creates the folder that is meant to store Raft data. Ensures
|
||||
// we always set 0700 mode.
|
||||
func makeDataFolder(folder string) error {
|
||||
// TODO(hector): Remove raft datafolder migration hack
|
||||
// in the future
|
||||
baseDir := filepath.Dir(folder)
|
||||
legacyFolder := filepath.Join(baseDir, "ipfs-cluster-data")
|
||||
|
||||
if _, err := os.Stat(legacyFolder); err == nil {
|
||||
// legacy data folder exists. Rename
|
||||
logger.Warningf("Renaming legacy data folder: %s -> %s", legacyFolder, folder)
|
||||
err := os.Rename(legacyFolder, folder)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err := os.MkdirAll(folder, 0700)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return os.MkdirAll(folder, 0700)
|
||||
}
|
||||
|
||||
func (rw *raftWrapper) makeTransport() (err error) {
|
||||
|
|
|
@ -64,14 +64,6 @@ type jsonConfig struct {
|
|||
IPFSRequestTimeout string `json:"ipfs_request_timeout"`
|
||||
PinTimeout string `json:"pin_timeout"`
|
||||
UnpinTimeout string `json:"unpin_timeout"`
|
||||
|
||||
// Fields below are only to maintain compatibility
|
||||
// They can be removed in future
|
||||
ProxyListenMultiaddress string `json:"proxy_listen_multiaddress,omitempty"`
|
||||
ProxyReadTimeout string `json:"proxy_read_timeout,omitempty"`
|
||||
ProxyReadHeaderTimeout string `json:"proxy_read_header_timeout,omitempty"`
|
||||
ProxyWriteTimeout string `json:"proxy_write_timeout,omitempty"`
|
||||
ProxyIdleTimeout string `json:"proxy_idle_timeout,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigKey provides a human-friendly identifier for this type of Config.
|
||||
|
|
Loading…
Reference in New Issue
Block a user