Skip to content

Commit

Permalink
storage, etcd3: add an option for turning on/off compaction from apis…
Browse files Browse the repository at this point in the history
…erver

This commit adds an option for controlling request of compaction to
etcd3 from apiserver. There is a situation that apiserver cannot fully
own its etcd cluster (e.g. sharing it with canal). In such a case,
apiserver should have limited access in terms of etcd's auth
functionality so it don't have a priviledge to issue compaction
requests. It means that the compaction requests should be issued by
other component and apiserver's compaction requests are needless.

For such use cases, this commit adds a new flag
`storagebackend.Config.DisableCompaction`. If the flag is false (default),
apiserver issues the compaction requests like current behaviour. If it
is true, apiserver doesn't issue the requests. It can be configured
with a newly added option of apiserver `--etcd-disable-compaction`.
  • Loading branch information
mitake committed Sep 7, 2017
1 parent 1a3a071 commit fe3b759
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions staging/src/k8s.io/apiserver/pkg/server/options/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ func (s *EtcdOptions) AddFlags(fs *pflag.FlagSet) {

fs.StringVar(&s.EncryptionProviderConfigFilepath, "experimental-encryption-provider-config", s.EncryptionProviderConfigFilepath,
"The file containing configuration for encryption providers to be used for storing secrets in etcd")

fs.BoolVar(&s.StorageConfig.DisableCompaction, "etcd-disable-compaction", s.StorageConfig.DisableCompaction,
"If true, disable issuing compaction request from apiserver.")

}

func (s *EtcdOptions) ApplyTo(c *server.Config) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type Config struct {
Copier runtime.ObjectCopier
// Transformer allows the value to be transformed prior to persisting into etcd.
Transformer value.Transformer

// DisableCompaction is a flag to turn off requesting compaction from apiserver.
DisableCompaction bool
}

func NewDefaultConfig(prefix string, copier runtime.ObjectCopier, codec runtime.Codec) *Config {
Expand All @@ -58,7 +61,8 @@ func NewDefaultConfig(prefix string, copier runtime.ObjectCopier, codec runtime.
// Default cache size to 0 - if unset, its size will be set based on target
// memory usage.
DeserializationCacheSize: 0,
Copier: copier,
Codec: codec,
Copier: copier,
Codec: codec,
DisableCompaction: false,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ func newETCD3Storage(c storagebackend.Config) (storage.Interface, DestroyFunc, e
return nil, nil, err
}
ctx, cancel := context.WithCancel(context.Background())
etcd3.StartCompactor(ctx, client)
if !c.DisableCompaction {
etcd3.StartCompactor(ctx, client)
}
destroyFunc := func() {
cancel()
client.Close()
Expand Down

0 comments on commit fe3b759

Please sign in to comment.