Skip to content

Commit 88b6e4a

Browse files
committed
Do not enable Northd Metrics when exporterImage is unset
For minor update scenarios we need to honor exporterImage as in older versions will not have OpenstackNetworkExporterImage set so exporterImage="". So with this patch metrics will be enabled only when metricsEnabled=true and exporterImage is set. Also removed the default image as now included in openstack-operator like other images, this was temporary change. Also dropped unnecessary log message when deployment do not exist. Related-Issue: https://issues.redhat.com/browse/OSPRH-12568 Depends-On: openstack-k8s-operators/openstack-operator#1587
1 parent d8f5f3d commit 88b6e4a

5 files changed

Lines changed: 10 additions & 11 deletions

File tree

api/bases/ovn.openstack.org_ovnnorthds.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ spec:
5353
environmental default if empty)
5454
type: string
5555
exporterImage:
56-
default: quay.io/openstack-k8s-operators/openstack-network-exporter:current-podified
5756
description: ExporterImage - Container Image URL for the openstack-network-exporter
5857
metrics sidecar (will be set to environmental default if empty)
5958
type: string

api/v1beta1/ovnnorthd_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ type OVNNorthdSpec struct {
4646
ContainerImage string `json:"containerImage"`
4747

4848
// +kubebuilder:validation:Optional
49-
// +kubebuilder:default="quay.io/openstack-k8s-operators/openstack-network-exporter:current-podified"
5049
// ExporterImage - Container Image URL for the openstack-network-exporter metrics sidecar (will be set to environmental default if empty)
5150
ExporterImage string `json:"exporterImage,omitempty"`
5251

config/crd/bases/ovn.openstack.org_ovnnorthds.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ spec:
5353
environmental default if empty)
5454
type: string
5555
exporterImage:
56-
default: quay.io/openstack-k8s-operators/openstack-network-exporter:current-podified
5756
description: ExporterImage - Container Image URL for the openstack-network-exporter
5857
metrics sidecar (will be set to environmental default if empty)
5958
type: string

controllers/ovnnorthd_controller.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ func (r *OVNNorthdReconciler) reconcileNormal(ctx context.Context, instance *ovn
548548
}
549549
// create Deployment - end
550550

551-
// Create per-pod metrics services if metrics are enabled
552-
if instance.Spec.MetricsEnabled == nil || *instance.Spec.MetricsEnabled {
551+
// Create per-pod metrics services if metrics are enabled and exporter image is specified
552+
if instance.Spec.ExporterImage != "" && (instance.Spec.MetricsEnabled == nil || *instance.Spec.MetricsEnabled) {
553553
ctrlResult, err = r.reconcileMetricsServices(ctx, helper, instance, serviceLabels)
554554
if err != nil {
555555
Log.Error(err, "Failed to reconcile metrics services")
@@ -609,15 +609,18 @@ func (r *OVNNorthdReconciler) generateServiceConfigMaps(
609609
Labels: cmLabels,
610610
ConfigOptions: templateParameters,
611611
},
612-
// ConfigConfigMap for network exporter
613-
{
612+
}
613+
614+
// Add ConfigConfigMap for network exporter only if metrics are enabled and exporter image is specified
615+
if instance.Spec.ExporterImage != "" && (instance.Spec.MetricsEnabled == nil || *instance.Spec.MetricsEnabled) {
616+
cms = append(cms, util.Template{
614617
Name: fmt.Sprintf("%s-config", instance.Name),
615618
Namespace: instance.Namespace,
616619
Type: util.TemplateTypeConfig,
617620
InstanceType: instance.Kind,
618621
Labels: cmLabels,
619622
ConfigOptions: templateParameters,
620-
},
623+
})
621624
}
622625
return configmap.EnsureConfigMaps(ctx, h, instance, cms, envVars)
623626
}
@@ -719,7 +722,6 @@ func (r *OVNNorthdReconciler) cleanupLegacyDeployment(
719722
if err != nil {
720723
if k8s_errors.IsNotFound(err) {
721724
// Deployment doesn't exist, migration already complete
722-
Log.V(1).Info("No legacy deployment found, migration already complete")
723725
return nil
724726
}
725727
return fmt.Errorf("failed to check for legacy deployment %s: %w", deploymentName, err)

pkg/ovnnorthd/statefulset.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ func StatefulSet(
121121
},
122122
}
123123

124-
// Add metrics sidecar container if MetricsEnabled is true (default)
125-
if instance.Spec.MetricsEnabled == nil || *instance.Spec.MetricsEnabled {
124+
// Add metrics sidecar container if MetricsEnabled is true (default) and exporter image is specified
125+
if instance.Spec.ExporterImage != "" && (instance.Spec.MetricsEnabled == nil || *instance.Spec.MetricsEnabled) {
126126
metricsVolumeMounts := []corev1.VolumeMount{
127127
{
128128
Name: "ovn-rundir",

0 commit comments

Comments
 (0)