You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(nice to have) Mechanism to generate CLI documentation from golang code
(nice to have) Generate alluxio-env.sh.template and validate in PR check that it is up to date
Background
The CLI in the bash format has grown to be a giant monolith of bash code. One of the goals in the new main branch is to properly modularize various portions of the codebase and the set of bash scripts within the bin/ folder is one obvious counterexample to this goal.
Advantages:
Writing in a more structured language other than bash will prevent mistakes such as Fix Xmx check #17459
Golang can be compiled into an executable binary such that there are no additional runtime requirements for Alluxio, as opposed to using an interpreted language such as python
Disadvantages
Introduces golang as a new compilation/development requirement, which was previously a soft requirement as it was needed to run certain scripts such as building the tarball
Compiled executables delivered as part of the tarball cannot be edited, unlike the bash scripts
Layout/Implementation
All cli go code are in the cli/ directory.
If the -PgoCli flag is added when running maven, it will build the required go binary to execute.
If running the bin/cli.sh command and the go binary isn't built yet, it will build on demand
Otherwise, the go cli will not be built. This prevents golang to be a must-have requirement for building the project; will translate it to be a default after deprecating the existing bash cli.
The user provided environment variables remains the same as before, via setting in conf/alluxio-env.sh.
InitAlluxioEnv() in cli/env/env.go initializes the default values and reading from the above user config file, storing them in a global env.Env variable; effectively replacing libexec/alluxio-config.sh
Unlike in bash where variable substitution is rampant, all variables values are always stored in their fully expanded form
Adding --debugLog enables verbose logging to diagnose the logic flow and when appropriate, prints out the corresponding and fully expanded bash command
The Process interface outlines the definition of an Alluxio process
The process defines its own environment variables and sets them in env.Env for subsequent logic to access
The process is added to the command tree under the process subcommand, where currently the only actionable command is Start()
The only current process defined is the Master process in cli/process/master.go
The Command interface outlines the definition for running a java class
The command is added to the command tree under the root command, but could easily expand into its own subcommand tree following cobra's conventions
The BaseCommand struct is designated to be embedded in full implementations of the command interface
BaseCommand.RunJavaClassCmd() organizes the environment variables, java opts, and command line arguments, effectively replacing function runJavaClass in bin/alluxio
Processes and commands are registered in cli/main.go, the entrypoint go file that is compiled to a binary.
Combined with the process and command interfaces, this code architecture promotes extensibility, allowing another go project to use this code as a dependency, picking which processes and commands to register as they choose.
This issue tracks the effort started in #17463
TODO list
bin/cli.shthat builds the CLIBackground
The CLI in the bash format has grown to be a giant monolith of bash code. One of the goals in the new
mainbranch is to properly modularize various portions of the codebase and the set of bash scripts within thebin/folder is one obvious counterexample to this goal.Advantages:
Disadvantages
Layout/Implementation
cli/directory.-PgoCliflag is added when running maven, it will build the required go binary to execute.bin/cli.shcommand and the go binary isn't built yet, it will build on demandconf/alluxio-env.sh.InitAlluxioEnv()incli/env/env.goinitializes the default values and reading from the above user config file, storing them in a globalenv.Envvariable; effectively replacinglibexec/alluxio-config.sh--debugLogenables verbose logging to diagnose the logic flow and when appropriate, prints out the corresponding and fully expanded bash commandProcessinterface outlines the definition of an Alluxio processenv.Envfor subsequent logic to accessprocesssubcommand, where currently the only actionable command isStart()Masterprocess incli/process/master.goCommandinterface outlines the definition for running a java classBaseCommandstruct is designated to be embedded in full implementations of the command interfaceBaseCommand.RunJavaClassCmd()organizes the environment variables, java opts, and command line arguments, effectively replacingfunction runJavaClassinbin/alluxiocli/main.go, the entrypoint go file that is compiled to a binary.