Skip to content

Commit 1bdfeb2

Browse files
authored
Merge branch 'main' into fix-inst
2 parents 5030c8c + 1432f77 commit 1bdfeb2

File tree

21 files changed

+931
-234
lines changed

21 files changed

+931
-234
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: breaking
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
5+
component: operator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: change dotnet instrumentation feature gate into command line flag --enable-dotnet-instrumentation
9+
10+
# One or more tracking issues related to the change
11+
issues: [2582, 2671]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

apis/v1alpha1/convert.go

+181-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func Tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error
3535
StatusReplicas: in.Status.Scale.StatusReplicas,
3636
},
3737
Version: in.Status.Version,
38-
Image: in.Spec.Image,
38+
Image: in.Status.Image,
3939
},
4040
}
4141

@@ -108,7 +108,7 @@ func Tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error
108108
out.Spec.OpenTelemetryCommonFields.InitContainers = copy.Spec.InitContainers
109109
out.Spec.OpenTelemetryCommonFields.AdditionalContainers = copy.Spec.AdditionalContainers
110110

111-
out.Spec.TargetAllocator = TargetAllocatorEmbedded(copy.Spec.TargetAllocator)
111+
out.Spec.TargetAllocator = tov1beta1TA(copy.Spec.TargetAllocator)
112112

113113
out.Spec.Mode = v1beta1.Mode(copy.Spec.Mode)
114114
out.Spec.UpgradeStrategy = v1beta1.UpgradeStrategy(copy.Spec.UpgradeStrategy)
@@ -132,6 +132,7 @@ func Tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error
132132
}
133133

134134
out.Spec.Observability.Metrics.EnableMetrics = copy.Spec.Observability.Metrics.EnableMetrics
135+
out.Spec.Observability.Metrics.DisablePrometheusAnnotations = copy.Spec.Observability.Metrics.DisablePrometheusAnnotations
135136

