Skip to content

Commit 2e89e59

Browse files
Merge pull request #476 from openshift-cherrypick-robot/cherry-pick-424-to-18.0.0-proposed
[18.0.0-proposed] [OSPRH-8076] Fix CustomMonitoringStack
2 parents 2e54f59 + fa62956 commit 2e89e59

13 files changed

+211
-68
lines changed

api/bases/telemetry.openstack.org_metricstorages.yaml

+13-13
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,17 @@ spec:
10691069
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
10701070
type: string
10711071
type: object
1072+
dashboardsEnabled:
1073+
default: false
1074+
description: DashboardsEnabled allows to enable or disable dashboards
1075+
and related artifacts
1076+
type: boolean
1077+
dataplaneNetwork:
1078+
default: ctlplane
1079+
description: DataplaneNetwork defines the network that will be used
1080+
to scrape dataplane node_exporter endpoints
1081+
pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9]$
1082+
type: string
10721083
monitoringStack:
10731084
description: MonitoringStack allows to define a metric storage with
10741085
options supported by Red Hat
@@ -1078,17 +1089,6 @@ spec:
10781089
default: true
10791090
description: AlertingEnabled allows to enable or disable alertmanager
10801091
type: boolean
1081-
dashboardsEnabled:
1082-
default: false
1083-
description: DashboardsEnabled allows to enable or disable dashboards
1084-
and related artifacts
1085-
type: boolean
1086-
dataplaneNetwork:
1087-
default: ctlplane
1088-
description: DataplaneNetwork defines the network that will be
1089-
used to scrape dataplane node_exporter endpoints
1090-
pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9]$
1091-
type: string
10921092
scrapeInterval:
10931093
default: 30s
10941094
description: ScrapeInterval sets the interval between scrapes
@@ -1175,8 +1175,6 @@ spec:
11751175
- persistent
11761176
type: string
11771177
type: object
1178-
required:
1179-
- dataplaneNetwork
11801178
type: object
11811179
prometheusTls:
11821180
description: TLS - Parameters related to the TLS
@@ -1189,6 +1187,8 @@ spec:
11891187
description: SecretName - holding the cert, key for the service
11901188
type: string
11911189
type: object
1190+
required:
1191+
- dataplaneNetwork
11921192
type: object
11931193
status:
11941194
description: MetricStorageStatus defines the observed state of MetricStorage

api/bases/telemetry.openstack.org_telemetries.yaml

+13-13
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,17 @@ spec:
15971597
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
15981598
type: string
15991599
type: object
1600+
dashboardsEnabled:
1601+
default: false
1602+
description: DashboardsEnabled allows to enable or disable dashboards
1603+
and related artifacts
1604+
type: boolean
1605+
dataplaneNetwork:
1606+
default: ctlplane
1607+
description: DataplaneNetwork defines the network that will be
1608+
used to scrape dataplane node_exporter endpoints
1609+
pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9]$
1610+
type: string
16001611
enabled:
16011612
default: false
16021613
description: Enabled - Whether a MetricStorage should be deployed
@@ -1611,17 +1622,6 @@ spec:
16111622
default: true
16121623
description: AlertingEnabled allows to enable or disable alertmanager
16131624
type: boolean
1614-
dashboardsEnabled:
1615-
default: false
1616-
description: DashboardsEnabled allows to enable or disable
1617-
dashboards and related artifacts
1618-
type: boolean
1619-
dataplaneNetwork:
1620-
default: ctlplane
1621-
description: DataplaneNetwork defines the network that will
1622-
be used to scrape dataplane node_exporter endpoints
1623-
pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9]$
1624-
type: string
16251625
scrapeInterval:
16261626
default: 30s
16271627
description: ScrapeInterval sets the interval between scrapes
@@ -1710,8 +1710,6 @@ spec:
17101710
- persistent
17111711
type: string
17121712
type: object
1713-
required:
1714-
- dataplaneNetwork
17151713
type: object
17161714
prometheusTls:
17171715
description: TLS - Parameters related to the TLS
@@ -1724,6 +1722,8 @@ spec:
17241722
description: SecretName - holding the cert, key for the service
17251723
type: string
17261724
type: object
1725+
required:
1726+
- dataplaneNetwork
17271727
type: object
17281728
type: object
17291729
status:

