Skip to content

Commit eff16d4

Browse files
committed
Merge branch 'fix/small-limit-for-kconfserver' into 'master'
fix: allow larger buffer size for commands (especially for idf.py confserver) Closes IDFCI-3569 and IDF-13919 See merge request espressif/esp-idf!42312
2 parents 44767e4 + b51329b commit eff16d4

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

tools/idf_py_actions/core_ext.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,37 @@ def build_target(target_name: str, ctx: Context, args: PropertyDict) -> None:
4646
ensure_build_directory(args, ctx.info_name)
4747
run_target(target_name, args, force_progression=GENERATORS[args.generator].get('force_progression', False))
4848

49+
def confserver_target(target_name: str, ctx: Context, args: PropertyDict, buffer_size: int) -> None:
50+
"""
51+
Execute the idf.py confserver command with the specified buffer size.
52+
"""
53+
ensure_build_directory(args, ctx.info_name)
54+
if buffer_size < 2048:
55+
yellow_print(
56+
f'WARNING: The specified buffer size {buffer_size} KB is less than the '
57+
'recommended minimum of 2048 KB for idf.py confserver. Consider increasing it to at least 2048 KB '
58+
'by setting environment variable IDF_CONFSERVER_BUFFER_SIZE=<buffer size in KB> or by calling '
59+
'idf.py confserver --buffer-size <buffer size in KB>.'
60+
)
61+
try:
62+
run_target(
63+
target_name,
64+
args,
65+
force_progression=GENERATORS[args.generator].get('force_progression', False),
66+
buffer_size=buffer_size,
67+
)
68+
except ValueError as e:
69+
if str(e) == 'Separator is not found, and chunk exceed the limit':
70+
# Buffer size too small/one-line output of the command too long
71+
raise FatalError(
72+
f'ERROR: Command failed with an error message "{e}". '
73+
'Try increasing the buffer size to 2048 (or higher) by setting environment variable '
74+
'IDF_CONFSERVER_BUFFER_SIZE=<buffer size in KB> or by calling '
75+
'idf.py confserver --buffer-size <buffer size in KB>.'
76+
)
77+
else:
78+
raise
79+
4980
def size_target(
5081
target_name: str, ctx: Context, args: PropertyDict, output_format: str, output_file: str, diff_map_file: str
5182
) -> None:
@@ -481,9 +512,22 @@ def help_and_exit(action: str, ctx: Context, param: list, json_option: bool, add
481512
],
482513
},
483514
'confserver': {
484-
'callback': build_target,
515+
'callback': confserver_target,
485516
'help': 'Run JSON configuration server.',
486-
'options': global_options,
517+
'options': global_options
518+
+ [
519+
{
520+
'names': ['--buffer-size'],
521+
'help': (
522+
'Set the buffer size (in KB) in order to accommodate initial confserver response.'
523+
'Default value and recommended minimum is 2048 (KB), but it might need to be '
524+
'increased for very large projects.'
525+
),
526+
'type': int,
527+
'default': 2048,
528+
'envvar': 'IDF_CONFSERVER_BUFFER_SIZE',
529+
}
530+
],
487531
},
488532
'size': {
489533
'callback': size_target,

tools/idf_py_actions/tools.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def __init__(
298298
force_progression: bool = False,
299299
interactive: bool = False,
300300
convert_output: bool = False,
301+
buffer_size: int | None = None,
301302
) -> None:
302303
self.tool_name = tool_name
303304
self.args = args
@@ -310,6 +311,7 @@ def __init__(
310311
self.force_progression = force_progression
311312
self.interactive = interactive
312313
self.convert_output = convert_output
314+
self.buffer_size = buffer_size or 256
313315

314316
def __call__(self) -> None:
315317
def quote_arg(arg: str) -> str:
@@ -368,7 +370,7 @@ async def run_command(self, cmd: list, env_copy: dict) -> tuple[Process, str | N
368370
p = await asyncio.create_subprocess_exec(
369371
*cmd,
370372
env=env_copy,
371-
limit=1024 * 1024,
373+
limit=1024 * self.buffer_size,
372374
cwd=self.cwd,
373375
stdout=asyncio.subprocess.PIPE,
374376
stderr=asyncio.subprocess.PIPE,
@@ -520,6 +522,7 @@ def run_target(
520522
custom_error_handler: FunctionType | None = None,
521523
force_progression: bool = False,
522524
interactive: bool = False,
525+
buffer_size: int | None = None,
523526
) -> None:
524527
"""Run target in build directory."""
525528
if env is None:
@@ -546,6 +549,7 @@ def run_target(
546549
hints=not args.no_hints,
547550
force_progression=force_progression,
548551
interactive=interactive,
552+
buffer_size=buffer_size,
549553
)()
550554

551555

0 commit comments

Comments
 (0)