Skip to content

Commit 2c683db

Browse files
committed
[Feature] Simplify Operator ID
1 parent 5e666d9 commit 2c683db

31 files changed

+180
-102
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- (Bugfix) (DP) Propagate Timeout Across Subcommands
88
- (Maintenance) Bump Dependencies
99
- (Feature) (Platform) EventsV1 Integration
10+
- (Feature) Simplify Operator ID Process
1011

1112
## [1.3.1](https://github.com/arangodb/kube-arangodb/tree/1.3.1) (2025-10-07)
1213
- (Documentation) Add ArangoPlatformStorage Docs & Examples

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ Flags:
196196
--http1.transport.keep-alive-timeout-short duration Interval between keep-alive probes for an active network connection (default 100ms)
197197
--http1.transport.max-idle-conns int Maximum number of idle (keep-alive) connections across all hosts. Zero means no limit (default 100)
198198
--http1.transport.tls-handshake-timeout duration Maximum amount of time to wait for a TLS handshake. Zero means no timeout (default 10s)
199-
--image.discovery.status Discover Operator Image from Pod Status by default. When disabled Pod Spec is used. (default true)
200199
--image.discovery.timeout duration Timeout for image discovery process (default 1m0s)
201200
--internal.scaling-integration Enable Scaling Integration
202201
--kubernetes.burst int Burst for the k8s API (default 256)

