cmd/satellite: Allow core & API without live accounting cache
Allow the satellite commands which uses the live accounting cache (core and API) to run when at the time that its instantiated there is an error connecting to the backend. This prevent that if live accounting backend is down we can run these services because: 1. The services must run despite of the cache backend being down although it may be degraded. 2. We may need to start new replicas of the services or the services in a different place while we are troubleshooting and fixing the cache backend system. 3. Our services may restart when the cache backend or the network connecting to it fails momentarily. Change-Id: Ic93f9571bc0865c9488d64ab1356376fae797efc
This commit is contained in:
parent
0f70574e3c
commit
2e34b631b1
@ -13,6 +13,7 @@ import (
|
|||||||
"storj.io/private/version"
|
"storj.io/private/version"
|
||||||
"storj.io/storj/pkg/revocation"
|
"storj.io/storj/pkg/revocation"
|
||||||
"storj.io/storj/satellite"
|
"storj.io/storj/satellite"
|
||||||
|
"storj.io/storj/satellite/accounting"
|
||||||
"storj.io/storj/satellite/accounting/live"
|
"storj.io/storj/satellite/accounting/live"
|
||||||
"storj.io/storj/satellite/metainfo"
|
"storj.io/storj/satellite/metainfo"
|
||||||
"storj.io/storj/satellite/orders"
|
"storj.io/storj/satellite/orders"
|
||||||
@ -61,7 +62,13 @@ func cmdAPIRun(cmd *cobra.Command, args []string) (err error) {
|
|||||||
|
|
||||||
accountingCache, err := live.NewCache(log.Named("live-accounting"), runCfg.LiveAccounting)
|
accountingCache, err := live.NewCache(log.Named("live-accounting"), runCfg.LiveAccounting)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.New("Error creating live accounting cache on satellite api: %+v", err)
|
if !accounting.ErrSystemOrNetError.Has(err) || accountingCache == nil {
|
||||||
|
return errs.New("Error instantiating live accounting cache: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Warn("Unable to connect to live accounting cache. Verify connection",
|
||||||
|
zap.Error(err),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
err = errs.Combine(err, accountingCache.Close())
|
err = errs.Combine(err, accountingCache.Close())
|
||||||
|
@ -29,6 +29,7 @@ import (
|
|||||||
"storj.io/storj/pkg/revocation"
|
"storj.io/storj/pkg/revocation"
|
||||||
_ "storj.io/storj/private/version" // This attaches version information during release builds.
|
_ "storj.io/storj/private/version" // This attaches version information during release builds.
|
||||||
"storj.io/storj/satellite"
|
"storj.io/storj/satellite"
|
||||||
|
"storj.io/storj/satellite/accounting"
|
||||||
"storj.io/storj/satellite/accounting/live"
|
"storj.io/storj/satellite/accounting/live"
|
||||||
"storj.io/storj/satellite/compensation"
|
"storj.io/storj/satellite/compensation"
|
||||||
"storj.io/storj/satellite/metainfo"
|
"storj.io/storj/satellite/metainfo"
|
||||||
@ -356,7 +357,13 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) {
|
|||||||
|
|
||||||
liveAccounting, err := live.NewCache(log.Named("live-accounting"), runCfg.LiveAccounting)
|
liveAccounting, err := live.NewCache(log.Named("live-accounting"), runCfg.LiveAccounting)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.New("Error creating live accounting cache: %+v", err)
|
if !accounting.ErrSystemOrNetError.Has(err) || liveAccounting == nil {
|
||||||
|
return errs.New("Error instantiating live accounting cache: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Warn("Unable to connect to live accounting cache. Verify connection",
|
||||||
|
zap.Error(err),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
err = errs.Combine(err, liveAccounting.Close())
|
err = errs.Combine(err, liveAccounting.Close())
|
||||||
|
Loading…
Reference in New Issue
Block a user