Skip to content

Commit 2924d74

Browse files
committed
fix the issues with namespaces for cluster scope
1 parent 82b2335 commit 2924d74

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

main.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -350,20 +350,25 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
350350
if err != nil {
351351
return operator.Config{}, operator.Dependencies{}, maskAny(fmt.Errorf("Failed to created versioned client: %s", err))
352352
}
353-
eventRecorder := createRecorder(cliLog, kubecli, name, namespace)
354353

355354
scope, ok := scope.AsScope(operatorOptions.scope)
356355
if !ok {
357356
return operator.Config{}, operator.Dependencies{}, maskAny(fmt.Errorf("Scope %s is not known by Operator", operatorOptions.scope))
358357
}
359358

359+
var watchNamespace string
360360
if scope.IsCluster() {
361-
namespace = metav1.NamespaceAll
361+
watchNamespace = metav1.NamespaceAll
362+
} else {
363+
watchNamespace = namespace
362364
}
363365

366+
eventRecorder := createRecorder(cliLog, kubecli, name, watchNamespace)
367+
364368
cfg := operator.Config{
365369
ID: id,
366370
Namespace: namespace,
371+
WatchNamespace: watchNamespace,
367372
PodName: name,
368373
ServiceAccount: serviceAccount,
369374
OperatorImage: image,

pkg/operator/operator.go

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type Operator struct {
8585
type Config struct {
8686
ID string
8787
Namespace string
88+
WatchNamespace string
8889
PodName string
8990
ServiceAccount string
9091
OperatorImage string

pkg/operator/operator_deployment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (o *Operator) runDeployments(stop <-chan struct{}) {
5151
o.log,
5252
o.Dependencies.CRCli.DatabaseV1().RESTClient(),
5353
deploymentType.ArangoDeploymentResourcePlural,
54-
o.Config.Namespace,
54+
o.Config.WatchNamespace,
5555
&api.ArangoDeployment{},
5656
cache.ResourceEventHandlerFuncs{
5757
AddFunc: o.onAddArangoDeployment,

pkg/operator/operator_deployment_relication.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (o *Operator) runDeploymentReplications(stop <-chan struct{}) {
5151
o.log,
5252
o.Dependencies.CRCli.ReplicationV1().RESTClient(),
5353
replication2.ArangoDeploymentReplicationResourcePlural,
54-
o.Config.Namespace,
54+
o.Config.WatchNamespace,
5555
&api.ArangoDeploymentReplication{},
5656
cache.ResourceEventHandlerFuncs{
5757
AddFunc: o.onAddArangoDeploymentReplication,
@@ -203,7 +203,7 @@ func (o *Operator) handleDeploymentReplicationEvent(event *Event) error {
203203
// makeDeploymentReplicationConfigAndDeps creates a Config & Dependencies object for a new DeploymentReplication.
204204
func (o *Operator) makeDeploymentReplicationConfigAndDeps(apiObject *api.ArangoDeploymentReplication) (replication.Config, replication.Dependencies) {
205205
cfg := replication.Config{
206-
Namespace: o.Config.Namespace,
206+
Namespace: o.Config.WatchNamespace,
207207
}
208208
deps := replication.Dependencies{
209209
Log: o.Dependencies.LogService.MustGetLogger(logging.LoggerNameDeploymentReplication).With().

0 commit comments

Comments
 (0)