cmd/cmd.go

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ var (
162162
podSchedulingGracePeriod time.Duration
163163
}
164164
operatorImageDiscovery struct {
165-
timeout time.Duration
165+
timeout time.Duration
166+
//deprecated: Do not use this flag, as discovery methog changed
166167
defaultStatusDiscovery bool
167168
}
168169
operatorReconciliationRetry struct {
@@ -191,6 +192,12 @@ var (
191192
)
192193

193194
func init() {
195+
if err := initE(); err != nil {
196+
panic(err.Error())
197+
}
198+
}
199+
200+
func initE() error {
194201
var deprecatedStr string
195202

196203
f := cmdMain.Flags()
@@ -217,20 +224,14 @@ func init() {
217224
f.BoolVar(&operatorOptions.enablePlatform, "operator.platform", false, "Enable to run the Platform operator")
218225
f.BoolVar(&operatorOptions.enableScheduler, "operator.scheduler", false, "Enable to run the Scheduler operator")
219226
f.BoolVar(&operatorOptions.enableK2KClusterSync, "operator.k2k-cluster-sync", false, "Enable to run the ListSimple operator")
220-
f.MarkDeprecated("operator.k2k-cluster-sync", "Enabled within deployment operator")
221227
f.BoolVar(&operatorOptions.versionOnly, "operator.version", false, "Enable only version endpoint in Operator")
222228
f.StringVar(&deprecatedStr, "operator.alpine-image", "alpine:3.7", "Docker image used for alpine containers")
223-
f.MarkDeprecated("operator.alpine-image", "Value is not used anymore")
224229
f.StringVar(&deprecatedStr, "operator.metrics-exporter-image", "arangodb/arangodb-exporter:0.1.6", "Docker image used for metrics containers by default")
225-
f.MarkDeprecated("operator.metrics-exporter-image", "Value is not used anymore")
226230
f.StringVar(&deprecatedStr, "operator.arango-image", "arangodb/arangodb:latest", "Docker image used for arango by default")
227-
f.MarkDeprecated("operator.arango-image", "Value is not used anymore")
228231
f.BoolVar(&chaosOptions.allowed, "chaos.allowed", false, "Set to allow chaos in deployments. Only activated when allowed and enabled in deployment")
229232
f.BoolVar(&operatorOptions.skipLeaderLabel, "leader.label.skip", false, "Skips Leader Label for the Pod")
230233
f.BoolVar(&operatorOptions.singleMode, "mode.single", false, "Enable single mode in Operator. WARNING: There should be only one replica of Operator, otherwise Operator can take unexpected actions")
231234
f.String("scope", "", "Define scope on which Operator works. Legacy - pre 1.1.0 scope with limited cluster access")
232-
f.MarkDeprecated("scope", "Value is not used anymore")
233-
f.MarkHidden("scope")
234235
f.DurationVar(&operatorTimeouts.k8s, "timeout.k8s", globals.DefaultKubernetesTimeout, "The request timeout to the kubernetes")
235236
f.DurationVar(&operatorTimeouts.arangoD, "timeout.arangod", globals.DefaultArangoDTimeout, "The request timeout to the ArangoDB")
236237
f.DurationVar(&operatorTimeouts.arangoDCheck, "timeout.arangod-check", globals.DefaultArangoDCheckTimeout, "The version check request timeout to the ArangoDB")
@@ -260,21 +261,35 @@ func init() {
260261
f.BoolVar(&operatorImageDiscovery.defaultStatusDiscovery, "image.discovery.status", true, "Discover Operator Image from Pod Status by default. When disabled Pod Spec is used.")
261262
f.DurationVar(&operatorImageDiscovery.timeout, "image.discovery.timeout", time.Minute, "Timeout for image discovery process")
262263
f.IntVar(&threads, "threads", 16, "Number of the worker threads")
263-
if err := logging.Init(&cmdMain); err != nil {
264-
panic(err.Error())
265-
}
266-
if err := features.Init(&cmdMain); err != nil {
267-
panic(err.Error())
268-
}
269-
if err := agencyConfig.Init(&cmdMain); err != nil {
270-
panic(err.Error())
264+
265+
if err := errors.Errors(
266+
f.MarkDeprecated("operator.k2k-cluster-sync", "Enabled within deployment operator"),
267+
f.MarkDeprecated("operator.alpine-image", "Value is not used anymore"),
268+
f.MarkDeprecated("operator.metrics-exporter-image", "Value is not used anymore"),
269+
f.MarkDeprecated("operator.arango-image", "Value is not used anymore"),
270+
f.MarkDeprecated("scope", "Value is not used anymore"),
271+
f.MarkDeprecated("image.discovery.status", "Value fetched from the Operator Spec"),
272+
); err != nil {
273+
return errors.Wrap(err, "Unable to mark flags as deprecated")
271274
}
272-
if err := reconcile.ActionsConfigGlobal.Init(&cmdMain); err != nil {
273-
panic(err.Error())
275+
276+
if err := errors.Errors(
277+
f.MarkHidden("scope"),
278+
); err != nil {
279+
return errors.Wrap(err, "Unable to mark flags as hidden")
274280
}
275-
if err := operatorHTTP.InitConfiguration(&cmdMain); err != nil {
276-
panic(err.Error())
281+
282+
if err := errors.Errors(
283+
logging.Init(&cmdMain),
284+
features.Init(&cmdMain),
285+
agencyConfig.Init(&cmdMain),
286+
reconcile.ActionsConfigGlobal.Init(&cmdMain),
287+
operatorHTTP.InitConfiguration(&cmdMain),
288+
); err != nil {
289+
return errors.Wrap(err, "Unable to register secondary commands")
277290
}
291+
292+
return nil
278293
}
279294

280295
func Command() *cobra.Command {
@@ -590,7 +605,7 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
590605
Namespace: namespace,
591606
PodName: name,
592607
ServiceAccount: serviceAccount,
593-
OperatorImage: image,
608+
Image: image,
594609
SkipLeaderLabel: operatorOptions.skipLeaderLabel,
595610
EnableDeployment: operatorOptions.enableDeployment,
596611
EnableDeploymentReplication: operatorOptions.enableDeploymentReplication,
@@ -633,18 +648,24 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
633648

634649
// getMyPodInfo looks up the image & service account of the pod with given name in given namespace
635650
// Returns image, serviceAccount, error.
636-
func getMyPodInfo(kubecli kubernetes.Interface, namespace, name string) (string, string, error) {
637-
if image, sa, ok := getMyPodInfoWrap(kubecli, namespace, name, getMyImageInfoFunc(operatorImageDiscovery.defaultStatusDiscovery)); ok {
638-
return image, sa, nil
639-
}
651+
func getMyPodInfo(kubecli kubernetes.Interface, namespace, name string) (util.Image, string, error) {
652+
var ret util.Image
653+
var serviceAccount string
640654

641-
logger.Warn("Unable to discover image, fallback to second method")
655+
if image, sa, ok := getMyPodInfoWrap(kubecli, namespace, name, getMyImageInfoFunc(false)); !ok {
656+
return util.Image{}, "", errors.Errorf("Unable to discover Operator image from Spec")
657+
} else {
658+
ret.Image = image
659+
serviceAccount = sa
660+
}
642661

643-
if image, sa, ok := getMyPodInfoWrap(kubecli, namespace, name, getMyImageInfoFunc(!operatorImageDiscovery.defaultStatusDiscovery)); ok {
644-
return image, sa, nil
662+
if image, _, ok := getMyPodInfoWrap(kubecli, namespace, name, getMyImageInfoFunc(!operatorImageDiscovery.defaultStatusDiscovery)); ok {
663+
ret.StatusImage = util.NewType(image)
664+
} else {
665+
logger.Warn("Unable to discover image from status")
645666
}
646667

647-
return "", "", errors.Errorf("Unable to discover image")
668+
return ret, serviceAccount, nil
648669
}
649670

650671
func getMyPodInfoWrap(kubecli kubernetes.Interface, namespace, name string, imageFunc func(in *core.Pod) (string, bool)) (string, string, bool) {

docs/cli/arangodb_operator.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ Flags:
7878
--http1.transport.keep-alive-timeout-short duration Interval between keep-alive probes for an active network connection (default 100ms)
7979
--http1.transport.max-idle-conns int Maximum number of idle (keep-alive) connections across all hosts. Zero means no limit (default 100)
8080
--http1.transport.tls-handshake-timeout duration Maximum amount of time to wait for a TLS handshake. Zero means no timeout (default 10s)
81-
--image.discovery.status Discover Operator Image from Pod Status by default. When disabled Pod Spec is used. (default true)
8281
--image.discovery.timeout duration Timeout for image discovery process (default 1m0s)
8382
--internal.scaling-integration Enable Scaling Integration
8483
--kubernetes.burst int Burst for the k8s API (default 256)

integrations/scheduler/v2/suite_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/arangodb/kube-arangodb/pkg/logging"
3333
operator "github.com/arangodb/kube-arangodb/pkg/operatorV2"
3434
"github.com/arangodb/kube-arangodb/pkg/operatorV2/event"
35+
"github.com/arangodb/kube-arangodb/pkg/util"
3536
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/helm"
3637
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
3738
"github.com/arangodb/kube-arangodb/pkg/util/kclient/external"
@@ -102,7 +103,7 @@ func MockClient(t *testing.T, ctx context.Context, mods ...Mod) (pbSchedulerV2.S
102103
}
103104

104105
func chartHandler(client kclient.Client, ns string) operator.Handler {
105-
op := operator.NewOperator("mock", ns, "mock")
106+
op := operator.NewOperator("mock", ns, util.Image{Image: "mock"})
106107
recorder := event.NewEventRecorder("mock", client.Kubernetes())
107108

108109
return chart.Handler(op, recorder, client)

pkg/deployment/context_impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (d *Deployment) GetServerGroupIterator() reconciler.ServerGroupIterator {
8484
}
8585

8686
func (d *Deployment) GetOperatorImage() string {
87-
return d.config.OperatorImage
87+
return d.config.Image.Get(d.GetSpec().ImageDiscoveryMode.Get() == api.DeploymentImageDiscoveryKubeletMode)
8888
}
8989

9090
// GetNamespace returns the kubernetes namespace that contains

pkg/deployment/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ type Config struct {
7171
ServiceAccount string
7272
AllowChaos bool
7373
ScalingIntegrationEnabled bool
74-
OperatorImage string
74+
Image util.Image
7575
ReconciliationDelay time.Duration
7676
}
7777

pkg/deployment/deployment_core_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
459459
},
460460
},
461461
config: Config{
462-
OperatorImage: testImageOperator,
462+
Image: util.Image{Image: testImageOperator},
463463
},
464464
Helper: func(t *testing.T, deployment *Deployment, testCase *testCaseStruct) {
465465
deployment.currentObjectStatus = &api.DeploymentStatus{
@@ -690,7 +690,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
690690
},
691691
},
692692
config: Config{
693-
OperatorImage: testImageOperator,
693+
Image: util.Image{Image: testImageOperator},
694694
},
695695
Helper: func(t *testing.T, deployment *Deployment, testCase *testCaseStruct) {
696696
deployment.currentObjectStatus = &api.DeploymentStatus{
@@ -1237,7 +1237,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
12371237
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
12381238
},
12391239
config: Config{
1240-
OperatorImage: testImageOperator,
1240+
Image: util.Image{Image: testImageOperator},
12411241
},
12421242
ExpectedEvent: "member dbserver is created",
12431243
ExpectedPod: core.Pod{
@@ -1307,7 +1307,7 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
13071307
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, false, authorization, shared.ServerPortName)
13081308
},
13091309
config: Config{
1310-
OperatorImage: testImageOperator,
1310+
Image: util.Image{Image: testImageOperator},
13111311
},
13121312
ExpectedEvent: "member dbserver is created",
13131313
ExpectedPod: core.Pod{

pkg/deployment/deployment_encryption_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 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.
@@ -132,7 +132,7 @@ func TestEnsurePod_ArangoDB_Encryption(t *testing.T) {
132132
testCase.ExpectedPod.Spec.Containers[0].LivenessProbe = createTestLivenessProbe(httpProbe, true, authorization, shared.ServerPortName)
133133
},
134134
config: Config{
135-
OperatorImage: testImageOperator,
135+
Image: util.Image{Image: testImageOperator},
136136
},
137137
ExpectedEvent: "member dbserver is created",
138138
ExpectedPod: core.Pod{

pkg/deployment/deployment_pod_sync_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
289289
DropInit: true,
290290
Name: "Sync Master Pod with lifecycle, license, monitoring without authentication and alpine",
291291
config: Config{
292-
OperatorImage: testImageOperator,
292+
Image: util.Image{Image: testImageOperator},
293293
},
294294
ArangoDeployment: &api.ArangoDeployment{
295295
Spec: api.DeploymentSpec{
@@ -377,7 +377,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
377377
DropInit: true,
378378
Name: "Sync Master Pod alias - existing service, ClusterIP and valid name",
379379
config: Config{
380-
OperatorImage: testImageOperator,
380+
Image: util.Image{Image: testImageOperator},
381381
},
382382
ArangoDeployment: &api.ArangoDeployment{
383383
Spec: api.DeploymentSpec{
@@ -489,7 +489,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
489489
DropInit: true,
490490
Name: "Sync Master Pod alias - missing service and valid name",
491491
config: Config{
492-
OperatorImage: testImageOperator,
492+
Image: util.Image{Image: testImageOperator},
493493
},
494494
ArangoDeployment: &api.ArangoDeployment{
495495
Spec: api.DeploymentSpec{
@@ -582,7 +582,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
582582
DropInit: true,
583583
Name: "Sync Master Pod alias - existing service, missing ClusterIP and valid name",
584584
config: Config{
585-
OperatorImage: testImageOperator,
585+
Image: util.Image{Image: testImageOperator},
586586
},
587587
ArangoDeployment: &api.ArangoDeployment{
588588
Spec: api.DeploymentSpec{
@@ -683,7 +683,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
683683
DropInit: true,
684684
Name: "Sync Master Pod alias - existing service, ClusterIP and invalid name",
685685
config: Config{
686-
OperatorImage: testImageOperator,
686+
Image: util.Image{Image: testImageOperator},
687687
},
688688
ArangoDeployment: &api.ArangoDeployment{
689689
Spec: api.DeploymentSpec{
@@ -787,7 +787,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
787787
DropInit: true,
788788
Name: "Sync Master Pod alias - existing service, ClusterIP and missing name",
789789
config: Config{
790-
OperatorImage: testImageOperator,
790+
Image: util.Image{Image: testImageOperator},
791791
},
792792
ArangoDeployment: &api.ArangoDeployment{
793793
Spec: api.DeploymentSpec{
@@ -886,7 +886,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
886886
DropInit: true,
887887
Name: "Sync Master Pod alias - existing service, ClusterIP and valid names",
888888
config: Config{
889-
OperatorImage: testImageOperator,
889+
Image: util.Image{Image: testImageOperator},
890890
},
891891
ArangoDeployment: &api.ArangoDeployment{
892892
Spec: api.DeploymentSpec{
@@ -1002,7 +1002,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
10021002
DropInit: true,
10031003
Name: "Sync Master Pod alias - existing service, ClusterIP and valid names with different ports",
10041004
config: Config{
1005-
OperatorImage: testImageOperator,
1005+
Image: util.Image{Image: testImageOperator},
10061006
},
10071007
ArangoDeployment: &api.ArangoDeployment{
10081008
Spec: api.DeploymentSpec{
@@ -1116,7 +1116,7 @@ func TestEnsurePod_Sync_Master(t *testing.T) {
11161116
DropInit: true,
11171117
Name: "Sync Master Pod alias - existing service, ClusterIP and mixed names",
11181118
config: Config{
1119-
OperatorImage: testImageOperator,
1119+
Image: util.Image{Image: testImageOperator},
11201120
},
11211121
ArangoDeployment: &api.ArangoDeployment{
11221122
Spec: api.DeploymentSpec{
@@ -1239,7 +1239,7 @@ func TestEnsurePod_Sync_Worker(t *testing.T) {
12391239
Name: "Sync Worker Pod with monitoring, service account, node selector, lifecycle, license " +
12401240
"liveness probe, priority class name, resource requirements without alpine",
12411241
config: Config{
1242-
OperatorImage: testImageOperator,
1242+
Image: util.Image{Image: testImageOperator},
12431243
},
12441244
ArangoDeployment: &api.ArangoDeployment{
12451245
Spec: api.DeploymentSpec{
@@ -1334,7 +1334,7 @@ func TestEnsurePod_Sync_Worker(t *testing.T) {
13341334
InitContainersCopyResources: util.NewType(false),
13351335
},
13361336
config: Config{
1337-
OperatorImage: testImageOperator,
1337+
Image: util.Image{Image: testImageOperator},
13381338
},
13391339
ArangoDeployment: &api.ArangoDeployment{
13401340
Spec: api.DeploymentSpec{

0 commit comments

Comments
 (0)