[LU-12734] bash completion (for now: lctl set/get_param) Created: 09/Sep/19  Updated: 13/Dec/22  Resolved: 20/Sep/19

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.13.0

Type: New Feature Priority: Minor
Reporter: CEA Assignee: Dominique Martinet (Inactive)
Resolution: Fixed Votes: 0
Labels: LTS12

Issue Links:
Related
is related to LU-13225 add bash completion for lfs Resolved
is related to LU-16392 Bash completion regressions, lctl and... Resolved
Rank (Obsolete): 9223372036854775807

 Description   

Fairly far from lustre itself... Being used to tabbing into /proc/fs/lustre, with many files moving to various subdirectories of /sys the lctl set/get_param commands are really hard to use for me without completion.

I wrote bash completion for the *_param commands only to start with, will push to gerrit what I have right away.

Questions:

  • is there interest in general? If not, close this and will spare my time as well
  • can we land some partial completion (e.g. right now the first level of tab works with --list-commands, but beyond that you're on your own except for params commands), or do we want something complete-ish from the start?
  • if we start with lctl, what about lfs, lnetctl, etc etc etc...
  • if we start with bash, what about zsh, fish, etc...
  • should probably install to /usr/share/bash-completion/completions/<something>, but I'm a bit lost as to where to add this bit.

I personally don't care much - definitely won't help with other shell completions but I'd be happy to (slowly) add up other commands and update once in a while; the most critical for me really is set/get_param completion and I've set that up in our configuration management system so this is mostly freebies / possibly call for help to finish.



 Comments   
Comment by Gerrit Updater [ 09/Sep/19 ]

Dominique Martinet (dominique.martinet@cea.fr) uploaded a new patch: https://review.whamcloud.com/36105
Subject: LU-12734 misc: add bash completion for lctl set/get_param
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 0e95b514a2ed0a0ddd4ca5b43858b6220a16f2fc

Comment by Peter Jones [ 09/Sep/19 ]

There was enthusiastic response to this idea on the triage call today

Comment by Andreas Dilger [ 09/Sep/19 ]

IMHO, I think your initial patch is already very useful and worthwhile to land. This is something that I've wanted for a long time.

I think implementing this incrementally is definitely the right way to do it. Trying to do a "full" implementation for all commands would take a lot of time and be of marginal use, since many lctl commands are rarely used. The get/set/list params have by far the most optional arguments, so users need the most help with those. Also, getting the initial functionality out to users could encourage contributions from others.

Having bash completions for "lfs setstripe" would probably be my suggestion for the next thing to tackle.

As for completions for other shells, I think that can be left for users who care more about them. Bash is by far the most common shell, and should get the most attention.

Comment by Gerrit Updater [ 20/Sep/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36105/
Subject: LU-12734 misc: add bash completion for lctl set/get_param
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: f87a7f2656ceff174a00933a170032f093ecc72d

Comment by Peter Jones [ 20/Sep/19 ]

Landed for 2.13

Comment by Gerrit Updater [ 15/Oct/19 ]

Andreas Dilger (adilger@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/36459
Subject: LU-12734 misc: allow older bash_completion versions
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: f40c0e4b7e7efaf6a1ed4cad23abbf2b70892872

Comment by Andreas Dilger [ 15/Oct/19 ]

Dominique, I tried to install the lctl bash completion on an older client (with bash-completion-1.3), and it failed with an error "bash _init_completion: command not found".  By looking at the existing helpers installed on that system, I found that replacing _init_completion with _get_comp_words_by_ref allowed the completions to work.

It looks like the "_get_comp_words_by_ref()" function is also available in newer versions of bash_completion (at least bash-completion-2.1 uses it internally to _init_completions()). It seems to work in my light testing, but I don't know the details of what is being missed by not using _init_completions(). Do you know if that is critical?

PS: this functionality is quite awesome. It even works properly with things like "osc.myth-*.max<tab>" to provide the "short" list of completions rather than expanding "*" to the full list.

Comment by Gerrit Updater [ 18/Oct/19 ]

Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/36483
Subject: LU-12734 misc: add bash completion for lctl set/get_param
Project: fs/lustre-release
Branch: b2_12
Current Patch Set: 1
Commit: 21127722c3de7de0e2c7ea621e4b916cf820f66c

Comment by Gerrit Updater [ 05/Nov/19 ]

Andreas Dilger (adilger@whamcloud.com) merged in patch https://review.whamcloud.com/36459/
Subject: LU-12734 misc: allow older bash_completion versions
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 10578849c9a7cb1e1323fb98b270349651b5bf90

Comment by Gerrit Updater [ 21/Nov/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36483/
Subject: LU-12734 misc: add bash completion for lctl set/get_param
Project: fs/lustre-release
Branch: b2_12
Current Patch Set:
Commit: c2ae9aa442e79b0cb6e8853bc603148791034ca7

Generated at Sat Feb 10 02:55:10 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.