Skip to content

Commit 03db58f

Browse files
ImeevMATotktonada
authored andcommitted
config: introduce feedback options
This patch introduces all feedback options. Part of tarantool#8861 NO_DOC=Was already described before.
1 parent e78afb3 commit 03db58f

File tree

5 files changed

+173
-10
lines changed

5 files changed

+173
-10
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## feature/config
2+
3+
* All feedback options are now supported (gh-8861).

src/box/lua/config/instance_config.lua

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,17 @@ local function advertise_peer_uri_validate(data, w)
232232
return uri
233233
end
234234

235+
local function feedback_apply_default_if(_data, _w)
236+
return box.internal.feedback_daemon ~= nil
237+
end
238+
239+
local function feedback_validate(data, w)
240+
if data == nil or box.internal.feedback_daemon ~= nil then
241+
return
242+
end
243+
w.error('Tarantool is built without feedback reports sending support')
244+
end
245+
235246
return schema.new('instance_config', schema.record({
236247
config = schema.record({
237248
version = schema.enum({
@@ -1179,6 +1190,57 @@ return schema.new('instance_config', schema.record({
11791190
end
11801191
end,
11811192
}),
1193+
feedback = schema.record({
1194+
enabled = schema.scalar({
1195+
type = 'boolean',
1196+
box_cfg = 'feedback_enabled',
1197+
default = true,
1198+
apply_default_if = feedback_apply_default_if,
1199+
validate = feedback_validate,
1200+
}),
1201+
crashinfo = schema.scalar({
1202+
type = 'boolean',
1203+
box_cfg = 'feedback_crashinfo',
1204+
default = true,
1205+
apply_default_if = feedback_apply_default_if,
1206+
validate = feedback_validate,
1207+
}),
1208+
host = schema.scalar({
1209+
type = 'string',
1210+
box_cfg = 'feedback_host',
1211+
default = 'https://feedback.tarantool.io',
1212+
apply_default_if = feedback_apply_default_if,
1213+
validate = feedback_validate,
1214+
}),
1215+
metrics_collect_interval = schema.scalar({
1216+
type = 'number',
1217+
box_cfg = 'feedback_metrics_collect_interval',
1218+
default = 60,
1219+
apply_default_if = feedback_apply_default_if,
1220+
validate = feedback_validate,
1221+
}),
1222+
send_metrics = schema.scalar({
1223+
type = 'boolean',
1224+
box_cfg = 'feedback_send_metrics',
1225+
default = true,
1226+
apply_default_if = feedback_apply_default_if,
1227+
validate = feedback_validate,
1228+
}),
1229+
interval = schema.scalar({
1230+
type = 'number',
1231+
box_cfg = 'feedback_interval',
1232+
default = 3600,
1233+
apply_default_if = feedback_apply_default_if,
1234+
validate = feedback_validate,
1235+
}),
1236+
metrics_limit = schema.scalar({
1237+
type = 'integer',
1238+
box_cfg = 'feedback_metrics_limit',
1239+
default = 1024 * 1024,
1240+
apply_default_if = feedback_apply_default_if,
1241+
validate = feedback_validate,
1242+
}),
1243+
}),
11821244
}, {
11831245
-- This kind of validation cannot be implemented as the
11841246
-- 'validate' annotation of a particular schema node. There

test/config-luatest/cluster_config_schema_test.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ g.test_defaults = function()
222222
config = {
223223
reload = 'auto',
224224
},
225+
feedback = box.internal.feedback_daemon ~= nil and {
226+
crashinfo = true,
227+
host = 'https://feedback.tarantool.io',
228+
metrics_collect_interval = 60,
229+
send_metrics = true,
230+
enabled = true,
231+
interval = 3600,
232+
metrics_limit = 1024*1024,
233+
} or nil,
225234
}
226235
local res = cluster_config:apply_default({})
227236
t.assert_equals(res, exp)

test/config-luatest/config_test.lua

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,51 @@ g.test_remaining_vinyl_options = function()
343343
t.assert_equals(box.cfg.vinyl_timeout, 7.5)
344344
end)
345345
end
346+
347+
g.test_feedback_options = function()
348+
t.skip_if(box.internal.feedback_daemon == nil, 'Feedback is disabled')
349+
local dir = treegen.prepare_directory(g, {}, {})
350+
local config = [[
351+
credentials:
352+
users:
353+
guest:
354+
roles:
355+
- super
356+
357+
iproto:
358+
listen: unix/:./{{ instance_name }}.iproto
359+
360+
feedback:
361+
crashinfo: false
362+
host: 'https://feedback.tarantool.io'
363+
metrics_collect_interval: 120
364+
send_metrics: false
365+
enabled: false
366+
interval: 7200
367+
metrics_limit: 1000000
368+
369+
groups:
370+
group-001:
371+
replicasets:
372+
replicaset-001:
373+
instances:
374+
instance-001: {}
375+
]]
376+
local config_file = treegen.write_script(dir, 'config.yaml', config)
377+
local opts = {
378+
config_file = config_file,
379+
alias = 'instance-001',
380+
chdir = dir,
381+
}
382+
g.server = server:new(opts)
383+
g.server:start()
384+
g.server:exec(function()
385+
t.assert_equals(box.cfg.feedback_crashinfo, false)
386+
t.assert_equals(box.cfg.feedback_host, 'https://feedback.tarantool.io')
387+
t.assert_equals(box.cfg.feedback_metrics_collect_interval, 120)
388+
t.assert_equals(box.cfg.feedback_send_metrics, false)
389+
t.assert_equals(box.cfg.feedback_enabled, false)
390+
t.assert_equals(box.cfg.feedback_interval, 7200)
391+
t.assert_equals(box.cfg.feedback_metrics_limit, 1000000)
392+
end)
393+
end

test/config-luatest/instance_config_schema_test.lua

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,15 +1044,6 @@ g.test_box_cfg_coverage = function()
10441044
password_enforce_specialchars = true,
10451045
password_history_length = true,
10461046

1047-
-- TODO: Will be added in the scope of gh-8861.
1048-
feedback_enabled = true,
1049-
feedback_crashinfo = true,
1050-
feedback_host = true,
1051-
feedback_interval = true,
1052-
feedback_send_metrics = true,
1053-
feedback_metrics_collect_interval = true,
1054-
feedback_metrics_limit = true,
1055-
10561047
-- TODO: Will be added in the scope of gh-8861.
10571048
flightrec_enabled = true,
10581049
flightrec_logs_size = true,
@@ -1095,11 +1086,18 @@ g.test_box_cfg_coverage = function()
10951086

10961087
-- Collect box_cfg annotations from the schema.
10971088
local box_cfg_options_in_schema = instance_config:pairs():filter(function(w)
1089+
if w.schema.box_cfg == nil then
1090+
return false
1091+
end
10981092
-- Skip EE options on CE.
10991093
if w.schema.enterprise_edition and not is_enterprise then
11001094
return false
11011095
end
1102-
return w.schema.box_cfg ~= nil
1096+
-- Skip feedback options if feedback is disabled.
1097+
if w.schema.box_cfg:startswith('feedback') then
1098+
return box.internal.feedback_daemon ~= nil
1099+
end
1100+
return true
11031101
end):map(function(w)
11041102
return w.schema.box_cfg, {
11051103
path = table.concat(w.path, '.'),
@@ -1169,3 +1167,46 @@ g.test_box_cfg_coverage = function()
11691167
end
11701168
end
11711169
end
1170+
1171+
g.test_feedback_enabled = function()
1172+
t.skip_if(box.internal.feedback_daemon == nil, 'Feedback is disabled')
1173+
local iconfig = {
1174+
feedback = {
1175+
crashinfo = false,
1176+
host = 'one',
1177+
metrics_collect_interval = 1,
1178+
send_metrics = false,
1179+
enabled = true,
1180+
interval = 2,
1181+
metrics_limit = 3,
1182+
},
1183+
}
1184+
instance_config:validate(iconfig)
1185+
validate_fields(iconfig.feedback, instance_config.schema.fields.feedback)
1186+
1187+
local exp = {
1188+
crashinfo = true,
1189+
host = 'https://feedback.tarantool.io',
1190+
metrics_collect_interval = 60,
1191+
send_metrics = true,
1192+
enabled = true,
1193+
interval = 3600,
1194+
metrics_limit = 1024*1024,
1195+
}
1196+
local res = instance_config:apply_default({}).feedback
1197+
t.assert_equals(res, exp)
1198+
end
1199+
1200+
g.test_feedback_disabled = function()
1201+
t.skip_if(box.internal.feedback_daemon ~= nil, 'Feedback is enabled')
1202+
local iconfig = {
1203+
feedback = {
1204+
enabled = true,
1205+
},
1206+
}
1207+
local ok, err = pcall(instance_config.validate, instance_config, iconfig)
1208+
t.assert(not ok)
1209+
local exp = '[instance_config] feedback.enabled: Tarantool is built '..
1210+
'without feedback reports sending support'
1211+
t.assert_equals(err, exp)
1212+
end

0 commit comments

Comments
 (0)