Page MenuHomePhabricator

Make webservice command read default cli arguments from ~/.webservicerc
Closed, ResolvedPublic

Description

It would be nice to be able to put flags like --backend=kubernetes into a config file.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

It already reads them from service.manifest...

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!

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 :)

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.

scfc triaged this task as Low priority.Feb 16 2017, 10:17 PM
scfc moved this task from Backlog to Ready to be worked on on the Toolforge board.
scfc subscribed.

+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

https://gerrit.wikimedia.org/r/435691

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

https://gerrit.wikimedia.org/r/437164

Change 437164 merged by jenkins-bot:
[operations/software/tools-webservice@master] Read rcfile if it exists and parse arguments from it using configparser

https://gerrit.wikimedia.org/r/437164

Might need some documentation on how to use this.

bd808 assigned this task to Nehajha.
bd808 added a subscriber: Nehajha.

Change 435691 abandoned by BryanDavis:
Read command line arguments from a config file

Reason:
Done via I27403ae75af47ac009aff75373437d21a9ab9d81 instead

https://gerrit.wikimedia.org/r/435691