hashicorp / hashicorp/consul-esm

Consul-ESM crashes if there is no Consul Namespaces

Open
#175 1 comment 0 reactions 0 assignees View on GitHub
bug consul unreproducible waiting for reply
Dominant language
Go
Stars
270
Forks
47
Avg merge
1h 14m
Merged PRs (30d)
3

Description

With Consul Enterprise, if there is no Consul Namespace created, Consul ESM will crash when starting up.

#### Reproduction Steps

1. Remove all Consul namespaces
2. Run Consul-ESM

### Environment

Consul-ESM: v0.6.2
Consul: v1.13.0+ent

### Output of consul Namespaces

```
$ consul namespace list -format json
[]
```

### Actual result

```
2022-10-31T19:02:40.883+0100 [INFO] consul-esm: Trying to obtain leadership...
2022-10-31T19:02:40.892+0100 [INFO] consul-esm: Obtained leadership
2022-10-31T19:02:40.893+0100 [INFO] consul-esm: Updating external node list: items=8
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xbe15e9]

goroutine 39 [running]:
main.(*Agent).getServiceInstances(0xc00010ef80, 0xc0005c9ee8)
/home/runner/work/consul-esm/consul-esm/leader.go:303 +0x289
main.(*Agent).watchServiceInstances(0xc00010ef80, 0x0?, 0xc00055c180)
/home/runner/work/consul-esm/consul-esm/leader.go:266 +0x179
created by main.(*Agent).computeWatchedNodes
/home/runner/work/consul-esm/consul-esm/leader.go:125 +0x165
```

### Workaround

Just by adding a Namespace in Consul:

```
consul namespace create -name foobar
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.