Skip to content

Commit 84263c2

Browse files
committed
Add TelemetrySpecCore struct
This version of the struct (called "core") is meant to be used via the OpenStackControlplane. It is the same as TelemetrySpec only it is missing the containerImages. The Default() function for webhooks has been split accordingly. Also removes AodhInitContainerImageURL which is unused. Jira: OSPRH-4835
1 parent 444ba30 commit 84263c2

File tree

5 files changed

+249
-48
lines changed

5 files changed

+249
-48
lines changed

Diff for: api/v1beta1/autoscaling_types.go

+34-17
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222

23-
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
2423
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
24+
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
2525
)
2626

2727
const (
@@ -37,9 +37,25 @@ const (
3737
DbSyncHash = "dbsync"
3838
)
3939

40-
4140
// Aodh defines the aodh component spec
4241
type Aodh struct {
42+
AodhCore `json:",inline"`
43+
44+
// +kubebuilder:validation:Required
45+
APIImage string `json:"apiImage"`
46+
47+
// +kubebuilder:validation:Required
48+
EvaluatorImage string `json:"evaluatorImage"`
49+
50+
// +kubebuilder:validation:Required
51+
NotifierImage string `json:"notifierImage"`
52+
53+
// +kubebuilder:validation:Required
54+
ListenerImage string `json:"listenerImage"`
55+
}
56+
57+
// Aodh defines the aodh component spec
58+
type AodhCore struct {
4359
// RabbitMQ instance name
4460
// Needed to request a transportURL that is created and used in Aodh
4561
// +kubebuilder:default=rabbitmq
@@ -97,18 +113,6 @@ type Aodh struct {
97113
// +kubebuilder:default=memcached
98114
// Memcached instance name.
99115
MemcachedInstance string `json:"memcachedInstance"`
100-
101-
// +kubebuilder:validation:Required
102-
APIImage string `json:"apiImage"`
103-
104-
// +kubebuilder:validation:Required
105-
EvaluatorImage string `json:"evaluatorImage"`
106-
107-
// +kubebuilder:validation:Required
108-
NotifierImage string `json:"notifierImage"`
109-
110-
// +kubebuilder:validation:Required
111-
ListenerImage string `json:"listenerImage"`
112116
}
113117

114118
// APIOverrideSpec to override the generated manifest of several child resources.
@@ -119,6 +123,22 @@ type APIOverrideSpec struct {
119123

120124
// AutoscalingSpec defines the desired state of Autoscaling
121125
type AutoscalingSpec struct {
126+
AutoscalingSpecBase `json:",inline"`
127+
128+
// Aodh spec
129+
Aodh Aodh `json:"aodh,omitempty"`
130+
}
131+
132+
// AutoscalingSpecCore defines the desired state of Autoscaling (this version is used by the OpenStackControlplane no image parameters)
133+
type AutoscalingSpecCore struct {
134+
AutoscalingSpecBase `json:",inline"`
135+
136+
// Aodh spec
137+
Aodh AodhCore `json:"aodh,omitempty"`
138+
}
139+
140+
// AutoscalingSpecBase -
141+
type AutoscalingSpecBase struct {
122142
// Host of user deployed prometheus
123143
// +kubebuilder:validation:Optional
124144
PrometheusHost string `json:"prometheusHost,omitempty"`
@@ -129,9 +149,6 @@ type AutoscalingSpec struct {
129149
// +kubebuilder:validation:Optional
130150
PrometheusPort int32 `json:"prometheusPort,omitempty"`
131151

132-
// Aodh spec
133-
Aodh Aodh `json:"aodh,omitempty"`
134-
135152
// Heat instance name.
136153
// +kubebuilder:default=heat
137154
HeatInstance string `json:"heatInstance"`

Diff for: api/v1beta1/ceilometer_types.go

+20-15
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,26 @@ const (
3838

3939
// CeilometerSpec defines the desired state of Ceilometer
4040
type CeilometerSpec struct {
41+
CeilometerSpecCore `json:",inline"`
42+
43+
// +kubebuilder:validation:Required
44+
CentralImage string `json:"centralImage"`
45+
46+
// +kubebuilder:validation:Required
47+
NotificationImage string `json:"notificationImage"`
48+
49+
// +kubebuilder:validation:Required
50+
SgCoreImage string `json:"sgCoreImage"`
51+
52+
// +kubebuilder:validation:Required
53+
ComputeImage string `json:"computeImage"`
54+
55+
// +kubebuilder:validation:Required
56+
IpmiImage string `json:"ipmiImage"`
57+
}
58+
59+
// CeilometerSpecCore defines the desired state of Ceilometer. This version is used by the OpenStackControlplane (no image parameters)
60+
type CeilometerSpecCore struct {
4161
// RabbitMQ instance name
4262
// Needed to request a transportURL that is created and used in Telemetry
4363
// +kubebuilder:default=rabbitmq
@@ -69,21 +89,6 @@ type CeilometerSpec struct {
6989

7090
// NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to
7191
NetworkAttachmentDefinitions []string `json:"networkAttachmentDefinitions,omitempty"`
72-
73-
// +kubebuilder:validation:Required
74-
CentralImage string `json:"centralImage"`
75-
76-
// +kubebuilder:validation:Required
77-
NotificationImage string `json:"notificationImage"`
78-
79-
// +kubebuilder:validation:Required
80-
SgCoreImage string `json:"sgCoreImage"`
81-
82-
// +kubebuilder:validation:Required
83-
ComputeImage string `json:"computeImage"`
84-
85-
// +kubebuilder:validation:Required
86-
IpmiImage string `json:"ipmiImage"`
8792
}
8893

8994
// CeilometerStatus defines the observed state of Ceilometer

Diff for: api/v1beta1/telemetry_types.go

+51-7
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,32 @@ type PasswordsSelector struct {
4545

4646
// TelemetrySpec defines the desired state of Telemetry
4747
type TelemetrySpec struct {
48+
TelemetrySpecBase `json:",inline"`
49+
4850
// +kubebuilder:validation:Optional
4951
// Autoscaling - Parameters related to the autoscaling service
5052
Autoscaling AutoscalingSection `json:"autoscaling,omitempty"`
5153

5254
// +kubebuilder:validation:Optional
5355
// Ceilometer - Parameters related to the ceilometer service
5456
Ceilometer CeilometerSection `json:"ceilometer,omitempty"`
57+
}
58+
59+
// TelemetrySpecCore defines the desired state of Telemetry. This version has no image parameters and is used by OpenStackControlplane
60+
type TelemetrySpecCore struct {
61+
TelemetrySpecBase `json:",inline"`
5562

63+
// +kubebuilder:validation:Optional
64+
// Autoscaling - Parameters related to the autoscaling service
65+
Autoscaling AutoscalingSectionCore `json:"autoscaling,omitempty"`
66+
67+
// +kubebuilder:validation:Optional
68+
// Ceilometer - Parameters related to the ceilometer service
69+
Ceilometer CeilometerSectionCore `json:"ceilometer,omitempty"`
70+
}
71+
72+
// TelemetrySpecBase -
73+
type TelemetrySpecBase struct {
5674
// +kubebuilder:validation:Optional
5775
// MetricStorage - Parameters related to the metricStorage
5876
MetricStorage MetricStorageSection `json:"metricStorage,omitempty"`
@@ -76,6 +94,20 @@ type CeilometerSection struct {
7694
CeilometerSpec `json:",inline"`
7795
}
7896

97+
// CeilometerSectionCore defines the desired state of the ceilometer service
98+
type CeilometerSectionCore struct {
99+
// +kubebuilder:validation:Optional
100+
// +kubebuilder:default=true
101+
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
102+
// Enabled - Whether OpenStack Ceilometer service should be deployed and managed
103+
Enabled bool `json:"enabled"`
104+
105+
// +kubebuilder:validation:Optional
106+
//+operator-sdk:csv:customresourcedefinitions:type=spec
107+
// Template - Overrides to use when creating the OpenStack Ceilometer service
108+
CeilometerSpecCore `json:",inline"`
109+
}
110+
79111
// AutoscalingSection defines the desired state of the autoscaling service
80112
type AutoscalingSection struct {
81113
// +kubebuilder:validation:Optional
@@ -90,6 +122,20 @@ type AutoscalingSection struct {
90122
AutoscalingSpec `json:",inline"`
91123
}
92124

125+
// AutoscalingSectionCore defines the desired state of the autoscaling service
126+
type AutoscalingSectionCore struct {
127+
// +kubebuilder:validation:Optional
128+
// +kubebuilder:default=false
129+
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
130+
// Enabled - Whether OpenStack autoscaling service should be deployed and managed
131+
Enabled bool `json:"enabled"`
132+
133+
// +kubebuilder:validation:Optional
134+
//+operator-sdk:csv:customresourcedefinitions:type=spec
135+
// Template - Overrides to use when creating the OpenStack autoscaling service
136+
AutoscalingSpecCore `json:",inline"`
137+
}
138+
93139
// MetricStorageSection defines the desired state of the MetricStorage
94140
type MetricStorageSection struct {
95141
// +kubebuilder:validation:Optional
@@ -161,19 +207,17 @@ func init() {
161207
func SetupDefaultsTelemetry() {
162208
// Acquire environmental defaults and initialize Telemetry defaults with them
163209
telemetryDefaults := TelemetryDefaults{
164-
CentralContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_CENTRAL_IMAGE_URL_DEFAULT", CeilometerCentralContainerImage),
165-
ComputeContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_COMPUTE_IMAGE_URL_DEFAULT", CeilometerComputeContainerImage),
166-
IpmiContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_IPMI_IMAGE_URL_DEFAULT", CeilometerIpmiContainerImage),
167-
NotificationContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_NOTIFICATION_IMAGE_URL_DEFAULT", CeilometerNotificationContainerImage),
168-
SgCoreContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_SGCORE_IMAGE_URL_DEFAULT", CeilometerSgCoreContainerImage),
210+
CentralContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_CENTRAL_IMAGE_URL_DEFAULT", CeilometerCentralContainerImage),
211+
ComputeContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_COMPUTE_IMAGE_URL_DEFAULT", CeilometerComputeContainerImage),
212+
IpmiContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_IPMI_IMAGE_URL_DEFAULT", CeilometerIpmiContainerImage),
213+
NotificationContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_NOTIFICATION_IMAGE_URL_DEFAULT", CeilometerNotificationContainerImage),
214+
SgCoreContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_SGCORE_IMAGE_URL_DEFAULT", CeilometerSgCoreContainerImage),
169215

170216
// Autoscaling
171217
AodhAPIContainerImageURL: util.GetEnvVar("RELATED_IMAGE_AODH_API_IMAGE_URL_DEFAULT", AodhAPIContainerImage),
172218
AodhEvaluatorContainerImageURL: util.GetEnvVar("RELATED_IMAGE_AODH_EVALUATOR_IMAGE_URL_DEFAULT", AodhEvaluatorContainerImage),
173219
AodhNotifierContainerImageURL: util.GetEnvVar("RELATED_IMAGE_AODH_NOTIFIER_IMAGE_URL_DEFAULT", AodhNotifierContainerImage),
174220
AodhListenerContainerImageURL: util.GetEnvVar("RELATED_IMAGE_AODH_LISTENER_IMAGE_URL_DEFAULT", AodhListenerContainerImage),
175-
AodhInitContainerImageURL: util.GetEnvVar("RELATED_IMAGE_AODH_API_IMAGE_URL_DEFAULT", AodhAPIContainerImage),
176-
177221
}
178222

179223
SetupTelemetryDefaults(telemetryDefaults)

Diff for: api/v1beta1/telemetry_webhook.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type TelemetryDefaults struct {
3838
AodhEvaluatorContainerImageURL string
3939
AodhNotifierContainerImageURL string
4040
AodhListenerContainerImageURL string
41-
AodhInitContainerImageURL string
4241
}
4342

4443
var telemetryDefaults TelemetryDefaults
@@ -101,6 +100,11 @@ func (spec *TelemetrySpec) Default() {
101100
}
102101
}
103102

103+
// Default - set defaults for this Telemetry spec core
104+
func (spec *TelemetrySpecCore) Default() {
105+
// nothing here yet
106+
}
107+
104108
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
105109
//+kubebuilder:webhook:path=/validate-telemetry-openstack-org-v1beta1-telemetry,mutating=false,failurePolicy=fail,sideEffects=None,groups=telemetry.openstack.org,resources=telemetries,verbs=create;update,versions=v1beta1,name=vtelemetry.kb.io,admissionReviewVersions=v1
106110

0 commit comments

Comments
 (0)