api/v1beta1/metricstorage_types.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,11 @@ type MonitoringStack struct {
6767
// +kubebuilder:default=true
6868
AlertingEnabled bool `json:"alertingEnabled"`
6969

70-
// DashboardsEnabled allows to enable or disable dashboards and related artifacts
71-
// +kubebuilder:validation:Optional
72-
// +kubebuilder:default=false
73-
DashboardsEnabled bool `json:"dashboardsEnabled"`
74-
7570
// ScrapeInterval sets the interval between scrapes
7671
// +kubebuilder:validation:Optional
7772
// +kubebuilder:default="30s"
7873
ScrapeInterval string `json:"scrapeInterval"`
7974

80-
// DataplaneNetwork defines the network that will be used to scrape dataplane node_exporter endpoints
81-
// +kubebuilder:default=ctlplane
82-
DataplaneNetwork infranetworkv1.NetNameStr `json:"dataplaneNetwork"`
83-
8475
// Storage allows to define options for how to store metrics
8576
// +kubebuilder:validation:Optional
8677
// +kubebuilder:default={strategy: persistent, retention: "24h", persistent: {pvcStorageRequest: "20G"}}
@@ -89,6 +80,15 @@ type MonitoringStack struct {
8980

9081
// MetricStorageSpec defines the desired state of MetricStorage
9182
type MetricStorageSpec struct {
83+
// DashboardsEnabled allows to enable or disable dashboards and related artifacts
84+
// +kubebuilder:validation:Optional
85+
// +kubebuilder:default=false
86+
DashboardsEnabled bool `json:"dashboardsEnabled"`
87+
88+
// DataplaneNetwork defines the network that will be used to scrape dataplane node_exporter endpoints
89+
// +kubebuilder:default=ctlplane
90+
DataplaneNetwork infranetworkv1.NetNameStr `json:"dataplaneNetwork"`
91+
9292
// MonitoringStack allows to define a metric storage with
9393
// options supported by Red Hat
9494
// +kubebuilder:validation:Optional

api/v1beta1/metricstorage_webhook.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ func (spec *MetricStorageSpec) Default() {
5555
// NOTE: If we want to enable dashboards in the future by default, set
5656
// it here like Alerting above
5757
}
58+
if spec.DataplaneNetwork == "" {
59+
spec.DataplaneNetwork = "ctlplane"
60+
}
5861
if spec.MonitoringStack != nil {
5962
spec.MonitoringStack.Default()
6063
}
@@ -65,9 +68,6 @@ func (ms *MonitoringStack) Default() {
6568
if ms.ScrapeInterval == "" {
6669
ms.ScrapeInterval = "30s"
6770
}
68-
if ms.DataplaneNetwork == "" {
69-
ms.DataplaneNetwork = "ctlplane"
70-
}
7171
ms.Storage.Default()
7272
}
7373

config/crd/bases/telemetry.openstack.org_metricstorages.yaml

+13-13
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,17 @@ spec:
10691069
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
10701070
type: string
10711071
type: object
1072+
dashboardsEnabled:
1073+
default: false
1074+
description: DashboardsEnabled allows to enable or disable dashboards
1075+
and related artifacts
1076+
type: boolean
1077+
dataplaneNetwork:
1078+
default: ctlplane
1079+
description: DataplaneNetwork defines the network that will be used
1080+
to scrape dataplane node_exporter endpoints
1081+
pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9]$
1082+
type: string
10721083
monitoringStack:
10731084
description: MonitoringStack allows to define a metric storage with
10741085
options supported by Red Hat
@@ -1078,17 +1089,6 @@ spec:
10781089
default: true
10791090
description: AlertingEnabled allows to enable or disable alertmanager
10801091
type: boolean
1081-
dashboardsEnabled:
1082-
default: false
1083-
description: DashboardsEnabled allows to enable or disable dashboards
1084-
and related artifacts
1085-
type: boolean
1086-
dataplaneNetwork:
1087-
default: ctlplane
1088-
description: DataplaneNetwork defines the network that will be
1089-
used to scrape dataplane node_exporter endpoints
1090-
pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9]$
1091-
type: string
10921092
scrapeInterval:
10931093
default: 30s
10941094
description: ScrapeInterval sets the interval between scrapes
@@ -1175,8 +1175,6 @@ spec:
11751175
- persistent
11761176
type: string
11771177
type: object
1178-
required:
1179-
- dataplaneNetwork
11801178
type: object
11811179
prometheusTls:
11821180
description: TLS - Parameters related to the TLS
@@ -1189,6 +1187,8 @@ spec:
11891187
description: SecretName - holding the cert, key for the service
11901188
type: string
11911189
type: object
1190+
required:
1191+
- dataplaneNetwork
11921192
type: object
11931193
status:
11941194
description: MetricStorageStatus defines the observed state of MetricStorage

config/crd/bases/telemetry.openstack.org_telemetries.yaml

+13-13
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,17 @@ spec:
15971597
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
15981598
type: string
15991599
type: object
1600+
dashboardsEnabled:
1601+
default: false
1602+
description: DashboardsEnabled allows to enable or disable dashboards
1603+
and related artifacts
1604+
type: boolean
1605+
dataplaneNetwork:
1606+
default: ctlplane
1607+
description: DataplaneNetwork defines the network that will be
1608+
used to scrape dataplane node_exporter endpoints
1609+
pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9]$
1610+
type: string
16001611
enabled:
16011612
default: false
16021613
description: Enabled - Whether a MetricStorage should be deployed
@@ -1611,17 +1622,6 @@ spec:
16111622
default: true
16121623
description: AlertingEnabled allows to enable or disable alertmanager
16131624
type: boolean
1614-
dashboardsEnabled:
1615-
default: false
1616-
description: DashboardsEnabled allows to enable or disable
1617-
dashboards and related artifacts
1618-
type: boolean
1619-
dataplaneNetwork:
1620-
default: ctlplane
1621-
description: DataplaneNetwork defines the network that will
1622-
be used to scrape dataplane node_exporter endpoints
1623-
pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9]$
1624-
type: string
16251625
scrapeInterval:
16261626
default: 30s
16271627
description: ScrapeInterval sets the interval between scrapes
@@ -1710,8 +1710,6 @@ spec:
17101710
- persistent
17111711
type: string
17121712
type: object
1713-
required:
1714-
- dataplaneNetwork
17151713
type: object
17161714
prometheusTls:
17171715
description: TLS - Parameters related to the TLS
@@ -1724,6 +1722,8 @@ spec:
17241722
description: SecretName - holding the cert, key for the service
17251723
type: string
17261724
type: object
1725+
required:
1726+
- dataplaneNetwork
17271727
type: object
17281728
type: object
17291729
status:

