Skip to content

Commit da4c6ae

Browse files
committed
beholder/config: wire up ChipIngressForceIPV4 option
1 parent e03cea5 commit da4c6ae

5 files changed

Lines changed: 16 additions & 6 deletions

File tree

pkg/beholder/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func NewGRPCClient(cfg Config, otlploggrpcNew otlploggrpcFactory) (*Client, erro
231231
headerProvider := NewStaticAuthHeaderProvider(cfg.AuthHeaders)
232232
chipIngressOpts = append(chipIngressOpts, chipingress.WithTokenAuth(headerProvider))
233233
}
234-
if !cfg.ChipIngressIPv6Enabled {
234+
if cfg.ChipIngressForceIPV4 {
235235
// Force the use of IPv4 addresses for the chip ingress connection
236236
chipIngressOpts = append(chipIngressOpts, chipingress.WithForceIPV4())
237237
}

pkg/beholder/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type Config struct {
3838
ChipIngressEmitterEnabled bool
3939
ChipIngressEmitterGRPCEndpoint string
4040
ChipIngressInsecureConnection bool // Disables TLS for Chip Ingress Emitter
41-
ChipIngressIPv6Enabled bool
41+
ChipIngressForceIPV4 bool // Forces IPv4 connections for Chip Ingress Emitter
4242

4343
// OTel Log
4444
LogExportTimeout time.Duration

pkg/beholder/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ func ExampleConfig() {
5757
}
5858
fmt.Printf("%+v\n", *config.LogRetryConfig)
5959
// Output:
60-
// {InsecureConnection:true CACertFile: OtelExporterGRPCEndpoint:localhost:4317 OtelExporterHTTPEndpoint:localhost:4318 ResourceAttributes:[{Key:package_name Value:{vtype:4 numeric:0 stringly:beholder slice:<nil>}} {Key:sender Value:{vtype:4 numeric:0 stringly:beholderclient slice:<nil>}}] EmitterExportTimeout:1s EmitterExportInterval:1s EmitterExportMaxBatchSize:512 EmitterMaxQueueSize:2048 EmitterBatchProcessor:true TraceSampleRatio:1 TraceBatchTimeout:1s TraceSpanExporter:<nil> TraceRetryConfig:<nil> MetricReaderInterval:1s MetricRetryConfig:<nil> MetricViews:[] ChipIngressEmitterEnabled:false ChipIngressEmitterGRPCEndpoint: ChipIngressInsecureConnection:false ChipIngressIPv6Enabled:false LogExportTimeout:1s LogExportInterval:1s LogExportMaxBatchSize:512 LogMaxQueueSize:2048 LogBatchProcessor:true LogRetryConfig:<nil> LogStreamingEnabled:false AuthPublicKeyHex: AuthHeaders:map[]}
60+
// {InsecureConnection:true CACertFile: OtelExporterGRPCEndpoint:localhost:4317 OtelExporterHTTPEndpoint:localhost:4318 ResourceAttributes:[{Key:package_name Value:{vtype:4 numeric:0 stringly:beholder slice:<nil>}} {Key:sender Value:{vtype:4 numeric:0 stringly:beholderclient slice:<nil>}}] EmitterExportTimeout:1s EmitterExportInterval:1s EmitterExportMaxBatchSize:512 EmitterMaxQueueSize:2048 EmitterBatchProcessor:true TraceSampleRatio:1 TraceBatchTimeout:1s TraceSpanExporter:<nil> TraceRetryConfig:<nil> MetricReaderInterval:1s MetricRetryConfig:<nil> MetricViews:[] ChipIngressEmitterEnabled:false ChipIngressEmitterGRPCEndpoint: ChipIngressInsecureConnection:false ChipIngressForceIPV4:false LogExportTimeout:1s LogExportInterval:1s LogExportMaxBatchSize:512 LogMaxQueueSize:2048 LogBatchProcessor:true LogRetryConfig:<nil> LogStreamingEnabled:false AuthPublicKeyHex: AuthHeaders:map[]}
6161
// {InitialInterval:5s MaxInterval:30s MaxElapsedTime:1m0s}
6262
}

pkg/loop/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const (
6464

6565
envChipIngressEndpoint = "CL_CHIP_INGRESS_ENDPOINT"
6666
envChipIngressInsecureConnection = "CL_CHIP_INGRESS_INSECURE_CONNECTION"
67+
envChipIngressForceIPV4 = "CL_CHIP_INGRESS_FORCE_IPV4"
6768
)
6869

6970
// EnvConfig is the configuration between the application and the LOOP executable. The values
@@ -119,6 +120,7 @@ type EnvConfig struct {
119120

120121
ChipIngressEndpoint string
121122
ChipIngressInsecureConnection bool
123+
ChipIngressForceIPV4 bool
122124
}
123125

124126
// AsCmdEnv returns a slice of environment variable key/value pairs for an exec.Cmd.
@@ -187,6 +189,7 @@ func (e *EnvConfig) AsCmdEnv() (env []string) {
187189

188190
add(envChipIngressEndpoint, e.ChipIngressEndpoint)
189191
add(envChipIngressInsecureConnection, strconv.FormatBool(e.ChipIngressInsecureConnection))
192+
add(envChipIngressForceIPV4, strconv.FormatBool(e.ChipIngressForceIPV4))
190193

191194
return
192195
}
@@ -350,6 +353,10 @@ func (e *EnvConfig) parse() error {
350353
if err != nil {
351354
return fmt.Errorf("failed to parse %s: %w", envChipIngressInsecureConnection, err)
352355
}
356+
e.ChipIngressForceIPV4, err = getBool(envChipIngressForceIPV4)
357+
if err != nil {
358+
return fmt.Errorf("failed to parse %s: %w", envChipIngressForceIPV4, err)
359+
}
353360
}
354361

355362
return nil

pkg/loop/config_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ func TestEnvConfig_parse(t *testing.T) {
7575
envTelemetryEmitterExportMaxBatchSize: "100",
7676
envTelemetryEmitterMaxQueueSize: "1000",
7777

78-
envChipIngressEndpoint: "http://chip-ingress.example.com",
78+
envChipIngressEndpoint: "chip-ingress.example.com:50051",
7979
envChipIngressInsecureConnection: "true",
80+
envChipIngressForceIPV4: "true",
8081
},
8182
expectError: false,
8283
expectConfig: envCfgFull,
@@ -173,8 +174,9 @@ var envCfgFull = EnvConfig{
173174
TelemetryEmitterExportMaxBatchSize: 100,
174175
TelemetryEmitterMaxQueueSize: 1000,
175176

176-
ChipIngressEndpoint: "http://chip-ingress.example.com",
177+
ChipIngressEndpoint: "chip-ingress.example.com:50051",
177178
ChipIngressInsecureConnection: true,
179+
ChipIngressForceIPV4: true,
178180
}
179181

180182
func TestEnvConfig_AsCmdEnv(t *testing.T) {
@@ -223,8 +225,9 @@ func TestEnvConfig_AsCmdEnv(t *testing.T) {
223225
assert.Equal(t, "1000", got[envTelemetryEmitterMaxQueueSize])
224226

225227
// Assert ChipIngress environment variables
226-
assert.Equal(t, "http://chip-ingress.example.com", got[envChipIngressEndpoint])
228+
assert.Equal(t, "chip-ingress.example.com:50051", got[envChipIngressEndpoint])
227229
assert.Equal(t, "true", got[envChipIngressInsecureConnection])
230+
assert.Equal(t, "true", got[envChipIngressForceIPV4])
228231
}
229232

230233
func TestGetMap(t *testing.T) {

0 commit comments

Comments
 (0)