Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com>
  • Loading branch information
Rizwana777 committed May 13, 2024
1 parent 2496558 commit 4359722
Show file tree
Hide file tree
Showing 4 changed files with 291 additions and 9 deletions.
11 changes: 3 additions & 8 deletions controllers/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,7 @@ func (r *RolloutManagerReconciler) reconcileRolloutsMetricsService(ctx context.C
}

// Create ServiceMonitor for Rollouts metrics
existingServiceMonitor := &monitoringv1.ServiceMonitor{
ObjectMeta: metav1.ObjectMeta{
Name: actualSvc.Name,
Namespace: actualSvc.Namespace,
},
}
existingServiceMonitor := &monitoringv1.ServiceMonitor{}
if err := fetchObject(ctx, r.Client, cr.Namespace, actualSvc.Name, existingServiceMonitor); err != nil {
if apierrors.IsNotFound(err) {
err = r.createServiceMonitorIfAbsent(ctx, cr.Namespace, cr, actualSvc.Name, actualSvc.Name)
Expand Down Expand Up @@ -1003,7 +998,7 @@ func GetAggregateToViewPolicyRules() []rbacv1.PolicyRule {
}
}

func (r *RolloutManagerReconciler) createServiceMonitorIfAbsent(ctx context.Context, namespace string, rolloutManager *rolloutsmanagerv1alpha1.RolloutManager, name, serviceMonitorLabel string) error {
func (r *RolloutManagerReconciler) createServiceMonitorIfAbsent(ctx context.Context, namespace string, rolloutManager rolloutsmanagerv1alpha1.RolloutManager, name, serviceMonitorLabel string) error {
serviceMonitor := &monitoringv1.ServiceMonitor{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -1026,7 +1021,7 @@ func (r *RolloutManagerReconciler) createServiceMonitorIfAbsent(ctx context.Cont
"Namespace", serviceMonitor.Namespace, "Name", serviceMonitor.Name)

// Set the RolloutManager instance as the owner and controller
if err := controllerutil.SetControllerReference(rolloutManager, serviceMonitor, r.Scheme); err != nil {
if err := controllerutil.SetControllerReference(&rolloutManager, serviceMonitor, r.Scheme); err != nil {
log.Error(err, "Error setting read role owner ref",
"Namespace", serviceMonitor.Namespace, "Name", serviceMonitor.Name, "RolloutManager Name", rolloutManager.Name)
return err
Expand Down
8 changes: 8 additions & 0 deletions controllers/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
"context"

rolloutsmanagerv1alpha1 "github.com/argoproj-labs/argo-rollouts-manager/api/v1alpha1"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -384,6 +386,12 @@ func makeTestReconciler(obj ...client.Object) *RolloutManagerReconciler {
err := rolloutsmanagerv1alpha1.AddToScheme(s)
Expect(err).ToNot(HaveOccurred())

err = monitoringv1.AddToScheme(s)
Expect(err).ToNot(HaveOccurred())

err = crdv1.AddToScheme(s)
Expect(err).ToNot(HaveOccurred())

cl := fake.NewClientBuilder().WithScheme(s).WithStatusSubresource(obj...).WithObjects(obj...).Build()

return &RolloutManagerReconciler{
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ require (
github.com/go-logr/logr v1.2.4
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.10
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.50.0
go.uber.org/zap v1.25.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.28.3
k8s.io/apiextensions-apiserver v0.28.3
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
sigs.k8s.io/controller-runtime v0.16.3
Expand Down Expand Up @@ -65,7 +67,6 @@ require (
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
Expand Down
Loading

0 comments on commit 4359722

Please sign in to comment.