controllers/metricstorage_controller.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ func (r *MetricStorageReconciler) reconcileNormal(
522522
}
523523
instance.Status.Conditions.MarkTrue(telemetryv1.ScrapeConfigReadyCondition, condition.ReadyMessage)
524524

525-
if !instance.Spec.MonitoringStack.DashboardsEnabled {
525+
if !instance.Spec.DashboardsEnabled {
526526
if res, err := metricstorage.DeleteDashboardObjects(ctx, instance, helper); err != nil {
527527
return res, err
528528
}
@@ -874,7 +874,7 @@ func getAddressFromIPSet(
874874
if len(ipset.Status.Reservation) > 0 {
875875
// search for the network specified in the Spec
876876
for _, reservation := range ipset.Status.Reservation {
877-
if reservation.Network == instance.Spec.MonitoringStack.DataplaneNetwork {
877+
if reservation.Network == instance.Spec.DataplaneNetwork {
878878
return reservation.Address, discoveryv1.AddressTypeIPv4
879879
}
880880
}

controllers/telemetry_controller.go

+4
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,14 @@ func (r TelemetryReconciler) reconcileMetricStorage(ctx context.Context, instanc
409409
if instance.Spec.MetricStorage.MetricStorageSpec.CustomMonitoringStack != nil {
410410
metricStorageInstance.Spec.CustomMonitoringStack = &obov1.MonitoringStackSpec{}
411411
instance.Spec.MetricStorage.MetricStorageSpec.CustomMonitoringStack.DeepCopyInto(metricStorageInstance.Spec.CustomMonitoringStack)
412+
} else {
413+
metricStorageInstance.Spec.CustomMonitoringStack = nil
412414
}
413415
if instance.Spec.MetricStorage.MetricStorageSpec.MonitoringStack != nil {
414416
metricStorageInstance.Spec.MonitoringStack = &telemetryv1.MonitoringStack{}
415417
instance.Spec.MetricStorage.MetricStorageSpec.MonitoringStack.DeepCopyInto(metricStorageInstance.Spec.MonitoringStack)
418+
} else {
419+
metricStorageInstance.Spec.MonitoringStack = nil
416420
}
417421
instance.Spec.MetricStorage.MetricStorageSpec.PrometheusTLS.DeepCopyInto(&metricStorageInstance.Spec.PrometheusTLS)
418422
// TODO: Uncomment this line when implementing TLS for Alertmanager

tests/kuttl/suites/metricstorage/tests/01-deploy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ kind: MetricStorage
33
metadata:
44
name: telemetry-kuttl
55
spec:
6+
dashboardsEnabled: true
67
monitoringStack:
78
alertingEnabled: true
8-
dashboardsEnabled: true
99
scrapeInterval: 30s
1010
storage:
1111
strategy: persistent

tests/kuttl/suites/metricstorage/tests/02-disable-dashboards.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ kind: MetricStorage
33
metadata:
44
name: telemetry-kuttl
55
spec:
6+
dashboardsEnabled: false
67
monitoringStack:
78
alertingEnabled: true
8-
dashboardsEnabled: false
99
scrapeInterval: 30s
1010
storage:
1111
strategy: persistent
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Kuttl test doesn't seem to wait correctly for the metric
2+
# storage to reconcile in the next test step when switching
3+
# to CustomMonitoringStack (in the output of the test I
4+
# can see it applyes the resource and fails a second later).
5+
# Deleting it here and than recreating it in the next step
6+
# should ensure kuttl waits long enough.
7+
apiVersion: kuttl.dev/v1beta1
8+
kind: TestStep
9+
delete:
10+
- apiVersion: telemetry.openstack.org/v1beta1
11+
kind: MetricStorage
12+
name: telemetry-kuttl

0 commit comments

Comments
 (0)