Skip to content

Commit 1cb601b

Browse files
committed
fix tests
1 parent 913d8f6 commit 1cb601b

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

apis/v1beta1/config.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ func (c *Config) getRbacRulesForComponentKinds(logger logr.Logger, componentKind
168168
} else {
169169
cfg = *c.Processors
170170
}
171+
case KindExtension:
172+
continue
171173
}
172174
for componentName := range enabledComponents[componentKind] {
173175
// TODO: Clean up the naming here and make it simpler to use a retriever.
@@ -197,7 +199,9 @@ func (c *Config) getPortsForComponentKinds(logger logr.Logger, componentKinds ..
197199
retriever = exporters.ParserFor
198200
cfg = c.Exporters
199201
case KindProcessor:
200-
break
202+
continue
203+
case KindExtension:
204+
continue
201205
}
202206
for componentName := range enabledComponents[componentKind] {
203207
// TODO: Clean up the naming here and make it simpler to use a retriever.

apis/v1beta1/config_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ func TestConfig_GetEnabledComponents(t *testing.T) {
304304
"bar": struct{}{},
305305
"count": struct{}{},
306306
},
307+
KindExtension: {},
307308
},
308309
},
309310
{
@@ -321,6 +322,7 @@ func TestConfig_GetEnabledComponents(t *testing.T) {
321322
KindExporter: {
322323
"prometheus": struct{}{},
323324
},
325+
KindExtension: {},
324326
},
325327
},
326328
{
@@ -339,6 +341,11 @@ func TestConfig_GetEnabledComponents(t *testing.T) {
339341
"otlp": struct{}{},
340342
"prometheus": struct{}{},
341343
},
344+
KindExtension: {
345+
"health_check": struct{}{},
346+
"pprof": struct{}{},
347+
"zpages": struct{}{},
348+
},
342349
},
343350
},
344351
{
@@ -352,6 +359,9 @@ func TestConfig_GetEnabledComponents(t *testing.T) {
352359
KindExporter: {
353360
"otlp/auth": struct{}{},
354361
},
362+
KindExtension: {
363+
"oauth2client": struct{}{},
364+
},
355365
},
356366
},
357367
{
@@ -365,6 +375,7 @@ func TestConfig_GetEnabledComponents(t *testing.T) {
365375
KindExporter: {
366376
"debug": struct{}{},
367377
},
378+
KindExtension: {},
368379
},
369380
},
370381
{
@@ -374,6 +385,7 @@ func TestConfig_GetEnabledComponents(t *testing.T) {
374385
KindReceiver: {},
375386
KindProcessor: {},
376387
KindExporter: {},
388+
KindExtension: {},
377389
},
378390
},
379391
}

internal/components/extensions/healthcheckv1.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import (
2222
"github.com/open-telemetry/opentelemetry-operator/internal/components"
2323
)
2424

25-
const DefaultHealthcheckV1Port = 13133
25+
const (
26+
DefaultHealthcheckV1Path = "/"
27+
DefaultHealthcheckV1Port = 13133
28+
)
2629

2730
type healthcheckV1Config struct {
2831
components.SingleEndpointConfig `mapstructure:",squash"`
@@ -32,10 +35,14 @@ type healthcheckV1Config struct {
3235
// HealthCheckV1Probe returns the probe configuration for the healthcheck v1 extension.
3336
// Right now no TLS config is parsed.
3437
func HealthCheckV1Probe(logger logr.Logger, config healthcheckV1Config) (*corev1.Probe, error) {
38+
path := config.Path
39+
if len(path) == 0 {
40+
path = DefaultHealthcheckV1Path
41+
}
3542
return &corev1.Probe{
3643
ProbeHandler: corev1.ProbeHandler{
3744
HTTPGet: &corev1.HTTPGetAction{
38-
Path: config.Path,
45+
Path: path,
3946
Port: intstr.FromInt32(config.GetPortNumOrDefault(logger, DefaultHealthcheckV1Port)),
4047
},
4148
},

internal/components/extensions/healthcheckv1_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestHealthCheckV1Probe(t *testing.T) {
8383
want: &corev1.Probe{
8484
ProbeHandler: corev1.ProbeHandler{
8585
HTTPGet: &corev1.HTTPGetAction{
86-
Path: "",
86+
Path: "/",
8787
Port: intstr.FromInt32(9090),
8888
},
8989
},
@@ -101,7 +101,7 @@ func TestHealthCheckV1Probe(t *testing.T) {
101101
want: &corev1.Probe{
102102
ProbeHandler: corev1.ProbeHandler{
103103
HTTPGet: &corev1.HTTPGetAction{
104-
Path: "",
104+
Path: "/",
105105
Port: intstr.FromInt32(extensions.DefaultHealthcheckV1Port),
106106
},
107107
},
@@ -118,7 +118,7 @@ func TestHealthCheckV1Probe(t *testing.T) {
118118
want: &corev1.Probe{
119119
ProbeHandler: corev1.ProbeHandler{
120120
HTTPGet: &corev1.HTTPGetAction{
121-
Path: "",
121+
Path: "/",
122122
Port: intstr.FromInt32(7070),
123123
},
124124
},
@@ -135,7 +135,7 @@ func TestHealthCheckV1Probe(t *testing.T) {
135135
want: &corev1.Probe{
136136
ProbeHandler: corev1.ProbeHandler{
137137
HTTPGet: &corev1.HTTPGetAction{
138-
Path: "",
138+
Path: "/",
139139
Port: intstr.FromInt32(extensions.DefaultHealthcheckV1Port),
140140
},
141141
},

0 commit comments

Comments
 (0)