Skip to content

Commit 4226f74

Browse files
committed
Fix
Signed-off-by: Pavol Loffay <[email protected]>
1 parent a31ed72 commit 4226f74

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

apis/v1beta1/collector_webhook.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,13 @@ func (c CollectorWebhook) validateTargetAllocatorConfig(ctx context.Context, r *
330330
return nil, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the target allocation deployment", r.Spec.Mode)
331331
}
332332

333-
// TODO ask Mikolaj https://github.com/open-telemetry/opentelemetry-operator/issues/2860
334-
//if r.Spec.Mode == ModeDaemonSet && r.Spec.TargetAllocator.AllocationStrategy != TargetAllocatorAllocationStrategyPerNode {
335-
// return nil, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which must be used with target allocation strategy %s ", r.Spec.Mode, OpenTelemetryTargetAllocatorAllocationStrategyPerNode)
336-
//}
337-
338-
//// TODO ask Mikolaj https://github.com/open-telemetry/opentelemetry-operator/issues/2860
339-
//if r.Spec.TargetAllocator.AllocationStrategy == OpenTelemetryTargetAllocatorAllocationStrategyPerNode && r.Spec.Mode != ModeDaemonSet {
340-
// return nil, fmt.Errorf("target allocation strategy %s is only supported in OpenTelemetry Collector mode %s", OpenTelemetryTargetAllocatorAllocationStrategyPerNode, ModeDaemonSet)
341-
//}
333+
if r.Spec.Mode == ModeDaemonSet && r.Spec.TargetAllocator.AllocationStrategy != TargetAllocatorAllocationStrategyPerNode {
334+
return nil, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which must be used with target allocation strategy %s ", r.Spec.Mode, TargetAllocatorAllocationStrategyPerNode)
335+
}
336+
337+
if r.Spec.TargetAllocator.AllocationStrategy == TargetAllocatorAllocationStrategyPerNode && r.Spec.Mode != ModeDaemonSet {
338+
return nil, fmt.Errorf("target allocation strategy %s is only supported in OpenTelemetry Collector mode %s", TargetAllocatorAllocationStrategyPerNode, ModeDaemonSet)
339+
}
342340

343341
cfgYaml, err := r.Spec.Config.Yaml()
344342
if err != nil {

apis/v1beta1/collector_webhook_test.go

+13-17
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,6 @@ var cfgYaml = `receivers:
482482
endpoint: 0.0.0.0:15268
483483
`
484484

485-
// TODO: a lot of these tests use .Spec.MaxReplicas and .Spec.MinReplicas. These fields are
486-
// deprecated and moved to .Spec.Autoscaler. Fine to use these fields to test that old CRD is
487-
// still supported but should eventually be updated.
488485
func TestOTELColValidatingWebhook(t *testing.T) {
489486
minusOne := int32(-1)
490487
zero := int32(0)
@@ -704,20 +701,19 @@ func TestOTELColValidatingWebhook(t *testing.T) {
704701
},
705702
expectedErr: "the OpenTelemetry Spec Prometheus configuration is incorrect",
706703
},
707-
// TODO https://github.com/open-telemetry/opentelemetry-operator/issues/2860
708-
//{
709-
// name: "invalid target allocation strategy",
710-
// otelcol: OpenTelemetryCollector{
711-
// Spec: OpenTelemetryCollectorSpec{
712-
// Mode: ModeDaemonSet,
713-
// TargetAllocator: TargetAllocatorEmbedded{
714-
// Enabled: true,
715-
// AllocationStrategy: TargetAllocatorAllocationStrategyLeastWeighted,
716-
// },
717-
// },
718-
// },
719-
// expectedErr: "mode is set to daemonset, which must be used with target allocation strategy per-node",
720-
//},
704+
{
705+
name: "invalid target allocation strategy",
706+
otelcol: OpenTelemetryCollector{
707+
Spec: OpenTelemetryCollectorSpec{
708+
Mode: ModeDaemonSet,
709+
TargetAllocator: TargetAllocatorEmbedded{
710+
Enabled: true,
711+
AllocationStrategy: TargetAllocatorAllocationStrategyLeastWeighted,
712+
},
713+
},
714+
},
715+
expectedErr: "mode is set to daemonset, which must be used with target allocation strategy per-node",
716+
},
721717
{
722718
name: "invalid port name",
723719
otelcol: OpenTelemetryCollector{

0 commit comments

Comments
 (0)