Skip to content

Commit 618b48f

Browse files
authored
[Feature] Agency Cache Poll EE Extension (#1330)
1 parent 7b9c0b4 commit 618b48f

File tree

6 files changed

+95
-28
lines changed

6 files changed

+95
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
44
- (Feature) AgencyCache Interface
5+
- (Feature) Agency Cache Poll EE Extension
56

67
## [1.2.29](https://github.com/arangodb/kube-arangodb/tree/1.2.29) (2023-06-08)
78
- (Maintenance) Add govulncheck to pipeline, update golangci-linter

pkg/deployment/agency/cache/config.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,22 @@ import (
2424
"time"
2525

2626
"github.com/spf13/cobra"
27-
28-
"github.com/arangodb/kube-arangodb/pkg/util"
29-
"github.com/arangodb/kube-arangodb/pkg/version"
3027
)
3128

3229
func Init(cmd *cobra.Command) error {
3330
f := cmd.PersistentFlags()
3431

35-
ee := version.GetVersionV1().IsEnterprise()
36-
37-
f.BoolVar(&global.PollEnabled, "agency.poll-enabled", ee, "The Agency poll functionality enablement (EnterpriseEdition Only)")
32+
f.Bool("agency.poll-enabled", false, "The Agency poll functionality enablement (EnterpriseEdition Only)")
3833

39-
if !ee {
40-
if err := f.MarkHidden("agency.poll-enabled"); err != nil {
41-
return err
42-
}
34+
if err := f.MarkHidden("agency.poll-enabled"); err != nil {
35+
return err
36+
}
37+
if err := f.MarkDeprecated("agency.poll-enabled", "Flag moved to feature"); err != nil {
38+
return err
4339
}
4440

45-
f.DurationVar(&global.RefreshDelay, "agency.refresh-delay", util.BoolSwitch(ee, 500*time.Millisecond, 0), "The Agency refresh delay (0 = no delay)")
46-
f.DurationVar(&global.RefreshDelay, "agency.refresh-interval", 0, "The Agency refresh interval (0 = do not refresh)")
41+
f.DurationVar(&global.RefreshDelay, "agency.refresh-delay", 500*time.Millisecond, "The Agency refresh delay (0 = no delay)")
42+
f.DurationVar(&global.RefreshInterval, "agency.refresh-interval", 0, "The Agency refresh interval (0 = do not refresh)")
4743

4844
return nil
4945
}
@@ -55,7 +51,6 @@ func GlobalConfig() Config {
5551
}
5652

5753
type Config struct {
58-
PollEnabled bool
5954
RefreshDelay time.Duration
6055
RefreshInterval time.Duration
6156
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
//go:build !enterprise
22+
// +build !enterprise
23+
24+
package agency
25+
26+
func getLoaderBase[T interface{}]() StateLoader[T] {
27+
return NewSimpleStateLoader[T]()
28+
}

pkg/deployment/agency/loader.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ func getLoader[T interface{}]() StateLoader[T] {
3939
return loader
4040
}
4141

42-
func getLoaderBase[T interface{}]() StateLoader[T] {
43-
if agencyCecheConfig.GlobalConfig().PollEnabled {
44-
return NewSimpleStateLoader[T]()
45-
} else {
46-
return NewSimpleStateLoader[T]()
47-
}
48-
}
49-
5042
type StateLoader[T interface{}] interface {
5143
State() (*T, uint64, bool)
5244

pkg/deployment/features/agency.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package features
22+
23+
func init() {
24+
registerFeature(agencyPoll)
25+
}
26+
27+
var agencyPoll = &feature{
28+
name: "agency-poll",
29+
description: "Enable Agency Poll for Enterprise deployments",
30+
version: "3.5.0",
31+
enterpriseRequired: false,
32+
operatorEnterpriseRequired: true,
33+
enabledByDefault: false,
34+
}
35+
36+
func AgencyPoll() Feature {
37+
return agencyPoll
38+
}

pkg/deployment/features/features.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import (
2424
"github.com/arangodb/go-driver"
2525

2626
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
27+
"github.com/arangodb/kube-arangodb/pkg/version"
2728
)
2829

2930
const (
@@ -38,6 +39,7 @@ type Feature interface {
3839
Description() string
3940
Version() driver.Version
4041
EnterpriseRequired() bool
42+
OperatorEnterpriseRequired() bool
4143
EnabledByDefault() bool
4244
Enabled() bool
4345
EnabledPointer() *bool
@@ -48,12 +50,12 @@ type Feature interface {
4850
}
4951

5052
type feature struct {
51-
name, description string
52-
version driver.Version
53-
enterpriseRequired, enabledByDefault, enabled bool
54-
deprecated string
55-
constValue *bool
56-
hidden bool
53+
name, description string
54+
version driver.Version
55+
enterpriseRequired, operatorEnterpriseRequired, enabledByDefault, enabled bool
56+
deprecated string
57+
constValue *bool
58+
hidden bool
5759
}
5860

5961
func (f feature) ImageSupported(i *api.ImageInfo) bool {
@@ -73,6 +75,13 @@ func (f feature) Supported(v driver.Version, enterprise bool) bool {
7375
}
7476

7577
func (f feature) Enabled() bool {
78+
if f.operatorEnterpriseRequired {
79+
// Operator Enterprise is required for this feature
80+
if !version.GetVersionV1().IsEnterprise() {
81+
return false
82+
}
83+
}
84+
7685
if f.constValue != nil {
7786
return *f.constValue
7887
}
@@ -96,6 +105,10 @@ func (f feature) EnterpriseRequired() bool {
96105
return f.enterpriseRequired
97106
}
98107

108+
func (f feature) OperatorEnterpriseRequired() bool {
109+
return f.operatorEnterpriseRequired
110+
}
111+
99112
func (f feature) EnabledByDefault() bool {
100113
return f.enabledByDefault
101114
}

0 commit comments

Comments
 (0)