Skip to content

Commit 2d82cbd

Browse files
pbuskoloewenstein-sap
authored andcommitted
make agent host configurable Co-authored-by: Pavel Busko <[email protected]>
1 parent d4cbce9 commit 2d82cbd

File tree

8 files changed

+17
-7
lines changed

8 files changed

+17
-7
lines changed

src/cmd/forwarder-agent/app/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
// GRPC stores the configuration for the router as a server using a PORT
1212
// with mTLS certs and as a client.
1313
type GRPC struct {
14+
Host string `env:"AGENT_HOST, report"`
1415
Port uint16 `env:"AGENT_PORT, report"`
1516
CAFile string `env:"AGENT_CA_FILE_PATH, required, report"`
1617
CertFile string `env:"AGENT_CERT_FILE_PATH, required, report"`
@@ -40,6 +41,7 @@ type Config struct {
4041
func LoadConfig() Config {
4142
cfg := Config{
4243
GRPC: GRPC{
44+
Host: "127.0.0.1",
4345
Port: 3458,
4446
},
4547
}

src/cmd/forwarder-agent/app/forwarder_agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (s *ForwarderAgent) Run() {
139139
rx := v2.NewReceiver(diode, im, omm)
140140

141141
s.v2srv = v2.NewServer(
142-
fmt.Sprintf("127.0.0.1:%d", s.grpc.Port),
142+
fmt.Sprintf("%s:%d", s.grpc.Host, s.grpc.Port),
143143
rx,
144144
grpc.Creds(serverCreds),
145145
grpc.MaxRecvMsgSize(10*1024*1024),

src/cmd/loggregator-agent/app/app_v2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (a *AppV2) Start() {
130130
)
131131
go tx.Start()
132132

133-
agentAddress := fmt.Sprintf("127.0.0.1:%d", a.config.GRPC.Port)
133+
agentAddress := fmt.Sprintf("%s:%d", a.config.GRPC.Host, a.config.GRPC.Port)
134134
log.Printf("agent v2 API started on addr %s", agentAddress)
135135

136136
var es envelopeSetter

src/cmd/loggregator-agent/app/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
// GRPC stores the configuration for the router as a server using a PORT
1414
// with mTLS certs and as a client.
1515
type GRPC struct {
16+
Host string `env:"AGENT_HOST"`
1617
Port uint16 `env:"AGENT_PORT"`
1718
CAFile string `env:"AGENT_CA_FILE"`
1819
CertFile string `env:"AGENT_CERT_FILE"`
@@ -50,6 +51,7 @@ func LoadConfig() (*Config, error) {
5051
Port: 14824,
5152
},
5253
GRPC: GRPC{
54+
Host: "127.0.0.1",
5355
Port: 3458,
5456
},
5557
}

src/cmd/syslog-agent/app/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
// GRPC stores the configuration for the router as a server using a PORT
1515
// with mTLS certs and as a client.
1616
type GRPC struct {
17+
Host string `env:"AGENT_HOST, report"`
1718
Port int `env:"AGENT_PORT, report"`
1819
CAFile string `env:"AGENT_CA_FILE_PATH, required, report"`
1920
CertFile string `env:"AGENT_CERT_FILE_PATH, required, report"`
@@ -63,6 +64,7 @@ func LoadConfig() Config {
6364
},
6465
GRPC: GRPC{
6566
Port: 3458,
67+
Host: "127.0.0.1",
6668
},
6769
AggregateConnectionRefreshInterval: 1 * time.Minute,
6870
DefaultDrainMetadata: true,

src/cmd/syslog-agent/app/syslog_agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (s *SyslogAgent) Run() {
263263

264264
rx := v2.NewReceiver(diode, im, omm)
265265
s.v2Srv = v2.NewServer(
266-
fmt.Sprintf("127.0.0.1:%d", s.grpc.Port),
266+
fmt.Sprintf("%s:%d", s.grpc.Host, s.grpc.Port),
267267
rx,
268268
grpc.Creds(serverCreds),
269269
grpc.MaxRecvMsgSize(10*1024*1024),

src/cmd/udp-forwarder/app/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ type GRPC struct {
1919

2020
// Config holds the configuration for the UDP agent
2121
type Config struct {
22-
UseRFC3339 bool `env:"USE_RFC3339"`
23-
UDPPort int `env:"UDP_PORT, report"`
22+
UseRFC3339 bool `env:"USE_RFC3339"`
23+
Host string `env:"AGENT_HOST, report"`
24+
UDPPort int `env:"UDP_PORT, report"`
2425
LoggregatorAgentGRPC GRPC
2526
Deployment string `env:"DEPLOYMENT, report"`
2627
Job string `env:"JOB, report"`
@@ -33,6 +34,7 @@ type Config struct {
3334
// LoadConfig reads from the environment to create a Config.
3435
func LoadConfig(log *log.Logger) Config {
3536
cfg := Config{
37+
Host: "127.0.0.1",
3638
UDPPort: 3457,
3739
LoggregatorAgentGRPC: GRPC{
3840
Addr: "127.0.0.1:3458",

src/cmd/udp-forwarder/app/udp_forwarder.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Metrics interface {
2525

2626
type UDPForwarder struct {
2727
grpc GRPC
28+
host string
2829
udpPort int
2930
pprofServer *http.Server
3031
pprofPort uint16
@@ -44,6 +45,7 @@ type UDPForwarder struct {
4445
func NewUDPForwarder(cfg Config, l *log.Logger, m Metrics) *UDPForwarder {
4546
return &UDPForwarder{
4647
grpc: cfg.LoggregatorAgentGRPC,
48+
host: cfg.Host,
4749
udpPort: cfg.UDPPort,
4850
pprofPort: cfg.MetricsServer.PprofPort,
4951
debugMetrics: cfg.MetricsServer.DebugMetrics,
@@ -97,13 +99,13 @@ func (u *UDPForwarder) Run() {
9799
dropsondeUnmarshaller := ingress.NewUnMarshaller(w)
98100
u.mu.Lock()
99101
u.nr, err = ingress.NewNetworkReader(
100-
fmt.Sprintf("127.0.0.1:%d", u.udpPort),
102+
fmt.Sprintf("%s:%d", u.host, u.udpPort),
101103
dropsondeUnmarshaller,
102104
u.metrics,
103105
)
104106
u.mu.Unlock()
105107
if err != nil {
106-
u.log.Fatalf("Failed to listen on 127.0.0.1:%d: %s", u.udpPort, err)
108+
u.log.Fatalf("Failed to listen on %s:%d: %s", u.host, u.udpPort, err)
107109
}
108110

109111
go u.nr.StartReading()

0 commit comments

Comments
 (0)