Remove prometheus socket before listen (#4961)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-01-25 14:52:51 -03:00 committed by GitHub
parent 66ef05849f
commit a8a827a806
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,6 +22,7 @@ import (
"io/ioutil"
"net"
"os"
"syscall"
jsoniter "github.com/json-iterator/go"
"github.com/prometheus/client_golang/prometheus"
@ -97,6 +98,9 @@ var (
// the ingress watch namespace and class used by the controller
func NewSocketCollector(pod, namespace, class string, metricsPerHost bool) (*SocketCollector, error) {
socket := "/tmp/prometheus-nginx.socket"
// unix sockets must be unlink()ed before being used
syscall.Unlink(socket)
listener, err := net.Listen("unix", socket)
if err != nil {
return nil, err