Skip to content

Commit

Permalink
chore: address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Fajerski <[email protected]>
  • Loading branch information
jan--f committed Nov 5, 2024
1 parent 2b63a0f commit 4f0e02c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
7 changes: 3 additions & 4 deletions pkg/controllers/operator/components.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package operator_controller
package operator

import (
"fmt"
Expand Down Expand Up @@ -37,7 +37,7 @@ func newServiceMonitor(namespace string) *monv1.ServiceMonitor {
"app.kubernetes.io/component": "operator",
"app.kubernetes.io/name": name,
"app.kubernetes.io/part-of": name,
"openshift.io/user-monitoring": "true",
"openshift.io/user-monitoring": "false",
},
},

Expand All @@ -51,8 +51,7 @@ func newServiceMonitor(namespace string) *monv1.ServiceMonitor {
CertFile: "/etc/prometheus/secrets/metrics-client-certs/tls.crt",
KeyFile: "/etc/prometheus/secrets/metrics-client-certs/tls.key",
SafeTLSConfig: monv1.SafeTLSConfig{
ServerName: ptr.To(fmt.Sprintf("%s.%s.svc", name, namespace)),
InsecureSkipVerify: ptr.To(false),
ServerName: ptr.To(fmt.Sprintf("%s.%s.svc", name, namespace)),
},
},
},
Expand Down
14 changes: 7 additions & 7 deletions pkg/controllers/operator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package operator_controller
package operator

import (
"context"
"time"

"github.com/go-logr/logr"
monv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -65,8 +65,8 @@ func RegisterWithManager(mgr ctrl.Manager, namespace string) error {
ctrl, err := ctrl.NewControllerManagedBy(mgr).
Owns(&monv1.ServiceMonitor{}, generationChanged).
Watches(
&appsv1.Deployment{},
handler.EnqueueRequestsFromMapFunc(rm.operatorDeployment),
&corev1.Service{},
handler.EnqueueRequestsFromMapFunc(rm.operatorService),
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
).
Build(rm)
Expand All @@ -82,7 +82,7 @@ func (rm resourceManager) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
logger := rm.logger.WithValues("operator", req.NamespacedName)
logger.Info("Reconciling operator resources")

op := &appsv1.Deployment{}
op := &corev1.Service{}
err := rm.k8sClient.Get(ctx, req.NamespacedName, op)
if errors.IsNotFound(err) {
return ctrl.Result{}, nil
Expand All @@ -107,9 +107,9 @@ func (rm resourceManager) Reconcile(ctx context.Context, req ctrl.Request) (ctrl

return ctrl.Result{}, nil
}
func (rm resourceManager) operatorDeployment(ctx context.Context, ms client.Object) []reconcile.Request {
func (rm resourceManager) operatorService(ctx context.Context, _ client.Object) []reconcile.Request {
var requests []reconcile.Request
op := &appsv1.Deployment{}
op := &corev1.Service{}
err := rm.k8sClient.Get(ctx, types.NamespacedName{Name: "observability-operator", Namespace: rm.namespace}, op)
if errors.IsNotFound(err) {
return requests
Expand Down
7 changes: 0 additions & 7 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ type OperatorConfiguration struct {
ThanosQuerier tqctrl.ThanosConfiguration
UIPlugins uictrl.UIPluginsConfiguration
FeatureGates FeatureGates
Namespace string
}

func WithNamespace(ns string) func(*OperatorConfiguration) {
Expand Down Expand Up @@ -123,12 +122,6 @@ func WithFeatureGates(featureGates FeatureGates) func(*OperatorConfiguration) {
}
}

func WithNamespace(ns string) func(*OperatorConfiguration) {
return func(oc *OperatorConfiguration) {
oc.Namespace = ns
}
}

func NewOperatorConfiguration(opts ...func(*OperatorConfiguration)) *OperatorConfiguration {
cfg := &OperatorConfiguration{}
for _, o := range opts {
Expand Down

0 comments on commit 4f0e02c

Please sign in to comment.