Skip to content

Commit 802ee42

Browse files
committed
feat: replace loggregator V1 UDP emitter with gRPC V2 client
feat: replace loggregator V1 UDP emitter with gRPC V2 client Remove the loggregator_emitter gem (V1, UDP/beefcake) and replace it with a new LoggregatorEmitter::Client backed by gRPC V2. The client uses lazy stub initialization to avoid gRPC background threads conflicting with Puma's thread pool at startup. Config keys renamed from `router`/`internal_url` to `endpoint`, with optional mTLS cert fields added to all three schemas (api, clock, worker). Integration and unit tests updated to use the V2 gRPC fake server.
1 parent b1f1251 commit 802ee42

16 files changed

Lines changed: 302 additions & 57 deletions

File tree

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ gem 'hashdiff'
1212
gem 'httpclient'
1313
gem 'json-diff'
1414
gem 'json-schema'
15-
gem 'loggregator_emitter', '~> 5.0'
1615
gem 'mime-types', '~> 3.7'
1716
gem 'multipart-parser'
1817
gem 'netaddr', '>= 2.0.4'

Gemfile.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ GEM
9494
ms_rest_azure (~> 0.7.0)
9595
backport (1.2.0)
9696
base64 (0.3.0)
97-
beefcake (1.0.0)
9897
benchmark (0.5.0)
9998
bigdecimal (4.1.1)
10099
bit-struct (0.17)
@@ -284,8 +283,6 @@ GEM
284283
rb-fsevent (~> 0.10, >= 0.10.3)
285284
rb-inotify (~> 0.9, >= 0.9.10)
286285
logger (1.7.0)
287-
loggregator_emitter (5.2.0)
288-
beefcake (~> 1.0.0)
289286
loofah (2.25.1)
290287
crass (~> 1.0.2)
291288
nokogiri (>= 1.12.0)
@@ -636,7 +633,6 @@ DEPENDENCIES
636633
json-diff
637634
json-schema
638635
listen
639-
loggregator_emitter (~> 5.0)
640636
machinist (~> 1.0.6)
641637
mime-types (~> 3.7)
642638
mock_redis

config/cloud_controller.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ log_audit_events: false
122122
telemetry_log_path: spec/artifacts/cloud_controller_telemetry.log
123123

124124
loggregator:
125-
router: "127.0.0.1:3456"
126-
internal_url: 'http://loggregator-trafficcontroller.service.cf.internal:8081'
125+
endpoint: "127.0.0.1:3456"
127126

128127
logcache:
129128
host: 'http://doppler.service.cf.internal'

lib/cloud_controller/config_schemas/api_schema.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,10 @@ class ApiSchema < VCAP::Config
316316
},
317317

318318
optional(:loggregator) => {
319-
router: String,
320-
internal_url: String
319+
endpoint: String,
320+
optional(:ca_file) => String,
321+
optional(:cert_file) => String,
322+
optional(:key_file) => String
321323
},
322324

323325
optional(:fluent) => {

lib/cloud_controller/config_schemas/clock_schema.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ class ClockSchema < VCAP::Config
180180
optional(:uaa_client_scope) => String,
181181

182182
optional(:loggregator) => {
183-
router: String
183+
endpoint: String,
184+
optional(:ca_file) => String,
185+
optional(:cert_file) => String,
186+
optional(:key_file) => String
184187
},
185188

186189
optional(:fluent) => {

lib/cloud_controller/config_schemas/worker_schema.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ class WorkerSchema < VCAP::Config
195195
},
196196

197197
optional(:loggregator) => {
198-
router: String
198+
endpoint: String,
199+
optional(:ca_file) => String,
200+
optional(:cert_file) => String,
201+
optional(:key_file) => String
199202
},
200203

201204
optional(:fluent) => {

lib/cloud_controller/runner.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'cloud_controller/uaa/uaa_token_decoder'
44
require 'cloud_controller/uaa/uaa_verification_keys'
55
require 'app_log_emitter'
6-
require 'loggregator_emitter'
6+
require 'loggregator_emitter/client'
77
require 'fluent_emitter'
88
require 'cloud_controller/rack_app_builder'
99
require 'cloud_controller/metrics/periodic_updater'
@@ -174,16 +174,20 @@ def setup_blobstore
174174
end
175175

176176
def setup_app_log_emitter
177+
VCAP::AppLogEmitter.logger = logger
177178
VCAP::AppLogEmitter.fluent_emitter = fluent_emitter if @config.get(:fluent)
178179

179-
if @config.get(:loggregator) && @config.get(
180-
:loggregator, :router
181-
)
182-
VCAP::AppLogEmitter.emitter = LoggregatorEmitter::Emitter.new(@config.get(:loggregator, :router), 'cloud_controller', 'API',
183-
@config.get(:index))
184-
end
180+
return unless @config.get(:loggregator) && @config.get(:loggregator, :endpoint)
185181

186-
VCAP::AppLogEmitter.logger = logger
182+
VCAP::AppLogEmitter.emitter = LoggregatorEmitter::Client.new(
183+
endpoint: @config.get(:loggregator, :endpoint),
184+
origin: 'cloud_controller',
185+
source_type: 'API',
186+
instance_id: @config.get(:index),
187+
ca_cert_file: @config.get(:loggregator, :ca_file),
188+
client_cert_file: @config.get(:loggregator, :cert_file),
189+
client_key_file: @config.get(:loggregator, :key_file)
190+
)
187191
end
188192

189193
def fluent_emitter

lib/delayed_job/delayed_worker.rb

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'puma'
44
require 'prometheus/middleware/exporter'
55
require 'cloud_controller/standalone_metrics_webserver'
6+
require 'loggregator_emitter/client'
67

78
class CloudController::DelayedWorker
89
DEFAULT_READ_AHEAD_POSTGRES = 0
@@ -96,15 +97,20 @@ def get_initialized_delayed_worker(config, logger)
9697
end
9798

9899
def setup_app_log_emitter(config, logger)
100+
VCAP::AppLogEmitter.logger = logger
99101
VCAP::AppLogEmitter.fluent_emitter = fluent_emitter(config) if config.get(:fluent)
100-
if config.get(:loggregator) && config.get(
101-
:loggregator, :router
102-
)
103-
VCAP::AppLogEmitter.emitter = LoggregatorEmitter::Emitter.new(config.get(:loggregator, :router), 'cloud_controller', 'API',
104-
config.get(:index))
105-
end
106102

107-
VCAP::AppLogEmitter.logger = logger
103+
return unless config.get(:loggregator) && config.get(:loggregator, :endpoint)
104+
105+
VCAP::AppLogEmitter.emitter = LoggregatorEmitter::Client.new(
106+
endpoint: config.get(:loggregator, :endpoint),
107+
origin: 'cloud_controller',
108+
source_type: 'API',
109+
instance_id: config.get(:index),
110+
ca_cert_file: config.get(:loggregator, :ca_file),
111+
client_cert_file: config.get(:loggregator, :cert_file),
112+
client_key_file: config.get(:loggregator, :key_file)
113+
)
108114
end
109115

110116
def fluent_emitter(config)

lib/loggregator-api/v2/envelope_pb.rb

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/loggregator-api/v2/ingress_pb.rb

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)