Skip to content

Commit 6316144

Browse files
committed
fix the issues with namespaces for cluster scope
1 parent 7d4fe0a commit 6316144

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

cmd/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,20 +384,25 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
384384
if err != nil {
385385
return operator.Config{}, operator.Dependencies{}, maskAny(fmt.Errorf("Failed to created versioned client: %s", err))
386386
}
387-
eventRecorder := createRecorder(cliLog, kubecli, name, namespace)
388387

389388
scope, ok := scope.AsScope(operatorOptions.scope)
390389
if !ok {
391390
return operator.Config{}, operator.Dependencies{}, maskAny(fmt.Errorf("Scope %s is not known by Operator", operatorOptions.scope))
392391
}
393392

393+
var watchNamespace string
394394
if scope.IsCluster() {
395-
namespace = metav1.NamespaceAll
395+
watchNamespace = metav1.NamespaceAll
396+
} else {
397+
watchNamespace = namespace
396398
}
397399

400+
eventRecorder := createRecorder(cliLog, kubecli, name, watchNamespace)
401+
398402
cfg := operator.Config{
399403
ID: id,
400404
Namespace: namespace,
405+
WatchNamespace: watchNamespace,
401406
PodName: name,
402407
ServiceAccount: serviceAccount,
403408
OperatorImage: image,

pkg/operator/operator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ type Operator struct {
9393
type Config struct {
9494
ID string
9595
Namespace string
96+
WatchNamespace string
9697
PodName string
9798
ServiceAccount string
9899
OperatorImage string

pkg/operator/operator_deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (o *Operator) runDeployments(stop <-chan struct{}) {
4949
o.log,
5050
o.Dependencies.CRCli.DatabaseV1().RESTClient(),
5151
deploymentType.ArangoDeploymentResourcePlural,
52-
o.Config.Namespace,
52+
o.Config.WatchNamespace,
5353
&api.ArangoDeployment{},
5454
cache.ResourceEventHandlerFuncs{
5555
AddFunc: o.onAddArangoDeployment,

pkg/operator/operator_deployment_relication.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (o *Operator) runDeploymentReplications(stop <-chan struct{}) {
4949
o.log,
5050
o.Dependencies.CRCli.ReplicationV1().RESTClient(),
5151
replication2.ArangoDeploymentReplicationResourcePlural,
52-
o.Config.Namespace,
52+
o.Config.WatchNamespace,
5353
&api.ArangoDeploymentReplication{},
5454
cache.ResourceEventHandlerFuncs{
5555
AddFunc: o.onAddArangoDeploymentReplication,
@@ -201,7 +201,7 @@ func (o *Operator) handleDeploymentReplicationEvent(event *Event) error {
201201
// makeDeploymentReplicationConfigAndDeps creates a Config & Dependencies object for a new DeploymentReplication.
202202
func (o *Operator) makeDeploymentReplicationConfigAndDeps(apiObject *api.ArangoDeploymentReplication) (replication.Config, replication.Dependencies) {
203203
cfg := replication.Config{
204-
Namespace: o.Config.Namespace,
204+
Namespace: o.Config.WatchNamespace,
205205
}
206206
deps := replication.Dependencies{
207207
Log: o.Dependencies.LogService.MustGetLogger(logging.LoggerNameDeploymentReplication).With().

0 commit comments

Comments
 (0)