It would be nice to be able to put flags like --backend=kubernetes into a config file.
Description
Details
Related Objects
- Mentioned In
- T158244: Improve `webservice status` output
T156626: k8s webservice restart failure with `ValueError: get() more than one object; use filter`
T190696: [Gsoc 2018] Proposal for Toolforge webservice command Improvement
T190638: GSoC 2018 proposal for Improvements for the Toolforge 'webservice' command
T177603: Proposal: Improvements for the Toolforge 'webservice' command
T175768: Improvements for the Toolforge 'webservice' command
T154504: Make webservice backend default to kubernetes - Mentioned Here
- T156626: k8s webservice restart failure with `ValueError: get() more than one object; use filter`
T158244: Improve `webservice status` output
Event Timeline
Doesn't that file get wiped out when you webservice stop? I thought there was some need to remember to use --backend=kubernetes each time you started the service?
That is true! If we do add a .webservicerc, I hope it it's yaml (rather
than a custom format) and we very clearly define what's in service.manifest
and what's in .webservicerc :)
Also possibly in the future when we've gotten rid of GridEngine we won't
need service.manifest!
I was thinking more about something that plays nicely with argparse. Its pretty trivial to support a file of one cli argument per line settings.
+1 for ~/.webservicerc being argparse and identical to the known command line arguments and not YAML.
Change 435691 had a related patch set uploaded (by Nehajha; owner: Nehajha):
[operations/software/tools-webservice@master] Read command line arguments from a config file
Copied from comment on https://gerrit.wikimedia.org/r/#/c/435691/ where I wrote:
I mentioned fromfile_prefix_chars in T148872#2736050 as a way to process such a file and have it match the expected CLI argument syntax. I did not elaborate there, but my idea was to find a way to run the argparse parsing logic twice: first reading the rcfile and then again reading the CLI arguments.
Thinking more about how the CLI parser for webservice works however, this may end up being a vary large amount of refactoring to accomplish. The things that are really useful to set in the rcfile for a tool are the default backend (gridengine or kubernetes) and the default webservice type (varies by backend). The way that the type is set as a positional argument becomes problematic for inclusion in an rcfile however.
An alternate way to handle this could be to use https://docs.python.org/3/library/configparser.html to read the rcfile if it exists and then inject the backend and type values found during the main section when the associated CLI argument has not been passed.
My main reason for wanting this is that I would like webservice stop; webservice start to be able to preserve maintainer configured state rather than stopping any running service and then starting a lighttpd gridengine job. It would also be nice to have webservice shell be "sticky" in the same way.
Change 437164 had a related patch set uploaded (by Nehajha; owner: Nehajha):
[operations/software/tools-webservice@master] Read rcfile if it exists and parse arguments from it
Change 437164 merged by jenkins-bot:
[operations/software/tools-webservice@master] Read rcfile if it exists and parse arguments from it using configparser
Mentioned in SAL (#wikimedia-cloud) [2018-08-08T10:00:59Z] <zhuyifei1999_> building & publishing toollabs-webservice 0.40 deb, and all Docker images T156626 T148872 T158244
I restored the docs that @Nehajha wrote (and I hid) for this previously: https://wikitech.wikimedia.org/w/index.php?title=Help:Toolforge/Web&diff=1799679&oldid=1798439
Change 435691 abandoned by BryanDavis:
Read command line arguments from a config file
Reason:
Done via I27403ae75af47ac009aff75373437d21a9ab9d81 instead