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)
|
||||
- (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)
|
||||
- (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"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"github.com/arangodb/kube-arangodb/pkg/version"
|
||||
)
|
||||
|
||||
func Init(cmd *cobra.Command) error {
|
||||
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 !ee {
|
||||
if err := f.MarkHidden("agency.poll-enabled"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f.MarkHidden("agency.poll-enabled"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f.MarkDeprecated("agency.poll-enabled", "Flag moved to feature"); err != nil {
|
||||
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-interval", 0, "The Agency refresh interval (0 = do not refresh)")
|
||||
f.DurationVar(&global.RefreshDelay, "agency.refresh-delay", 500*time.Millisecond, "The Agency refresh delay (0 = no delay)")
|
||||
f.DurationVar(&global.RefreshInterval, "agency.refresh-interval", 0, "The Agency refresh interval (0 = do not refresh)")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -55,7 +51,6 @@ func GlobalConfig() Config {
|
|||
}
|
||||
|
||||
type Config struct {
|
||||
PollEnabled bool
|
||||
RefreshDelay 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
|
||||
}
|
||||
|
||||
func getLoaderBase[T interface{}]() StateLoader[T] {
|
||||
if agencyCecheConfig.GlobalConfig().PollEnabled {
|
||||
return NewSimpleStateLoader[T]()
|
||||
} else {
|
||||
return NewSimpleStateLoader[T]()
|
||||
}
|
||||
}
|
||||
|
||||
type StateLoader[T interface{}] interface {
|
||||
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
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
// 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.
|
||||
|
@ -24,6 +24,7 @@ import (
|
|||
"github.com/arangodb/go-driver"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/version"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -38,6 +39,7 @@ type Feature interface {
|
|||
Description() string
|
||||
Version() driver.Version
|
||||
EnterpriseRequired() bool
|
||||
OperatorEnterpriseRequired() bool
|
||||
EnabledByDefault() bool
|
||||
Enabled() bool
|
||||
EnabledPointer() *bool
|
||||
|
@ -48,12 +50,12 @@ type Feature interface {
|
|||
}
|
||||
|
||||
type feature struct {
|
||||
name, description string
|
||||
version driver.Version
|
||||
enterpriseRequired, enabledByDefault, enabled bool
|
||||
deprecated string
|
||||
constValue *bool
|
||||
hidden bool
|
||||
name, description string
|
||||
version driver.Version
|
||||
enterpriseRequired, operatorEnterpriseRequired, enabledByDefault, enabled bool
|
||||
deprecated string
|
||||
constValue *bool
|
||||
hidden 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 {
|
||||
if f.operatorEnterpriseRequired {
|
||||
// Operator Enterprise is required for this feature
|
||||
if !version.GetVersionV1().IsEnterprise() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if f.constValue != nil {
|
||||
return *f.constValue
|
||||
}
|
||||
|
@ -96,6 +105,10 @@ func (f feature) EnterpriseRequired() bool {
|
|||
return f.enterpriseRequired
|
||||
}
|
||||
|
||||
func (f feature) OperatorEnterpriseRequired() bool {
|
||||
return f.operatorEnterpriseRequired
|
||||
}
|
||||
|
||||
func (f feature) EnabledByDefault() bool {
|
||||
return f.enabledByDefault
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue