Skip to content

Commit

Permalink
[to be shquashed]fix(#4948): removed unecessary(?) objects selectors …
Browse files Browse the repository at this point in the history
…in platformcontroller operator cache.
  • Loading branch information
valdar committed Feb 15, 2024
1 parent 82e6c57 commit 253ce80
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions pkg/cmd/platformcontroller/platformcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"flag"
"fmt"
"os"
"reflect"
"runtime"
"strconv"
"strings"
Expand All @@ -34,13 +33,9 @@ import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"

appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
coordination "k8s.io/api/coordination/v1"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/client-go/tools/leaderelection/resourcelock"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/cache"
Expand All @@ -52,10 +47,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

servingv1 "knative.dev/serving/pkg/apis/serving/v1"

"github.com/apache/camel-k/v2/pkg/apis"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/client"
"github.com/apache/camel-k/v2/pkg/controller"
"github.com/apache/camel-k/v2/pkg/event"
Expand Down Expand Up @@ -182,29 +174,9 @@ func Run(healthPort, monitoringPort int32, leaderElection bool, leaderElectionID
log.Info("Leader election is disabled!")
}

//TODO: check if this part is actually needed from here.
hasIntegrationLabel, err := labels.NewRequirement(v1.IntegrationLabel, selection.Exists, []string{})
exitOnError(err, "cannot create Integration label selector")
selector := labels.NewSelector().Add(*hasIntegrationLabel)

selectors := map[ctrl.Object]cache.ByObject{
&corev1.Pod{}: {Label: selector},
&appsv1.Deployment{}: {Label: selector},
&batchv1.Job{}: {Label: selector},
&servingv1.Service{}: {Label: selector},
}

if ok, err := kubernetes.IsAPIResourceInstalled(bootstrapClient, batchv1.SchemeGroupVersion.String(), reflect.TypeOf(batchv1.CronJob{}).Name()); ok && err == nil {
selectors[&batchv1.CronJob{}] = cache.ByObject{
Label: selector,
}
}

options := cache.Options{
ByObject: selectors,
Namespaces: []string{watchNamespace},
}
//TODO: to here.

mgr, err := manager.New(cfg, manager.Options{
EventBroadcaster: broadcaster,
Expand Down

0 comments on commit 253ce80

Please sign in to comment.