[#1708] tree: Introduce unsafe_sync_disabled
param to disable synchronization
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m20s
Pre-commit hooks / Pre-commit (push) Successful in 1m46s
Build / Build Components (push) Successful in 1m54s
Tests and linters / Run gofumpt (push) Successful in 2m17s
Tests and linters / Tests (push) Successful in 2m28s
Tests and linters / Lint (push) Successful in 2m35s
Tests and linters / Staticcheck (push) Successful in 2m44s
Tests and linters / gopls check (push) Successful in 4m22s
Tests and linters / Tests with -race (push) Successful in 5m29s
OCI image / Build container images (push) Successful in 4m0s
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m20s
Pre-commit hooks / Pre-commit (push) Successful in 1m46s
Build / Build Components (push) Successful in 1m54s
Tests and linters / Run gofumpt (push) Successful in 2m17s
Tests and linters / Tests (push) Successful in 2m28s
Tests and linters / Lint (push) Successful in 2m35s
Tests and linters / Staticcheck (push) Successful in 2m44s
Tests and linters / gopls check (push) Successful in 4m22s
Tests and linters / Tests with -race (push) Successful in 5m29s
OCI image / Build container images (push) Successful in 4m0s
Close #1708. Change-Id: Id2eafe332cf495a2886c468348d1dcafddae1f2d Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
db5b5a5d19
commit
ab18ce0f20
5 changed files with 21 additions and 0 deletions
|
@ -87,6 +87,12 @@ func (c TreeConfig) SyncBatchSize() int {
|
||||||
return SyncBatchSizeDefault
|
return SyncBatchSizeDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnsafeSyncDisabled returns the value of "unsafe_sync_disabled"
|
||||||
|
// config parameter from the "tree" section.
|
||||||
|
func (c TreeConfig) UnsafeSyncDisabled() bool {
|
||||||
|
return config.BoolSafe(c.cfg, "unsafe_sync_disabled")
|
||||||
|
}
|
||||||
|
|
||||||
// AuthorizedKeys parses and returns an array of "authorized_keys" config
|
// AuthorizedKeys parses and returns an array of "authorized_keys" config
|
||||||
// parameter from "tree" section.
|
// parameter from "tree" section.
|
||||||
//
|
//
|
||||||
|
|
|
@ -64,6 +64,7 @@ func initTreeService(c *cfg) {
|
||||||
tree.WithReplicationChannelCapacity(treeConfig.ReplicationChannelCapacity()),
|
tree.WithReplicationChannelCapacity(treeConfig.ReplicationChannelCapacity()),
|
||||||
tree.WithReplicationWorkerCount(treeConfig.ReplicationWorkerCount()),
|
tree.WithReplicationWorkerCount(treeConfig.ReplicationWorkerCount()),
|
||||||
tree.WithSyncBatchSize(treeConfig.SyncBatchSize()),
|
tree.WithSyncBatchSize(treeConfig.SyncBatchSize()),
|
||||||
|
tree.WithSyncDisabled(treeConfig.UnsafeSyncDisabled()),
|
||||||
tree.WithAuthorizedKeys(treeConfig.AuthorizedKeys()),
|
tree.WithAuthorizedKeys(treeConfig.AuthorizedKeys()),
|
||||||
tree.WithMetrics(c.metricsCollector.TreeService()),
|
tree.WithMetrics(c.metricsCollector.TreeService()),
|
||||||
tree.WithAPELocalOverrideStorage(c.cfgObject.cfgAccessPolicyEngine.accessPolicyEngine.LocalStorage()),
|
tree.WithAPELocalOverrideStorage(c.cfgObject.cfgAccessPolicyEngine.accessPolicyEngine.LocalStorage()),
|
||||||
|
|
|
@ -44,6 +44,7 @@ type cfg struct {
|
||||||
containerCacheSize int
|
containerCacheSize int
|
||||||
authorizedKeys atomic.Pointer[[][]byte]
|
authorizedKeys atomic.Pointer[[][]byte]
|
||||||
syncBatchSize int
|
syncBatchSize int
|
||||||
|
syncDisabled bool
|
||||||
|
|
||||||
localOverrideStorage policyengine.LocalOverrideStorage
|
localOverrideStorage policyengine.LocalOverrideStorage
|
||||||
morphChainStorage policyengine.MorphRuleChainStorageReader
|
morphChainStorage policyengine.MorphRuleChainStorageReader
|
||||||
|
@ -122,6 +123,12 @@ func WithSyncBatchSize(n int) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithSyncDisabled(d bool) Option {
|
||||||
|
return func(c *cfg) {
|
||||||
|
c.syncDisabled = d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func WithContainerCacheSize(n int) Option {
|
func WithContainerCacheSize(n int) Option {
|
||||||
return func(c *cfg) {
|
return func(c *cfg) {
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
|
|
|
@ -89,6 +89,10 @@ func New(opts ...Option) *Service {
|
||||||
func (s *Service) Start(ctx context.Context) {
|
func (s *Service) Start(ctx context.Context) {
|
||||||
ctx = tagging.ContextWithIOTag(ctx, qos.IOTagTreeSync.String())
|
ctx = tagging.ContextWithIOTag(ctx, qos.IOTagTreeSync.String())
|
||||||
go s.replicateLoop(ctx)
|
go s.replicateLoop(ctx)
|
||||||
|
if s.syncDisabled {
|
||||||
|
s.initialSyncDone.Store(true)
|
||||||
|
return
|
||||||
|
}
|
||||||
go s.syncLoop(ctx)
|
go s.syncLoop(ctx)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
|
|
@ -419,6 +419,9 @@ func (s *Service) SynchronizeAll() error {
|
||||||
return ErrShuttingDown
|
return ErrShuttingDown
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
if s.syncDisabled {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case s.syncChan <- struct{}{}:
|
case s.syncChan <- struct{}{}:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue