Skip to content

Commit

Permalink
cm-apisrv/kvstoremesh: make max consecutive quorum errors configurable
Browse files Browse the repository at this point in the history
Extend the clustermesh-apiserver/kvstoremesh configurations by adding
the previously missed kvstore-max-consecutive-quorum-errors option to
match the one already provided by the Cilium agents, as well as configure
the same default value.

Fixes: 2911b44 ("kvstore: add a cell for the kvstore client")
Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
  • Loading branch information
giorio94 authored and michi-covalent committed May 6, 2024
1 parent 96c2eb8 commit 0836539
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions pkg/kvstore/cell.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ var Cell = func(defaultBackend string) cell.Cell {
"KVStore Client",

cell.Config(config{
KVStore: defaultBackend,
KVStoreConnectivityTimeout: defaults.KVstoreConnectivityTimeout,
KVStoreLeaseTTL: defaults.KVstoreLeaseTTL,
KVStorePeriodicSync: defaults.KVstorePeriodicSync,
KVStore: defaultBackend,
KVStoreConnectivityTimeout: defaults.KVstoreConnectivityTimeout,
KVStoreLeaseTTL: defaults.KVstoreLeaseTTL,
KVStorePeriodicSync: defaults.KVstorePeriodicSync,
KVstoreMaxConsecutiveQuorumErrors: defaults.KVstoreMaxConsecutiveQuorumErrors,
}),

cell.Provide(func(lc cell.Lifecycle, shutdowner hive.Shutdowner, cfg config, opts *ExtraOptions) promise.Promise[BackendOperations] {
Expand All @@ -50,6 +51,7 @@ var Cell = func(defaultBackend string) cell.Cell {
option.Config.KVstoreConnectivityTimeout = cfg.KVStoreConnectivityTimeout
option.Config.KVstoreLeaseTTL = cfg.KVStoreLeaseTTL
option.Config.KVstorePeriodicSync = cfg.KVStorePeriodicSync
option.Config.KVstoreMaxConsecutiveQuorumErrors = cfg.KVstoreMaxConsecutiveQuorumErrors

ctx, cancel := context.WithCancel(context.Background())
var wg sync.WaitGroup
Expand Down Expand Up @@ -94,11 +96,12 @@ var Cell = func(defaultBackend string) cell.Cell {
}

type config struct {
KVStore string
KVStoreOpt map[string]string
KVStoreConnectivityTimeout time.Duration
KVStoreLeaseTTL time.Duration
KVStorePeriodicSync time.Duration
KVStore string
KVStoreOpt map[string]string
KVStoreConnectivityTimeout time.Duration
KVStoreLeaseTTL time.Duration
KVStorePeriodicSync time.Duration
KVstoreMaxConsecutiveQuorumErrors uint
}

func (def config) Flags(flags *pflag.FlagSet) {
Expand All @@ -116,6 +119,9 @@ func (def config) Flags(flags *pflag.FlagSet) {

flags.Duration(option.KVstorePeriodicSync, def.KVStorePeriodicSync,
"Periodic KVstore synchronization interval")

flags.Uint(option.KVstoreMaxConsecutiveQuorumErrorsName, def.KVstoreMaxConsecutiveQuorumErrors,
"Max acceptable kvstore consecutive quorum errors before recreating the etcd connection")
}

// GlobalUserMgmtClientPromiseCell provides a promise returning the global kvstore client to perform users
Expand Down

0 comments on commit 0836539

Please sign in to comment.