mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Agency Cache Poll EE Extension (#1330)
This commit is contained in:
parent
7b9c0b4fed
commit
618b48f606
6 changed files with 95 additions and 28 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
|
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
|
||||||
- (Feature) AgencyCache Interface
|
- (Feature) AgencyCache Interface
|
||||||
|
- (Feature) Agency Cache Poll EE Extension
|
||||||
|
|
||||||
## [1.2.29](https://github.com/arangodb/kube-arangodb/tree/1.2.29) (2023-06-08)
|
## [1.2.29](https://github.com/arangodb/kube-arangodb/tree/1.2.29) (2023-06-08)
|
||||||
- (Maintenance) Add govulncheck to pipeline, update golangci-linter
|
- (Maintenance) Add govulncheck to pipeline, update golangci-linter
|
||||||
|
|
21
pkg/deployment/agency/cache/config.go
vendored
21
pkg/deployment/agency/cache/config.go
vendored
|
@ -24,26 +24,22 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(cmd *cobra.Command) error {
|
func Init(cmd *cobra.Command) error {
|
||||||
f := cmd.PersistentFlags()
|
f := cmd.PersistentFlags()
|
||||||
|
|
||||||
ee := version.GetVersionV1().IsEnterprise()
|
f.Bool("agency.poll-enabled", false, "The Agency poll functionality enablement (EnterpriseEdition Only)")
|
||||||
|
|
||||||
f.BoolVar(&global.PollEnabled, "agency.poll-enabled", ee, "The Agency poll functionality enablement (EnterpriseEdition Only)")
|
if err := f.MarkHidden("agency.poll-enabled"); err != nil {
|
||||||
|
return err
|
||||||
if !ee {
|
}
|
||||||
if err := f.MarkHidden("agency.poll-enabled"); err != nil {
|
if err := f.MarkDeprecated("agency.poll-enabled", "Flag moved to feature"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
f.DurationVar(&global.RefreshDelay, "agency.refresh-delay", util.BoolSwitch(ee, 500*time.Millisecond, 0), "The Agency refresh delay (0 = no delay)")
|
f.DurationVar(&global.RefreshDelay, "agency.refresh-delay", 500*time.Millisecond, "The Agency refresh delay (0 = no delay)")
|
||||||
f.DurationVar(&global.RefreshDelay, "agency.refresh-interval", 0, "The Agency refresh interval (0 = do not refresh)")
|
f.DurationVar(&global.RefreshInterval, "agency.refresh-interval", 0, "The Agency refresh interval (0 = do not refresh)")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -55,7 +51,6 @@ func GlobalConfig() Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
PollEnabled bool
|
|
||||||
RefreshDelay time.Duration
|
RefreshDelay time.Duration
|
||||||
RefreshInterval time.Duration
|
RefreshInterval time.Duration
|
||||||
}
|
}
|
||||||
|
|
28
pkg/deployment/agency/loader.community.go
Normal file
28
pkg/deployment/agency/loader.community.go
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
//go:build !enterprise
|
||||||
|
// +build !enterprise
|
||||||
|
|
||||||
|
package agency
|
||||||
|
|
||||||
|
func getLoaderBase[T interface{}]() StateLoader[T] {
|
||||||
|
return NewSimpleStateLoader[T]()
|
||||||
|
}
|
|
@ -39,14 +39,6 @@ func getLoader[T interface{}]() StateLoader[T] {
|
||||||
return loader
|
return loader
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLoaderBase[T interface{}]() StateLoader[T] {
|
|
||||||
if agencyCecheConfig.GlobalConfig().PollEnabled {
|
|
||||||
return NewSimpleStateLoader[T]()
|
|
||||||
} else {
|
|
||||||
return NewSimpleStateLoader[T]()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type StateLoader[T interface{}] interface {
|
type StateLoader[T interface{}] interface {
|
||||||
State() (*T, uint64, bool)
|
State() (*T, uint64, bool)
|
||||||
|
|
||||||
|
|
38
pkg/deployment/features/agency.go
Normal file
38
pkg/deployment/features/agency.go
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package features
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerFeature(agencyPoll)
|
||||||
|
}
|
||||||
|
|
||||||
|
var agencyPoll = &feature{
|
||||||
|
name: "agency-poll",
|
||||||
|
description: "Enable Agency Poll for Enterprise deployments",
|
||||||
|
version: "3.5.0",
|
||||||
|
enterpriseRequired: false,
|
||||||
|
operatorEnterpriseRequired: true,
|
||||||
|
enabledByDefault: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
func AgencyPoll() Feature {
|
||||||
|
return agencyPoll
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// DISCLAIMER
|
// DISCLAIMER
|
||||||
//
|
//
|
||||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -24,6 +24,7 @@ import (
|
||||||
"github.com/arangodb/go-driver"
|
"github.com/arangodb/go-driver"
|
||||||
|
|
||||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -38,6 +39,7 @@ type Feature interface {
|
||||||
Description() string
|
Description() string
|
||||||
Version() driver.Version
|
Version() driver.Version
|
||||||
EnterpriseRequired() bool
|
EnterpriseRequired() bool
|
||||||
|
OperatorEnterpriseRequired() bool
|
||||||
EnabledByDefault() bool
|
EnabledByDefault() bool
|
||||||
Enabled() bool
|
Enabled() bool
|
||||||
EnabledPointer() *bool
|
EnabledPointer() *bool
|
||||||
|
@ -48,12 +50,12 @@ type Feature interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type feature struct {
|
type feature struct {
|
||||||
name, description string
|
name, description string
|
||||||
version driver.Version
|
version driver.Version
|
||||||
enterpriseRequired, enabledByDefault, enabled bool
|
enterpriseRequired, operatorEnterpriseRequired, enabledByDefault, enabled bool
|
||||||
deprecated string
|
deprecated string
|
||||||
constValue *bool
|
constValue *bool
|
||||||
hidden bool
|
hidden bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f feature) ImageSupported(i *api.ImageInfo) bool {
|
func (f feature) ImageSupported(i *api.ImageInfo) bool {
|
||||||
|
@ -73,6 +75,13 @@ func (f feature) Supported(v driver.Version, enterprise bool) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f feature) Enabled() bool {
|
func (f feature) Enabled() bool {
|
||||||
|
if f.operatorEnterpriseRequired {
|
||||||
|
// Operator Enterprise is required for this feature
|
||||||
|
if !version.GetVersionV1().IsEnterprise() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if f.constValue != nil {
|
if f.constValue != nil {
|
||||||
return *f.constValue
|
return *f.constValue
|
||||||
}
|
}
|
||||||
|
@ -96,6 +105,10 @@ func (f feature) EnterpriseRequired() bool {
|
||||||
return f.enterpriseRequired
|
return f.enterpriseRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f feature) OperatorEnterpriseRequired() bool {
|
||||||
|
return f.operatorEnterpriseRequired
|
||||||
|
}
|
||||||
|
|
||||||
func (f feature) EnabledByDefault() bool {
|
func (f feature) EnabledByDefault() bool {
|
||||||
return f.enabledByDefault
|
return f.enabledByDefault
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue