Skip to content

Commit

Permalink
Change how MetricStorage is copied in telemetry
Browse files Browse the repository at this point in the history
Chang the way the Telemetry controller copies MetricStorage spec
from the Telemetry CR to a MetricStorage CR to match the rest
of the code.

Fixes: https://issues.redhat.com/browse/OSPRH-9870

This will also prevent similar bugs in the future.
  • Loading branch information
vyzigold committed Sep 3, 2024
1 parent d03dd0d commit c0c86d1
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions controllers/telemetry_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
ceilometer "github.com/openstack-k8s-operators/telemetry-operator/pkg/ceilometer"
logging "github.com/openstack-k8s-operators/telemetry-operator/pkg/logging"
utils "github.com/openstack-k8s-operators/telemetry-operator/pkg/utils"
obov1 "github.com/rhobs/observability-operator/pkg/apis/monitoring/v1alpha1"
)

// TelemetryReconciler reconciles a Telemetry object
Expand Down Expand Up @@ -406,21 +405,7 @@ func (r TelemetryReconciler) reconcileMetricStorage(ctx context.Context, instanc

helper.GetLogger().Info("Reconciling MetricStorage", metricStorageNamespaceLabel, instance.Namespace, metricStorageNameLabel, telemetryv1.DefaultServiceName)
op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), metricStorageInstance, func() error {
if instance.Spec.MetricStorage.MetricStorageSpec.CustomMonitoringStack != nil {
metricStorageInstance.Spec.CustomMonitoringStack = &obov1.MonitoringStackSpec{}
instance.Spec.MetricStorage.MetricStorageSpec.CustomMonitoringStack.DeepCopyInto(metricStorageInstance.Spec.CustomMonitoringStack)
} else {
metricStorageInstance.Spec.CustomMonitoringStack = nil
}
if instance.Spec.MetricStorage.MetricStorageSpec.MonitoringStack != nil {
metricStorageInstance.Spec.MonitoringStack = &telemetryv1.MonitoringStack{}
instance.Spec.MetricStorage.MetricStorageSpec.MonitoringStack.DeepCopyInto(metricStorageInstance.Spec.MonitoringStack)
} else {
metricStorageInstance.Spec.MonitoringStack = nil
}
instance.Spec.MetricStorage.MetricStorageSpec.PrometheusTLS.DeepCopyInto(&metricStorageInstance.Spec.PrometheusTLS)
// TODO: Uncomment this line when implementing TLS for Alertmanager
//instance.Spec.MetricStorage.MetricStorageSpec.AlertmanagerTLS.DeepCopyInto(&metricStorageInstance.Spec.AlertmanagerTLS)
instance.Spec.MetricStorage.MetricStorageSpec.DeepCopyInto(&metricStorageInstance.Spec)

err := controllerutil.SetControllerReference(helper.GetBeforeObject(), metricStorageInstance, helper.GetScheme())
if err != nil {
Expand Down

0 comments on commit c0c86d1

Please sign in to comment.