Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cdi): remove service-monitor #328

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions images/cdi-artifact/patches/014-delete-service-monitor.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
diff --git a/cmd/cdi-operator/operator.go b/cmd/cdi-operator/operator.go
index 211f8cf70..4d166b992 100644
--- a/cmd/cdi-operator/operator.go
+++ b/cmd/cdi-operator/operator.go
@@ -26,7 +26,6 @@ import (
ocpconfigv1 "github.com/openshift/api/config/v1"
routev1 "github.com/openshift/api/route/v1"
secv1 "github.com/openshift/api/security/v1"
- promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"go.uber.org/zap/zapcore"
extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apiruntime "k8s.io/apimachinery/pkg/runtime"
@@ -38,6 +37,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

cdiv1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
+
"kubevirt.io/containerized-data-importer/pkg/operator/controller"
"kubevirt.io/containerized-data-importer/pkg/util"
)
@@ -117,11 +117,6 @@ func main() {
os.Exit(1)
}

- if err := promv1.AddToScheme(mgr.GetScheme()); err != nil {
- log.Error(err, "")
- os.Exit(1)
- }
-
if err := secv1.Install(mgr.GetScheme()); err != nil {
log.Error(err, "")
os.Exit(1)
diff --git a/pkg/operator/controller/callbacks.go b/pkg/operator/controller/callbacks.go
index fe40da5e4..7d97c3b8d 100644
--- a/pkg/operator/controller/callbacks.go
+++ b/pkg/operator/controller/callbacks.go
@@ -37,10 +37,11 @@ import (
sdk "kubevirt.io/controller-lifecycle-operator-sdk/pkg/sdk"

cdiv1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
+ "kubevirt.io/controller-lifecycle-operator-sdk/pkg/sdk/callbacks"
+
"kubevirt.io/containerized-data-importer/pkg/common"
cdicontroller "kubevirt.io/containerized-data-importer/pkg/controller"
cc "kubevirt.io/containerized-data-importer/pkg/controller/common"
- "kubevirt.io/controller-lifecycle-operator-sdk/pkg/sdk/callbacks"
)

func addReconcileCallbacks(r *ReconcileCDI) {
@@ -49,7 +50,6 @@ func addReconcileCallbacks(r *ReconcileCDI) {
r.reconciler.AddCallback(&corev1.ServiceAccount{}, reconcileServiceAccounts)
r.reconciler.AddCallback(&corev1.ServiceAccount{}, reconcileSCC)
r.reconciler.AddCallback(&appsv1.Deployment{}, reconcileCreateRoute)
- r.reconciler.AddCallback(&appsv1.Deployment{}, reconcileCreatePrometheusInfra)
r.reconciler.AddCallback(&appsv1.Deployment{}, reconcileRemainingRelationshipLabels)
r.reconciler.AddCallback(&appsv1.Deployment{}, reconcileDeleteSecrets)
r.reconciler.AddCallback(&appsv1.Deployment{}, reconcileCDICRD)
@@ -147,36 +147,6 @@ func reconcileSCC(args *callbacks.ReconcileCallbackArgs) error {
return nil
}

-func reconcileCreatePrometheusInfra(args *callbacks.ReconcileCallbackArgs) error {
- if args.State != callbacks.ReconcileStatePostRead {
- return nil
- }
-
- deployment := args.CurrentObject.(*appsv1.Deployment)
- // we don't check sdk.CheckDeploymentReady(deployment) since we want Prometheus to cover NotReady state as well
- if !isControllerDeployment(deployment) {
- return nil
- }
-
- cr := args.Resource.(runtime.Object)
- namespace := deployment.GetNamespace()
- if namespace == "" {
- return fmt.Errorf("cluster scoped owner not supported")
- }
-
- if deployed, err := isPrometheusDeployed(args.Logger, args.Client, namespace); err != nil {
- return err
- } else if !deployed {
- return nil
- }
- if err := ensurePrometheusResourcesExist(context.TODO(), args.Client, args.Scheme, deployment); err != nil {
- args.Recorder.Event(cr, corev1.EventTypeWarning, createResourceFailed, fmt.Sprintf("Failed to ensure prometheus resources exists, %v", err))
- return err
- }
-
- return nil
-}
-
func deleteWorkerResources(l logr.Logger, c client.Client) error {
listTypes := []client.ObjectList{&corev1.PodList{}, &corev1.ServiceList{}}

diff --git a/pkg/operator/controller/reconciler-hooks.go b/pkg/operator/controller/reconciler-hooks.go
index 6aafe14d6..fc55bff35 100644
--- a/pkg/operator/controller/reconciler-hooks.go
+++ b/pkg/operator/controller/reconciler-hooks.go
@@ -26,10 +26,6 @@ func (r *ReconcileCDI) watch() error {
return err
}

- if err := r.watchPrometheusResources(); err != nil {
- return err
- }
-
if err := r.watchRoutes(); err != nil {
return err
}
4 changes: 4 additions & 0 deletions images/cdi-artifact/patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ Do not manage DataVolume CRD with cdi-operator. Module will install this CRD usi
#### `011-change-storage-class-for-scratch-pvc.patch`

Set the storage class name for the scratch pvc from the original pvc that will own the scratch pvc, or set it to an empty value if not available.

#### `014-delete-service-monitor.patch`

Removed the creation of a service monitor from the cdi-operator.