Remove prometheus socket before listen (#4961)
This commit is contained in:
parent
66ef05849f
commit
a8a827a806
1 changed files with 4 additions and 0 deletions
|
@ -22,6 +22,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
@ -97,6 +98,9 @@ var (
|
||||||
// the ingress watch namespace and class used by the controller
|
// the ingress watch namespace and class used by the controller
|
||||||
func NewSocketCollector(pod, namespace, class string, metricsPerHost bool) (*SocketCollector, error) {
|
func NewSocketCollector(pod, namespace, class string, metricsPerHost bool) (*SocketCollector, error) {
|
||||||
socket := "/tmp/prometheus-nginx.socket"
|
socket := "/tmp/prometheus-nginx.socket"
|
||||||
|
// unix sockets must be unlink()ed before being used
|
||||||
|
syscall.Unlink(socket)
|
||||||
|
|
||||||
listener, err := net.Listen("unix", socket)
|
listener, err := net.Listen("unix", socket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue