hashicorp / hashicorp/consul-template

After receiving SIGHUP consul-template starts to use more sockets (file descriptors)

Open
#1,067 2 comments 0 reactions 0 assignees View on GitHub
needs-investigation
Dominant language
Go
Stars
4.8k
Forks
801
Avg merge
4h 5m
Merged PRs (30d)
6

Description

### Consul Template version

consul-template v0.19.4 (68b1da2)

### Configuration

```hcl
consul {
address = "127.0.0.1:8500"
retry {
enabled = true
attempts = -1
backoff = "2s"
}
}

max_stale = "2m"
log_level = "warn"
template {
source = "/etc/octopus/upstream/ztestweb500-zcu-backend.ctpl"
destination = "/etc/nginx/sites-enabled/consul/ztestweb500-zcu-backend"
command = "sudo service nginx reload"
perms = 0644
left_delimiter = "{:"
right_delimiter = ":}"
}
```

### Command

```shell
/usr/local/bin/consul-template -config /etc/octopus/consul-template
```

### Expected behavior

The number of sockets (file descriptors) used by the consul-template must remain the same after receiving SIGHUP.

### Actual behavior

The number of sockets (file descriptors) used by the consul-template increases irreversible after each SIGHUP. And sooner or later leads to run out of all ephemeral ports on the local node.

### Steps to reproduce

1. We have 1784 consul-template config files with 1919 dependencies in total
2. while true; do date; netstat -an4| grep "127.0.0.1:8500"| wc -l; ls -la /proc/$(pidof consul-template)/fd/ | wc -l; kill -HUP $(pidof consul-template) ;sleep 240; done

### References

- GH-591
- GH-595

Contributor guide

Open the contributing guide

Research direction

Start with the provided consul-template command and reproduction loop, monitoring connections to 127.0.0.1:8500 and the process file-descriptor count across repeated SIGHUP signals. Review the SIGHUP reload path and the behavior described in GH-591 and GH-595; done means repeated reloads leave socket and file-descriptor usage stable without exhausting ephemeral ports.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.