Skip to content

Commit bfe70a8

Browse files
Merge pull request #479 from karelyatin/OSPRH-12568-cleanup
Do not enable Northd Metrics when exporterImage is unset
2 parents d8f5f3d + b19061f commit bfe70a8

6 files changed

Lines changed: 11 additions & 12 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ repos:
5454
- id: destroyed-symlinks
5555
- id: check-yaml
5656
args: [-m]
57-
exclude: "^templates/(ovnnorthd|openstackconfiggenerator|openstackcontrolplane)/.*$"
57+
exclude: "^templates/(ovnnorthd|ovndbcluster|ovncontroller)/.*$"
5858
- id: check-json
5959
- id: detect-private-key
6060
- id: end-of-file-fixer

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)