Page MenuHomePhabricator

dbctl: support --background or --force?
Closed, ResolvedPublic

Description

dbctl at the moment does not have an option to by pass the confirmation message.
It can easily be bypassed by a simple echo "y" | dbctl ... but I was wondering if we should create a --background or --automation or whatever option that we can use when scripting things that will depool changes.
I am currently drafting a small skeleton of a rudimentary script to run automatic schema changes and I thought about this.

Thoughts?

Event Timeline

Volans or someone else mentioned there was a dbctl api, I am guessing that is the best way to go about that, but maybe they can point us to docs or source code to know more.

There's a --batch flag, intended for use from scripts, that I think should work for this?

There's also a Python API that can be used, although its semantics are a bit un-Pythonic -- lots of methods that return a tuple of (return value, [list of errors encountered if any]) instead of throwing exceptions.
Here's what pooling / depooling an instance looks like https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/conftool/+/refs/heads/master/conftool/extensions/dbconfig/cli.py#45 and here's what committing config looks like: https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/conftool/+/refs/heads/master/conftool/extensions/dbconfig/cli.py#123
That's just the implementation of the CLI itself.

Ah, thanks, I didn't know --batch existed, looked for it at https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/conftool/+/refs/heads/master/conftool/extensions/dbconfig/README.md but didn't see anything related. Maybe we should add it there, not in great detail, but just explaining that flag is available.
I can do that next week

Change 533556 had a related patch set uploaded (by CDanis; owner: CDanis):
[operations/software/conftool@master] dbctl: document config commit --batch

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

Change 533556 merged by jenkins-bot:
[operations/software/conftool@master] dbctl: document config commit --batch

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

CDanis claimed this task.

There's a --batch flag, intended for use from scripts, that I think should work for this?

There's also a Python API that can be used, although its semantics are a bit un-Pythonic -- lots of methods that return a tuple of (return value, [list of errors encountered if any]) instead of throwing exceptions.

The lack exceptions are not as problematic as the dependency on arguments. I think I will use the command line command with --batch, and in the future it would be nice to have a proper python3 api. As there is a proper workaround this is not a blocker, I will not file a task, as there are more important tasks pending regarding dbctl, and this ticket is ok as resolved.