Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indexserver: add debug subcommand #288

Merged
merged 1 commit into from
Feb 21, 2022
Merged

Conversation

stefanhengl
Copy link
Member

This adds a subcommand "debug" to indexserver.

➜  ~ zoekt-sourcegraph-indexserver debug --help
USAGE
  debug <subcommand>

SUBCOMMANDS
  find          find a shard by repo name
  index         index a repository
  list          list the repositories that are OWNED by this indexserver
  list-indexed  list the repositories that are INDEXED by this indexserver
  merge         run a full merge operation inside dir
  meta          output index and repo metadata
  trigrams      list all the trigrams in a shard

The new subcommand contains all debug commands that were previously
handled as flags. This means that this PR changes the API of indexserver
but only for the debug commands. There is no change in how we start indexserver.

The debug commands now live in a separate file "debug.go" and don't polute the
defintion of the server anymore. I used the vistor pattern as described
here peterbourgon/ff#76 to reuse the root flags for some of the debug commands.

Other changes:

  • removed deprecated flag exp-git-index
  • removed second argument of setupTmpDir because it was not used
  • sorted imports in main.go

How to review:
The diff is actually more readable than it appears at first glance. I
recommend to start at the bottom of main.go. Most of the changes in
main.go come from deleting things related to debug commands and
changing the parameters from pointers to values.

Test Plan:

  • I ran a local instance of Sourcegraph with a version of Zoekt based on
    this PR.
  • I built a binary for zoekt-sourcegraph-indexserver, copied it to a
    production instance and tried out all debug commands.

This adds a subcommand "debug" to indexserver.

The new subcommand contains all debug commands that were previously
handled as flags. This means that this commit changes the API but only for
debug command. There is no change in how we start indexserver.

The debug commands now live in a separate file "debug.go" and don't polute the
defintion of the server anymore. I used the vistor pattern as described
here peterbourgon/ff#76 to reuse the root
flags for some of the debug commands.

Other changes:
- removed deprecated flag exp-git-index
- removed second argument of setupTmpDir because it was not used
- sorted imports in main.go

How to review:
The diff is actually more readable than it appears at first glance. I
recommend to start at the bottom of main.go. Most of the changes in
main.go come from deleting things relating to debug commands and
changing the parameters from pointers to values.

Test Plan:
- I ran a local instance of Sourcegraph with a verion of Zoekt based on
this PR. Start up and indexing were successful.
- I built a binary for zoekt-sourcegraph-indexserver, copied it to a
production instance and tried out all debug commands
@stefanhengl stefanhengl requested a review from a team February 18, 2022 14:36
Copy link
Member

@keegancsmith keegancsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@stefanhengl stefanhengl merged commit 881cec1 into master Feb 21, 2022
@stefanhengl stefanhengl deleted the sh/add-debug-subcommand branch February 21, 2022 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants