Skip to content

Commit 029ae2a

Browse files
committed
reckless: A plugin with required option now doesn't crash installation the first time reckless tries to install it without the option, but instead warns the user and asks for manual insertion, then resumes installation attempt.
1 parent c14ff6c commit 029ae2a

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

tools/reckless

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,10 +1588,45 @@ def _install_plugin(src: InstInfo) -> Union[InstInfo, None]:
15881588
log.debug("plugin testing error:")
15891589
for line in test_log:
15901590
log.debug(f' {line}')
1591-
log.error('plugin testing failed')
1592-
remove_dir(clone_path)
1593-
remove_dir(inst_path)
1594-
return None
1591+
log.warning('plugin exited before establishing a CLN connection; '
1592+
'it may require options to be configured')
1593+
# At this point the installation cannot continue without user input.
1594+
# This part might be incompatible with automated executions (e.g. CI)
1595+
user_input = ''
1596+
if sys.stdin.isatty():
1597+
print("Enter an option as NAME=VALUE to retry (string values only), "
1598+
"or press Enter to skip: ", end='', flush=True)
1599+
try:
1600+
user_input = input().strip()
1601+
except EOFError:
1602+
pass
1603+
if user_input:
1604+
if '=' not in user_input:
1605+
log.warning("invalid option format (expected NAME=VALUE); skipping retry")
1606+
else:
1607+
opt_name, opt_value = user_input.split('=', 1)
1608+
opt_name = opt_name.strip()
1609+
if not opt_name:
1610+
log.warning("option name cannot be empty; skipping retry")
1611+
elif not isinstance(opt_value, str):
1612+
log.warning("option value must be a string; skipping retry")
1613+
else:
1614+
retry_env = os.environ.copy()
1615+
retry_env[opt_name] = opt_value
1616+
log.debug(f"retrying plugin test with {opt_name}={opt_value!r}")
1617+
try:
1618+
retest = run(
1619+
[Path(staged_src.source_loc).joinpath(staged_src.entry)],
1620+
cwd=str(staging_path), stdout=PIPE, stderr=PIPE,
1621+
text=True, timeout=10, env=retry_env)
1622+
retest_returncode = retest.returncode
1623+
except TimeoutExpired:
1624+
retest_returncode = 0
1625+
if retest_returncode == 0:
1626+
log.info('plugin started successfully with provided option')
1627+
else:
1628+
log.warning('plugin still failed after retry; '
1629+
'options must be configured before use')
15951630

15961631
add_installation_metadata(staged_src, src)
15971632
log.info(f'plugin installed: {inst_path}')

0 commit comments

Comments
 (0)