136137
for _, cm := range copy.Spec.ConfigMaps {
137138
out.Spec.ConfigMaps = append(out.Spec.ConfigMaps, v1beta1.ConfigMapsSpec{
@@ -146,7 +147,7 @@ func Tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error
146147
return out, nil
147148
}
148149

149-
func TargetAllocatorEmbedded(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedded {
150+
func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedded {
150151
out := v1beta1.TargetAllocatorEmbedded{}
151152
out.Replicas = in.Replicas
152153
out.NodeSelector = in.NodeSelector
@@ -184,3 +185,180 @@ func TargetAllocatorEmbedded(in OpenTelemetryTargetAllocator) v1beta1.TargetAllo
184185
}
185186
return out
186187
}
188+
189+
func tov1alpha1(in v1beta1.OpenTelemetryCollector) (*OpenTelemetryCollector, error) {
190+
copy := in.DeepCopy()
191+
configYaml, err := in.Spec.Config.Yaml()
192+
if err != nil {
193+
return nil, err
194+
}
195+
196+
return &OpenTelemetryCollector{
197+
ObjectMeta: copy.ObjectMeta,
198+
Status: OpenTelemetryCollectorStatus{
199+
Scale: ScaleSubresourceStatus{
200+
Selector: in.Status.Scale.Selector,
201+
Replicas: in.Status.Scale.Replicas,
202+
StatusReplicas: in.Status.Scale.StatusReplicas,
203+
},
204+
Version: in.Status.Version,
205+
Image: in.Status.Image,
206+
},
207+
208+
Spec: OpenTelemetryCollectorSpec{
209+
ManagementState: ManagementStateType(copy.Spec.ManagementState),
210+
Resources: copy.Spec.Resources,
211+
NodeSelector: copy.Spec.NodeSelector,
212+
Args: copy.Spec.Args,
213+
Replicas: copy.Spec.Replicas,
214+
Autoscaler: tov1alpha1Autoscaler(copy.Spec.Autoscaler),
215+
PodDisruptionBudget: tov1alpha1PodDisruptionBudget(copy.Spec.PodDisruptionBudget),
216+
SecurityContext: copy.Spec.SecurityContext,
217+
PodSecurityContext: copy.Spec.PodSecurityContext,
218+
PodAnnotations: copy.Spec.PodAnnotations,
219+
TargetAllocator: tov1alpha1TA(in.Spec.TargetAllocator),
220+
Mode: Mode(copy.Spec.Mode),
221+
ServiceAccount: copy.Spec.ServiceAccount,
222+
Image: copy.Spec.Image,
223+
UpgradeStrategy: UpgradeStrategy(copy.Spec.UpgradeStrategy),
224+
ImagePullPolicy: copy.Spec.ImagePullPolicy,
225+
Config: configYaml,
226+
VolumeMounts: copy.Spec.VolumeMounts,
227+
Ports: copy.Spec.Ports,
228+
Env: copy.Spec.Env,
229+
EnvFrom: copy.Spec.EnvFrom,
230+
VolumeClaimTemplates: copy.Spec.VolumeClaimTemplates,
231+
Tolerations: copy.Spec.Tolerations,
232+
Volumes: copy.Spec.Volumes,
233+
Ingress: Ingress{
234+
Type: IngressType(copy.Spec.Ingress.Type),
235+
RuleType: IngressRuleType(copy.Spec.Ingress.RuleType),
236+
Hostname: copy.Spec.Ingress.Hostname,
237+
Annotations: copy.Spec.Ingress.Annotations,
238+
TLS: copy.Spec.Ingress.TLS,
239+
IngressClassName: copy.Spec.Ingress.IngressClassName,
240+
Route: OpenShiftRoute{
241+
Termination: TLSRouteTerminationType(copy.Spec.Ingress.Route.Termination),
242+
},
243+
},
244+
HostNetwork: copy.Spec.HostNetwork,
245+
ShareProcessNamespace: copy.Spec.ShareProcessNamespace,
246+
PriorityClassName: copy.Spec.PriorityClassName,
247+
Affinity: copy.Spec.Affinity,
248+
Lifecycle: copy.Spec.Lifecycle,
249+
TerminationGracePeriodSeconds: copy.Spec.TerminationGracePeriodSeconds,
250+
LivenessProbe: tov1alpha1Probe(copy.Spec.LivenessProbe),
251+
InitContainers: copy.Spec.InitContainers,
252+
AdditionalContainers: copy.Spec.AdditionalContainers,
253+
Observability: ObservabilitySpec{
254+
Metrics: MetricsConfigSpec{
255+
EnableMetrics: copy.Spec.Observability.Metrics.EnableMetrics,
256+
DisablePrometheusAnnotations: copy.Spec.Observability.Metrics.DisablePrometheusAnnotations,
257+
},
258+
},
259+
TopologySpreadConstraints: copy.Spec.TopologySpreadConstraints,
260+
ConfigMaps: tov1alpha1ConfigMaps(copy.Spec.ConfigMaps),
261+
UpdateStrategy: copy.Spec.DaemonSetUpdateStrategy,
262+
DeploymentUpdateStrategy: copy.Spec.DeploymentUpdateStrategy,
263+
},
264+
}, nil
265+
}
266+
267+
func tov1alpha1PodDisruptionBudget(in *v1beta1.PodDisruptionBudgetSpec) *PodDisruptionBudgetSpec {
268+
if in == nil {
269+
return nil
270+
}
271+
return &PodDisruptionBudgetSpec{
272+
MinAvailable: in.MinAvailable,
273+
MaxUnavailable: in.MaxUnavailable,
274+
}
275+
}
276+
277+
func tov1alpha1Probe(in *v1beta1.Probe) *Probe {
278+
if in == nil {
279+
return nil
280+
}
281+
return &Probe{
282+
InitialDelaySeconds: in.InitialDelaySeconds,
283+
TimeoutSeconds: in.TimeoutSeconds,
284+
PeriodSeconds: in.PeriodSeconds,
285+
SuccessThreshold: in.SuccessThreshold,
286+
FailureThreshold: in.FailureThreshold,
287+
TerminationGracePeriodSeconds: in.TerminationGracePeriodSeconds,
288+
}
289+
}
290+
291+
func tov1alpha1Autoscaler(in *v1beta1.AutoscalerSpec) *AutoscalerSpec {
292+
if in == nil {
293+
return nil
294+
}
295+
296+
var metrics []MetricSpec
297+
for _, m := range in.Metrics {
298+
metrics = append(metrics, MetricSpec{
299+
Type: m.Type,
300+
Pods: m.Pods,
301+
})
302+
}
303+
304+
return &AutoscalerSpec{
305+
MinReplicas: in.MinReplicas,
306+
MaxReplicas: in.MaxReplicas,
307+
Behavior: in.Behavior,
308+
Metrics: metrics,
309+
TargetCPUUtilization: in.TargetCPUUtilization,
310+
TargetMemoryUtilization: in.TargetMemoryUtilization,
311+
}
312+
}
313+
314+
func tov1alpha1ConfigMaps(in []v1beta1.ConfigMapsSpec) []ConfigMapsSpec {
315+
var mapsSpecs []ConfigMapsSpec
316+
for _, m := range in {
317+
mapsSpecs = append(mapsSpecs, ConfigMapsSpec{
318+
Name: m.Name,
319+
MountPath: m.MountPath,
320+
})
321+
}
322+
return mapsSpecs
323+
}
324+
325+
func tov1alpha1TA(in v1beta1.TargetAllocatorEmbedded) OpenTelemetryTargetAllocator {
326+
var podMonitorSelector map[string]string
327+
if in.PrometheusCR.PodMonitorSelector != nil {
328+
podMonitorSelector = in.PrometheusCR.PodMonitorSelector.MatchLabels
329+
}
330+
var serviceMonitorSelector map[string]string
331+
if in.PrometheusCR.ServiceMonitorSelector != nil {
332+
serviceMonitorSelector = in.PrometheusCR.ServiceMonitorSelector.MatchLabels
333+
}
334+
335+
return OpenTelemetryTargetAllocator{
336+
Replicas: in.Replicas,
337+
NodeSelector: in.NodeSelector,
338+
Resources: in.Resources,
339+
AllocationStrategy: OpenTelemetryTargetAllocatorAllocationStrategy(in.AllocationStrategy),
340+
FilterStrategy: string(in.FilterStrategy),
341+
ServiceAccount: in.ServiceAccount,
342+
Image: in.Image,
343+
Enabled: in.Enabled,
344+
Affinity: in.Affinity,
345+
PrometheusCR: OpenTelemetryTargetAllocatorPrometheusCR{
346+
Enabled: in.PrometheusCR.Enabled,
347+
ScrapeInterval: in.PrometheusCR.ScrapeInterval,
348+
PodMonitorSelector: podMonitorSelector,
349+
ServiceMonitorSelector: serviceMonitorSelector,
350+
},
351+
SecurityContext: in.SecurityContext,
352+
PodSecurityContext: in.PodSecurityContext,
353+
TopologySpreadConstraints: in.TopologySpreadConstraints,
354+
Tolerations: in.Tolerations,
355+
Env: in.Env,
356+
Observability: ObservabilitySpec{
357+
Metrics: MetricsConfigSpec{
358+
EnableMetrics: in.Observability.Metrics.EnableMetrics,
359+
DisablePrometheusAnnotations: in.Observability.Metrics.DisablePrometheusAnnotations,
360+
},
361+
},
362+
PodDisruptionBudget: tov1alpha1PodDisruptionBudget(in.PodDisruptionBudget),
363+
}
364+
}

0 commit comments

Comments
 (0)