Skip to content

Commit d03dd0d

Browse files
Merge pull request #468 from vyzigold/ephemeral
[OSPRH-9252] Support for ephemeral metric storage
2 parents e372e50 + 57b1682 commit d03dd0d

8 files changed

+32
-17
lines changed

api/bases/telemetry.openstack.org_metricstorages.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1169,10 +1169,11 @@ spec:
11691169
type: string
11701170
strategy:
11711171
default: persistent
1172-
description: Strategy to use for storage. Can be "persistent"
1173-
or empty, in which case a COO default is used
1172+
description: Strategy to use for storage. Can be "persistent",
1173+
"ephemeral" or empty, in which case a COO default is used
11741174
enum:
11751175
- persistent
1176+
- ephemeral
11761177
type: string
11771178
type: object
11781179
type: object

api/bases/telemetry.openstack.org_telemetries.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1728,10 +1728,12 @@ spec:
17281728
type: string
17291729
strategy:
17301730
default: persistent
1731-
description: Strategy to use for storage. Can be "persistent"
1732-
or empty, in which case a COO default is used
1731+
description: Strategy to use for storage. Can be "persistent",
1732+
"ephemeral" or empty, in which case a COO default is
1733+
used
17331734
enum:
17341735
- persistent
1736+
- ephemeral
17351737
type: string
17361738
type: object
17371739
type: object

api/v1beta1/metricstorage_types.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ type PersistentStorage struct {
4242

4343
// Storage defines the options used for storage of metrics
4444
type Storage struct {
45-
// Strategy to use for storage. Can be "persistent"
45+
// Strategy to use for storage. Can be "persistent", "ephemeral"
4646
// or empty, in which case a COO default is used
4747
// +kubebuilder:validation:Optional
48-
// +kubebuilder:validation:Enum=persistent
48+
// +kubebuilder:validation:Enum=persistent;ephemeral
4949
// +kubebuilder:default=persistent
5050
Strategy string `json:"strategy"`
5151

@@ -57,7 +57,7 @@ type Storage struct {
5757
// Used to specify the options of persistent storage when
5858
// strategy = "persistent"
5959
// +kubebuilder:validation:Optional
60-
Persistent PersistentStorage `json:"persistent"`
60+
Persistent *PersistentStorage `json:"persistent,omitempty"`
6161
}
6262

6363
// MonitoringStack defines the options for a Red Hat supported metric storage

api/v1beta1/metricstorage_webhook.go

+3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ func (storage *Storage) Default() {
8181
storage.Retention = "24h"
8282
}
8383
if storage.Strategy == "persistent" {
84+
storage.Persistent = &PersistentStorage{}
8485
storage.Persistent.Default()
86+
} else {
87+
storage.Persistent = nil
8588
}
8689
}
8790

api/v1beta1/zz_generated.deepcopy.go

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1169,10 +1169,11 @@ spec:
11691169
type: string
11701170
strategy:
11711171
default: persistent
1172-
description: Strategy to use for storage. Can be "persistent"
1173-
or empty, in which case a COO default is used
1172+
description: Strategy to use for storage. Can be "persistent",
1173+
"ephemeral" or empty, in which case a COO default is used
11741174
enum:
11751175
- persistent
1176+
- ephemeral
11761177
type: string
11771178
type: object
11781179
type: object

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -1728,10 +1728,12 @@ spec:
17281728
type: string
17291729
strategy:
17301730
default: persistent
1731-
description: Strategy to use for storage. Can be "persistent"
1732-
or empty, in which case a COO default is used
1731+
description: Strategy to use for storage. Can be "persistent",
1732+
"ephemeral" or empty, in which case a COO default is
1733+
used
17331734
enum:
17341735
- persistent
1736+
- ephemeral
17351737
type: string
17361738
type: object
17371739
type: object

pkg/metricstorage/monitoring_stack.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func MonitoringStack(
4040
if err != nil {
4141
return nil, err
4242
}
43+
scrapeInterval := monv1.Duration(instance.Spec.MonitoringStack.ScrapeInterval)
4344
monitoringStack := &obov1.MonitoringStack{
4445
ObjectMeta: metav1.ObjectMeta{
4546
Name: instance.Name,
@@ -51,10 +52,8 @@ func MonitoringStack(
5152
Disabled: !instance.Spec.MonitoringStack.AlertingEnabled,
5253
},
5354
PrometheusConfig: &obov1.PrometheusConfig{
54-
Replicas: &telemetryv1.PrometheusReplicas,
55-
// NOTE: unsupported before OBOv0.0.21, but we can set the value
56-
// in the ServiceMonitor, so this isn't a big deal.
57-
//ScrapeInterval: instance.Spec.MonitoringStack.ScrapeInterval,
55+
Replicas: &telemetryv1.PrometheusReplicas,
56+
ScrapeInterval: &scrapeInterval,
5857
PersistentVolumeClaim: pvc,
5958
},
6059
Retention: monv1.Duration(instance.Spec.MonitoringStack.Storage.Retention),
@@ -68,7 +67,10 @@ func MonitoringStack(
6867

6968
func getPVCSpec(instance *telemetryv1.MetricStorage) (*corev1.PersistentVolumeClaimSpec, error) {
7069
if instance.Spec.MonitoringStack.Storage.Strategy == "persistent" {
71-
persistentSpec := &instance.Spec.MonitoringStack.Storage.Persistent
70+
persistentSpec := instance.Spec.MonitoringStack.Storage.Persistent
71+
if persistentSpec == nil {
72+
return nil, fmt.Errorf("Received a nil value in persistent storage config")
73+
}
7274
pvc := corev1.PersistentVolumeClaimSpec{}
7375
if !reflect.DeepEqual(persistentSpec.PvcStorageSelector, metav1.LabelSelector{}) {
7476
pvc.Selector = &persistentSpec.PvcStorageSelector

0 commit comments

Comments
 (0)