Skip to content

Commit b085c14

Browse files
authored
Fix blobstore benchmark errand (#604)
- Decouple blobstore benchmark logging from cc logging - Add cc_overrides to ccng yml, with that fog properties are really merged into ccng yml and fog is used for blobstore coomunication
1 parent 01d1e2c commit b085c14

2 files changed

Lines changed: 52 additions & 18 deletions

File tree

jobs/blobstore_benchmark/spec

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ properties:
3939
blobstore_benchmark.cc_overrides:
4040
description: "Hash merged into cc config for this errand."
4141
default: {}
42+
blobstore_benchmark.logging_level:
43+
default: "info"
44+
description: "Steno log level for the benchmark process (info|warn|error)."
45+
blobstore_benchmark.stdout_sink_enabled:
46+
default: false
47+
4248
cc:
4349
description: "Full Cloud Controller 'cc' config subtree."
4450
default: {}

jobs/blobstore_benchmark/templates/cloud_controller_ng.yml.erb

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
<%
22
require 'cgi'
33

4-
def yaml_escape(input_string)
5-
chars_to_escape = /[:\\"\x00-\x1f\x7f]/
6-
chars_needing_quotes = /[ !#'&%*,:>@\[\]\\`{|}]/
7-
delimiter = (chars_needing_quotes.match(input_string) ||
8-
chars_to_escape.match(input_string)) ? '"' : ''
9-
fixed_string = input_string.gsub(/(#{chars_to_escape})/) { |m| "\\x#{'%x' % m.ord}" }
10-
"#{delimiter}#{fixed_string}#{delimiter}"
11-
end
12-
134
def deep_merge_without_overwrite(base, extra)
145
return base unless extra.is_a?(Hash)
156

@@ -28,11 +19,39 @@
2819
end
2920

3021
cc_cfg = (link("cloud_controller_internal").p("cc") rescue {})
31-
3222
unless cc_cfg.is_a?(Hash)
3323
raise "cc link did not return a Hash, got: #{cc_cfg.class}"
3424
end
3525

26+
overrides = p("blobstore_benchmark.cc_overrides", {})
27+
unless overrides.is_a?(Hash)
28+
raise "blobstore_benchmark.cc_overrides must be a Hash, got: #{overrides.class}"
29+
end
30+
31+
def deep_stringify_keys(obj)
32+
return obj unless obj.is_a?(Hash)
33+
34+
obj.each_with_object({}) do |(k, v), h|
35+
h[k.to_s] = v.is_a?(Hash) ? deep_stringify_keys(v) : v
36+
end
37+
end
38+
39+
def deep_merge_overwrite(base, extra)
40+
return base unless extra.is_a?(Hash)
41+
42+
extra.each do |k, v|
43+
if base[k].is_a?(Hash) && v.is_a?(Hash)
44+
deep_merge_overwrite(base[k], v)
45+
else
46+
base[k] = v
47+
end
48+
end
49+
50+
base
51+
end
52+
53+
cc_cfg = deep_merge_overwrite(cc_cfg, overrides)
54+
3655
%w[resource_pool buildpacks packages droplets].each do |k|
3756
section = cc_cfg[k]
3857
next unless section.is_a?(Hash)
@@ -72,7 +91,8 @@
7291
db_hash['ca_cert_path'] = '/var/vcap/jobs/blobstore_benchmark/config/certs/db_ca.crt'
7392
end
7493

75-
logging_level = p("cc.logging_level", cc_cfg["logging_level"] || cc_cfg.dig("logging", "level") || "error")
94+
benchmark_logging_level = p("blobstore_benchmark.logging_level", "info")
95+
benchmark_stdout_sink = p("blobstore_benchmark.stdout_sink_enabled", false)
7696

7797
final = {
7898
'pid_filename' => '/var/vcap/sys/run/blobstore_benchmark/blobstore_benchmark.pid',
@@ -82,23 +102,31 @@
82102
'logging' => {
83103
'file' => '/var/vcap/sys/log/blobstore_benchmark/blobstore_benchmark.log',
84104
'syslog' => 'vcap.cloud_controller_ng',
85-
'level' => logging_level.to_s,
105+
'level' => benchmark_logging_level.to_s,
106+
86107
'max_retries' => p("cc.logging_max_retries", cc_cfg["logging_max_retries"] || 0),
87108
'format' => {
88109
'timestamp' => (cc_cfg.dig("logging", "format", "timestamp") ||
89110
link("cloud_controller_internal").p("cc.logging.format.timestamp", "rfc3339"))
90111
},
91-
'stdout_sink_enabled' => p('cc.stdout_logging_enabled', false)
112+
'stdout_sink_enabled' => benchmark_stdout_sink
92113
},
93114

94115
'db' => db_hash,
95-
96-
'storage_cli_config_file_resource_pool' => '/var/vcap/jobs/blobstore_benchmark/config/storage_cli_config_resource_pool.json',
97-
'storage_cli_config_file_buildpacks' => '/var/vcap/jobs/blobstore_benchmark/config/storage_cli_config_buildpacks.json',
98-
'storage_cli_config_file_packages' => '/var/vcap/jobs/blobstore_benchmark/config/storage_cli_config_packages.json',
99-
'storage_cli_config_file_droplets' => '/var/vcap/jobs/blobstore_benchmark/config/storage_cli_config_droplets.json',
100116
}
101117

118+
mode = p("blobstore_benchmark.mode")
119+
120+
# Only configure storage-cli JSON config paths when running storage-cli mode
121+
if mode == "storage-cli"
122+
final.merge!(
123+
'storage_cli_config_file_resource_pool' => '/var/vcap/jobs/blobstore_benchmark/config/storage_cli_config_resource_pool.json',
124+
'storage_cli_config_file_buildpacks' => '/var/vcap/jobs/blobstore_benchmark/config/storage_cli_config_buildpacks.json',
125+
'storage_cli_config_file_packages' => '/var/vcap/jobs/blobstore_benchmark/config/storage_cli_config_packages.json',
126+
'storage_cli_config_file_droplets' => '/var/vcap/jobs/blobstore_benchmark/config/storage_cli_config_droplets.json',
127+
)
128+
end
129+
102130
deep_merge_without_overwrite(final, cc_cfg)
103131
%>
104132
---

0 commit comments

Comments
 (0)