Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadbalancerexporter nil pointer dereference when no endpoints found #10110

Closed
jvilhuber opened this issue May 17, 2022 · 2 comments
Closed

loadbalancerexporter nil pointer dereference when no endpoints found #10110

jvilhuber opened this issue May 17, 2022 · 2 comments
Assignees
Labels

Comments

@jvilhuber
Copy link
Contributor

jvilhuber commented May 17, 2022

Describe the bug
I can reproduce this when I have 0 backends deployed (but the hless-service is deployed). In that case I assume the list of IP Addresses is empty, and we panic with a null pointer.

This also happened on startup when I deployed in a live system. Either the DNS failed (I get the occasional i/o error from the DNS lookup) or perhaps the hless service was not yet populated (I wasn't fast enough to check that).

Steps to reproduce
Deploy an hless service but scale down the referenced pods to 0. Then start a load-balancer front-end.

What did you expect to see?
No crash.

What did you see instead?

2022/05/17 12:34:13 http: panic serving 10.42.0.250:51694: runtime error: invalid memory address or nil pointer dereference
goroutine 102 [running]:
net/http.(*conn).serve.func1()
	net/http/server.go:1825 +0xb8
panic({0xb24920, 0x15da580})
	runtime/panic.go:844 +0x260
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End.func1()
	go.opentelemetry.io/otel/[email protected]/trace/span.go:359 +0x30
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End(0x40001d8180, {0x0, 0x0, 0x2854c?})
	go.opentelemetry.io/otel/[email protected]/trace/span.go:398 +0x6fc
panic({0xb24920, 0x15da580})
	runtime/panic.go:838 +0x20c
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter.(*hashRing).findEndpoint(0x400088fbd0?, 0x7b9de0?)
	github.com/open-telemetry/opentelemetry-collector-contrib/exporter/[email protected]/consistent_hashing.go:64 +0x1c
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter.(*hashRing).endpointFor(0x40005490c8?, {{{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x11, ...}}})
	github.com/open-telemetry/opentelemetry-collector-contrib/exporter/[email protected]/consistent_hashing.go:59 +0xe0
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter.(*loadBalancerImp).Endpoint(0x40005d4000?, {{{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x11, ...}}})
	github.com/open-telemetry/opentelemetry-collector-contrib/exporter/[email protected]/loadbalancer.go:181 +0xc8
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter.(*traceExporterImp).consumeTrace(0x4000126750, {0xe3eaf8, 0x40004bb350}, {0x400000e030?})
	github.com/open-telemetry/opentelemetry-collector-contrib/exporter/[email protected]/trace_exporter.go:104 +0xb8
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter.(*traceExporterImp).ConsumeTraces(0xe3eaf8?, {0xe3eaf8, 0x40004bb350}, {0x969f78?})
	github.com/open-telemetry/opentelemetry-collector-contrib/exporter/[email protected]/trace_exporter.go:92 +0x68
go.opentelemetry.io/collector/processor/processorhelper.NewTracesProcessor.func1({0xe3eaf8, 0x40004bb350}, {0x400000e030?})
	go.opentelemetry.io/[email protected]/processor/processorhelper/traces.go:70 +0x1bc
go.opentelemetry.io/collector/consumer.ConsumeTracesFunc.ConsumeTraces(...)
	go.opentelemetry.io/[email protected]/consumer/traces.go:36
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver.consumeTraces({0xe3eaf8, 0x40004bb350}, 0x40004ba270, {0xe38b10, 0x40001eb1a0})
	github.com/open-telemetry/opentelemetry-collector-contrib/receiver/[email protected]/trace_receiver.go:239 +0x88
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver.(*jReceiver).HandleThriftHTTPBatch(0x40003cc1e0, {0xe3e6e0, 0x40004b6f60}, 0x40003b8a00)
	github.com/open-telemetry/opentelemetry-collector-contrib/receiver/[email protected]/trace_receiver.go:443 +0xb0
net/http.HandlerFunc.ServeHTTP(0x40003b8900?, {0xe3e6e0?, 0x40004b6f60?}, 0x400021a460?)
	net/http/server.go:2084 +0x3c
github.com/gorilla/mux.(*Router).ServeHTTP(0x400019ac00, {0xe3e6e0, 0x40004b6f60}, 0x40003b8800)
	github.com/gorilla/[email protected]/mux.go:210 +0x1a8
go.opentelemetry.io/collector/config/confighttp.(*decompressor).wrap.func1({0xe3e6e0, 0x40004b6f60}, 0x40003b8800)
	go.opentelemetry.io/[email protected]/config/confighttp/compression.go:160 +0x170
net/http.HandlerFunc.ServeHTTP(0xc49900?, {0xe3e6e0?, 0x40004b6f60?}, 0xe2e170?)
	net/http/server.go:2084 +0x3c
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp.(*Handler).ServeHTTP(0x400017e8c0, {0xe3d7b0?, 0x40001e80e0}, 0x40003b8400)
	go.opentelemetry.io/contrib/instrumentation/net/http/[email protected]/handler.go:191 +0xaf0
go.opentelemetry.io/collector/config/confighttp.(*clientInfoHandler).ServeHTTP(0x400000e450, {0xe3d7b0, 0x40001e80e0}, 0x400043ba00)
	go.opentelemetry.io/[email protected]/config/confighttp/clientinfohandler.go:39 +0x23c
net/http.serverHandler.ServeHTTP({0xe381d8?}, {0xe3d7b0, 0x40001e80e0}, 0x400043ba00)
	net/http/server.go:2916 +0x408
net/http.(*conn).serve(0x400056c140, {0xe3eaf8, 0x40004baf90})
	net/http/server.go:1966 +0x550
created by net/http.(*Server).Serve
	net/http/server.go:3071 +0x448

What version did you use?
0.51.0

What config did you use?

    "exporters":
      "loadbalancing":
        "protocol":
          "otlp":
            "compression": "snappy"
            "retry_on_failure":
              "enabled": true
              "initial_interval": "5s"
              "max_elapsed_time": "300s"
              "max_interval": "30s"
            "sending_queue":
              "enabled": true
              "num_consumers": 120
              "queue_size": 40000
            "timeout": "2s"
            "tls":
              "insecure": true
        "resolver":
          "dns":
            "hostname": "otel-collector-backend-hless.default.svc.cluster.local"
            "port": 14317
    "extensions":
      "health_check":
        "endpoint": ":13133"
      "pprof":
        "endpoint": ":1777"
    "processors":
      "memory_limiter":
        "check_interval": "5s"
        "limit_percentage": 100
        "spike_limit_percentage": 10
    "receivers":
      "jaeger":
        "protocols":
          "grpc": {}
          "thrift_binary": {}
          "thrift_compact": {}
          "thrift_http": {}
      "opencensus":
        "endpoint": "0.0.0.0:55678"
      "otlp":
        "protocols":
          "grpc": {}
          "http": {}
      "zipkin": {}
    "service":
      "extensions":
      - "health_check"
      - "pprof"
      "pipelines":
        "traces/0":
          "exporters":
          - "loadbalancing"
          "processors":
          - "memory_limiter"
          "receivers":
          - "otlp"
          - "jaeger"
          - "zipkin"
          - "opencensus"
      "telemetry":
        "logs":
          "encoding": "json"
          "level": "info"
        "metrics":
          "address": "0.0.0.0:8888"
          "level": "normal"

Environment
Kubernetes as well as rancher-desktop testing.

Additional context

@jvilhuber jvilhuber added the bug Something isn't working label May 17, 2022
@jvilhuber
Copy link
Contributor Author

I'm guessing this:

// findEndpoint returns the "next" endpoint starting from the given position, or an empty string in case no endpoints are available
func (h *hashRing) findEndpoint(pos position) string {
	ringSize := len(h.items)
	if ringSize == 0 {
		return ""
	}

h.items may need to be checked for nil (sorry my go-setup is currently messed up, and can't do a PR or even compile locally).

@jvilhuber
Copy link
Contributor Author

Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants