Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use regex instead of man command to extract options #3

Merged
merged 1 commit into from
Nov 12, 2021
Merged

Use regex instead of man command to extract options #3

merged 1 commit into from
Nov 12, 2021

Conversation

AbcSxyZ
Copy link
Contributor

@AbcSxyZ AbcSxyZ commented Nov 12, 2021

Current Dockerfile can break with the following issue with minimized image like focal.

To use environment variables to configure the container with docker run, the docker-entrypoint.py was using man command through a subprocess to get all existing option of an executable.

On minimized version of Ubuntu image, man command is disabled with the following message:

This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, including manpages, you can run the 'unminimize'

Use python regex on raw man file to avoid the issue and retrieve all options.

Potential Error

Using a minimized image could raise the following:

Traceback (most recent call last):
  File "/usr/local/bin/docker-entrypoint", line 124, in <module>
    EXECUTABLE_ARGS = convert_env()
  File "/usr/local/bin/docker-entrypoint", line 79, in convert_env
    dogecoind_options = executable_options()
  File "/usr/local/bin/docker-entrypoint", line 32, in executable_options
    raw_options = subprocess.check_output(
  File "/usr/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'bash -c "man dogecoind | grep '^ *-'"' returned non-zero exit status 1.

Man command do not work properly on ubuntu minimized image,
fix it using python regex directly on man file
Copy link
Member

@patricklodder patricklodder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK.

Found that -e doesn't support ALL options (e.g. those from -help-debug, as those don't get added to the manpage) but since these work by just adding them as an argument to command space of docker run, I think we're good for now.

@AbcSxyZ
Copy link
Contributor Author

AbcSxyZ commented Nov 12, 2021

Found that -e doesn't support ALL options (e.g. those from -help-debug, as those don't get added to the manpage)

I will take a look, I was able to grab it with the regex, I had to care about it specifically. It should be a quick thing to solve.

@patricklodder
Copy link
Member

I will take a look, I was able to grab it with the regex, I had to care about it specifically. It should be a quick thing to solve.

Yeah we can pick this up separately, it's not a blocker because for now it works with docker run and those are mostly used for debugging / special circumstances. The only ones I can think of outside of debugging are, in sort-of order of importance:

  • -sendfreetransactions for allowing free tx right now
  • -checkblocks for detecting HW problems (or in case of k8s, persistence layer issues - not uncommon)
  • -rpcservertimeout for nodes that get pounded with slow RPC requests that have a cs_main lock, eg getchaintips
  • -rpcnamecoinapi for miners
  • -logtimemicros for nodes running debug logs
  • -limitfreerelay in the future when we bring back free space for utxo consolidation

@patricklodder patricklodder merged commit f031da2 into dogecoin:main Nov 12, 2021
@AbcSxyZ
Copy link
Contributor Author

AbcSxyZ commented Nov 16, 2021

How were you passing the environment variable for -help-debug ? Did you use docker run -e HELP_DEBUG= exactly, with the equal ?

I verified and the argument is working, it's used with execve parameters.

@patricklodder
Copy link
Member

no that is ok. try LOGTIMEMICROS= or RPCNAMECOINAPI=1

@AbcSxyZ
Copy link
Contributor Author

AbcSxyZ commented Nov 16, 2021

There is no mention of -logtimemicros & -rpcnamecoinapi in the dogecoind man (1.14.4 & 1.14.5). These options do not exist for the program.

@patricklodder
Copy link
Member

patricklodder commented Nov 16, 2021

docker run -e HELP= -e HELP_DEBUG= | grep -logtimemicros

edit: forgot we're testing 1.14.4 so there is no -rpcnamecoinapi because I added it in .5, but there is -logtimemicros

@AbcSxyZ AbcSxyZ deleted the fix-man-options branch December 4, 2021 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants