fluent-plugin-google-cloud 0.6.18 → 0.6.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/fluent-plugin-google-cloud.gemspec +1 -1
- data/lib/fluent/plugin/out_google_cloud.rb +10 -5
- data/test/plugin/base_test.rb +30 -21
- data/test/plugin/constants.rb +25 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6d301ee1e5098270379065a452a62e1764d322e
|
4
|
+
data.tar.gz: 973c4d138bd5ac58f44c21a49afc3146949446d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d5120e4508b5d218241cdca371b878e64d2d8da6c1a97bc712f845363886e2a8cd96807bc2098ab55232bcf2c7f97b103766ae446b71adea874aa713af5e7db
|
7
|
+
data.tar.gz: b4a3e052be29fe201d6c7ca3a10893ad53a292fe09ad309e20a04cc7af979d12548b483a3ca72d51734125bc27a35fdefa123d8d315ad210b7b011408597f9d9
|
@@ -10,7 +10,7 @@ eos
|
|
10
10
|
gem.homepage =
|
11
11
|
'https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud'
|
12
12
|
gem.license = 'Apache-2.0'
|
13
|
-
gem.version = '0.6.
|
13
|
+
gem.version = '0.6.19'
|
14
14
|
gem.authors = ['Ling Huang', 'Igor Peshansky']
|
15
15
|
gem.email = ['stackdriver-agents@google.com']
|
16
16
|
gem.required_ruby_version = Gem::Requirement.new('>= 2.2')
|
@@ -226,7 +226,7 @@ module Fluent
|
|
226
226
|
Fluent::Plugin.register_output('google_cloud', self)
|
227
227
|
|
228
228
|
PLUGIN_NAME = 'Fluentd Google Cloud Logging plugin'.freeze
|
229
|
-
PLUGIN_VERSION = '0.6.
|
229
|
+
PLUGIN_VERSION = '0.6.19'.freeze
|
230
230
|
|
231
231
|
# Name of the the Google cloud logging write scope.
|
232
232
|
LOGGING_SCOPE = 'https://www.googleapis.com/auth/logging.write'.freeze
|
@@ -258,6 +258,11 @@ module Fluent
|
|
258
258
|
config_param :zone, :string, :default => nil
|
259
259
|
config_param :vm_id, :string, :default => nil
|
260
260
|
config_param :vm_name, :string, :default => nil
|
261
|
+
# Kubernetes-specific parameters, only used to override these values in
|
262
|
+
# the fallback path when the metadata agent is temporarily unavailable.
|
263
|
+
# They have to match the configuration of the metadata agent.
|
264
|
+
config_param :k8s_cluster_name, :string, :default => nil
|
265
|
+
config_param :k8s_cluster_location, :string, :default => nil
|
261
266
|
|
262
267
|
# Map keys from a JSON payload to corresponding LogEntry fields.
|
263
268
|
config_param :http_request_key, :string, :default =>
|
@@ -2181,7 +2186,7 @@ module Fluent
|
|
2181
2186
|
begin
|
2182
2187
|
@k8s_cluster_name ||= fetch_gce_metadata(
|
2183
2188
|
'instance/attributes/cluster-name')
|
2184
|
-
@
|
2189
|
+
@k8s_cluster_location ||= fetch_gce_metadata(
|
2185
2190
|
'instance/attributes/cluster-location')
|
2186
2191
|
rescue StandardError => e
|
2187
2192
|
@log.error 'Failed to retrieve k8s cluster name and location.', \
|
@@ -2194,18 +2199,18 @@ module Fluent
|
|
2194
2199
|
'pod_name' => pod_name,
|
2195
2200
|
'container_name' => container_name,
|
2196
2201
|
'cluster_name' => @k8s_cluster_name,
|
2197
|
-
'location' => @
|
2202
|
+
'location' => @k8s_cluster_location
|
2198
2203
|
}
|
2199
2204
|
fallback_resource = GKE_CONSTANTS[:resource_type]
|
2200
2205
|
when K8S_NODE_CONSTANTS[:resource_type]
|
2201
2206
|
labels = {
|
2202
2207
|
'node_name' => node_name,
|
2203
2208
|
'cluster_name' => @k8s_cluster_name,
|
2204
|
-
'location' => @
|
2209
|
+
'location' => @k8s_cluster_location
|
2205
2210
|
}
|
2206
2211
|
fallback_resource = COMPUTE_CONSTANTS[:resource_type]
|
2207
2212
|
end
|
2208
|
-
unless @k8s_cluster_name && @
|
2213
|
+
unless @k8s_cluster_name && @k8s_cluster_location
|
2209
2214
|
@log.error "Failed to construct #{resource_type} resource locally." \
|
2210
2215
|
' Falling back to writing logs against' \
|
2211
2216
|
" #{fallback_resource} resource.", error: e
|
data/test/plugin/base_test.rb
CHANGED
@@ -1310,28 +1310,28 @@ module BaseTest
|
|
1310
1310
|
# k8s_container.
|
1311
1311
|
# When enable_metadata_agent is false.
|
1312
1312
|
{
|
1313
|
-
|
1313
|
+
config: APPLICATION_DEFAULT_CONFIG,
|
1314
1314
|
setup_metadata_agent_stub: false,
|
1315
1315
|
setup_k8s_stub: false,
|
1316
1316
|
log_entry: k8s_container_log_entry(log_entry(0)),
|
1317
1317
|
expected_params: COMPUTE_PARAMS
|
1318
1318
|
},
|
1319
1319
|
{
|
1320
|
-
|
1320
|
+
config: APPLICATION_DEFAULT_CONFIG,
|
1321
1321
|
setup_metadata_agent_stub: true,
|
1322
1322
|
setup_k8s_stub: false,
|
1323
1323
|
log_entry: k8s_container_log_entry(log_entry(0)),
|
1324
1324
|
expected_params: COMPUTE_PARAMS
|
1325
1325
|
},
|
1326
1326
|
{
|
1327
|
-
|
1327
|
+
config: APPLICATION_DEFAULT_CONFIG,
|
1328
1328
|
setup_metadata_agent_stub: true,
|
1329
1329
|
setup_k8s_stub: true,
|
1330
1330
|
log_entry: k8s_container_log_entry(log_entry(0)),
|
1331
1331
|
expected_params: COMPUTE_PARAMS
|
1332
1332
|
},
|
1333
1333
|
{
|
1334
|
-
|
1334
|
+
config: APPLICATION_DEFAULT_CONFIG,
|
1335
1335
|
setup_metadata_agent_stub: false,
|
1336
1336
|
setup_k8s_stub: true,
|
1337
1337
|
log_entry: k8s_container_log_entry(log_entry(0)),
|
@@ -1339,28 +1339,35 @@ module BaseTest
|
|
1339
1339
|
},
|
1340
1340
|
# When enable_metadata_agent is true.
|
1341
1341
|
{
|
1342
|
-
|
1342
|
+
config: ENABLE_METADATA_AGENT_CONFIG,
|
1343
1343
|
setup_metadata_agent_stub: false,
|
1344
1344
|
setup_k8s_stub: false,
|
1345
1345
|
log_entry: k8s_container_log_entry(log_entry(0)),
|
1346
1346
|
expected_params: COMPUTE_PARAMS
|
1347
1347
|
},
|
1348
1348
|
{
|
1349
|
-
|
1349
|
+
config: ENABLE_METADATA_AGENT_CONFIG,
|
1350
1350
|
setup_metadata_agent_stub: false,
|
1351
1351
|
setup_k8s_stub: true,
|
1352
1352
|
log_entry: k8s_container_log_entry(log_entry(0)),
|
1353
1353
|
expected_params: K8S_CONTAINER_PARAMS_FROM_LOCAL
|
1354
1354
|
},
|
1355
1355
|
{
|
1356
|
-
|
1356
|
+
config: CUSTOM_K8S_ENABLE_METADATA_AGENT_CONFIG,
|
1357
|
+
setup_metadata_agent_stub: false,
|
1358
|
+
setup_k8s_stub: false,
|
1359
|
+
log_entry: k8s_container_log_entry(log_entry(0)),
|
1360
|
+
expected_params: K8S_CONTAINER_PARAMS_CUSTOM
|
1361
|
+
},
|
1362
|
+
{
|
1363
|
+
config: ENABLE_METADATA_AGENT_CONFIG,
|
1357
1364
|
setup_metadata_agent_stub: true,
|
1358
1365
|
setup_k8s_stub: false,
|
1359
1366
|
log_entry: k8s_container_log_entry(log_entry(0)),
|
1360
1367
|
expected_params: K8S_CONTAINER_PARAMS
|
1361
1368
|
},
|
1362
1369
|
{
|
1363
|
-
|
1370
|
+
config: ENABLE_METADATA_AGENT_CONFIG,
|
1364
1371
|
setup_metadata_agent_stub: true,
|
1365
1372
|
setup_k8s_stub: true,
|
1366
1373
|
log_entry: k8s_container_log_entry(log_entry(0)),
|
@@ -1368,7 +1375,7 @@ module BaseTest
|
|
1368
1375
|
},
|
1369
1376
|
# When local_resource_id is not present or does not match k8s regexes.
|
1370
1377
|
{
|
1371
|
-
|
1378
|
+
config: ENABLE_METADATA_AGENT_CONFIG,
|
1372
1379
|
setup_metadata_agent_stub: true,
|
1373
1380
|
setup_k8s_stub: true,
|
1374
1381
|
log_entry: k8s_container_log_entry(
|
@@ -1376,7 +1383,7 @@ module BaseTest
|
|
1376
1383
|
expected_params: COMPUTE_PARAMS
|
1377
1384
|
},
|
1378
1385
|
{
|
1379
|
-
|
1386
|
+
config: ENABLE_METADATA_AGENT_CONFIG,
|
1380
1387
|
setup_metadata_agent_stub: true,
|
1381
1388
|
setup_k8s_stub: true,
|
1382
1389
|
log_entry: k8s_container_log_entry(
|
@@ -1388,21 +1395,28 @@ module BaseTest
|
|
1388
1395
|
},
|
1389
1396
|
# Specific cases for k8s_node.
|
1390
1397
|
{
|
1391
|
-
|
1398
|
+
config: APPLICATION_DEFAULT_CONFIG,
|
1392
1399
|
setup_metadata_agent_stub: true,
|
1393
1400
|
setup_k8s_stub: true,
|
1394
1401
|
log_entry: k8s_node_log_entry(log_entry(0)),
|
1395
1402
|
expected_params: COMPUTE_PARAMS
|
1396
1403
|
},
|
1397
1404
|
{
|
1398
|
-
|
1399
|
-
setup_metadata_agent_stub:
|
1405
|
+
config: ENABLE_METADATA_AGENT_CONFIG,
|
1406
|
+
setup_metadata_agent_stub: false,
|
1400
1407
|
setup_k8s_stub: true,
|
1401
1408
|
log_entry: k8s_node_log_entry(log_entry(0)),
|
1402
|
-
expected_params:
|
1409
|
+
expected_params: K8S_NODE_PARAMS_FROM_LOCAL
|
1403
1410
|
},
|
1404
1411
|
{
|
1405
|
-
|
1412
|
+
config: CUSTOM_K8S_ENABLE_METADATA_AGENT_CONFIG,
|
1413
|
+
setup_metadata_agent_stub: false,
|
1414
|
+
setup_k8s_stub: false,
|
1415
|
+
log_entry: k8s_node_log_entry(log_entry(0)),
|
1416
|
+
expected_params: K8S_NODE_PARAMS_CUSTOM
|
1417
|
+
},
|
1418
|
+
{
|
1419
|
+
config: ENABLE_METADATA_AGENT_CONFIG,
|
1406
1420
|
setup_metadata_agent_stub: true,
|
1407
1421
|
setup_k8s_stub: true,
|
1408
1422
|
log_entry: k8s_node_log_entry(log_entry(0)),
|
@@ -1422,12 +1436,7 @@ module BaseTest
|
|
1422
1436
|
setup_no_k8s_metadata_stubs
|
1423
1437
|
end
|
1424
1438
|
setup_logging_stubs do
|
1425
|
-
|
1426
|
-
ENABLE_METADATA_AGENT_CONFIG
|
1427
|
-
else
|
1428
|
-
APPLICATION_DEFAULT_CONFIG
|
1429
|
-
end
|
1430
|
-
d = create_driver(config)
|
1439
|
+
d = create_driver(test_params[:config])
|
1431
1440
|
d.emit(test_params[:log_entry])
|
1432
1441
|
d.run
|
1433
1442
|
end
|
data/test/plugin/constants.rb
CHANGED
@@ -43,6 +43,9 @@ module Constants
|
|
43
43
|
CUSTOM_FULLY_QUALIFIED_ZONE = "projects/#{PROJECT_ID}/zones/#{ZONE}".freeze
|
44
44
|
CUSTOM_VM_ID = 'C9876543210'.freeze
|
45
45
|
CUSTOM_HOSTNAME = 'custom.hostname.org'.freeze
|
46
|
+
# Kubernetes-specific attributes.
|
47
|
+
CUSTOM_K8S_CLUSTER_NAME = 'kubernetes-cluster'.freeze
|
48
|
+
CUSTOM_K8S_LOCATION = 'kubernetes-location'.freeze
|
46
49
|
|
47
50
|
# Attributes used for the EC2 metadata service.
|
48
51
|
EC2_PROJECT_ID = 'test-ec2-project-id'.freeze
|
@@ -257,6 +260,12 @@ module Constants
|
|
257
260
|
CONFIG_MISSING_METADATA_ALL = %(
|
258
261
|
).freeze
|
259
262
|
|
263
|
+
CUSTOM_K8S_ENABLE_METADATA_AGENT_CONFIG = %(
|
264
|
+
enable_metadata_agent true
|
265
|
+
k8s_cluster_name #{CUSTOM_K8S_CLUSTER_NAME}
|
266
|
+
k8s_cluster_location #{CUSTOM_K8S_LOCATION}
|
267
|
+
).freeze
|
268
|
+
|
260
269
|
CONFIG_EC2_PROJECT_ID = %(
|
261
270
|
project_id #{EC2_PROJECT_ID}
|
262
271
|
).freeze
|
@@ -441,6 +450,14 @@ module Constants
|
|
441
450
|
)
|
442
451
|
)
|
443
452
|
).freeze
|
453
|
+
K8S_CONTAINER_PARAMS_CUSTOM = K8S_CONTAINER_PARAMS.merge(
|
454
|
+
resource: K8S_CONTAINER_PARAMS[:resource].merge(
|
455
|
+
labels: K8S_CONTAINER_PARAMS[:resource][:labels].merge(
|
456
|
+
'cluster_name' => CUSTOM_K8S_CLUSTER_NAME,
|
457
|
+
'location' => CUSTOM_K8S_LOCATION
|
458
|
+
)
|
459
|
+
)
|
460
|
+
).freeze
|
444
461
|
|
445
462
|
# K8s Node.
|
446
463
|
K8S_NODE_PARAMS = {
|
@@ -463,6 +480,14 @@ module Constants
|
|
463
480
|
)
|
464
481
|
)
|
465
482
|
).freeze
|
483
|
+
K8S_NODE_PARAMS_CUSTOM = K8S_NODE_PARAMS.merge(
|
484
|
+
resource: K8S_NODE_PARAMS[:resource].merge(
|
485
|
+
labels: K8S_NODE_PARAMS[:resource][:labels].merge(
|
486
|
+
'cluster_name' => CUSTOM_K8S_CLUSTER_NAME,
|
487
|
+
'location' => CUSTOM_K8S_LOCATION
|
488
|
+
)
|
489
|
+
)
|
490
|
+
).freeze
|
466
491
|
|
467
492
|
# Docker Container.
|
468
493
|
DOCKER_CONTAINER_PARAMS = {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-google-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ling Huang
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|