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

Revisit commands to ensure they can cope with an unreachable index or malformed manifests #614

Closed
chriskim06 opened this issue Jun 21, 2020 · 5 comments · Fixed by #620
Closed

Comments

@chriskim06
Copy link
Member

chriskim06 commented Jun 21, 2020

Here are the various subcommands I thought needed testing and what I found in certain scenarios:

index

  • add index with no plugins dir
    • no error
  • add index with malformed plugin yaml
    • no error
  • remove index after deleting plugins dir
    • no error
  • remove index with malformed plugin yaml
    • no error

install

  • install plugin from index with malformed yaml
$ KREW_ROOT="/home/kimc/playground" X_KREW_ENABLE_MULTI_INDEX=1 /home/kimc/go/src/sigs.k8s.io/krew/out/bin/krew-linux_amd64 install local/fields
E0621 09:50:50.081559   16368 scanner.go:67] failed to read or parse plugin manifest "fields": plugin manifest validation error: plugin manifest has apiVersion="", not supported in this version of krew (try updating plugin index or install a newer version of krew)
Updated the local copy of plugin index "c".
Updated the local copy of plugin index.
Updated the local copy of plugin index "foo".
Updated the local copy of plugin index "local".
E0621 09:50:50.432399   16368 scanner.go:67] failed to read or parse plugin manifest "fields": plugin manifest validation error: plugin manifest has apiVersion="", not supported in this version of krew (try updating plugin index or install a newer version of krew)
F0621 09:50:50.435499   16368 root.go:79] failed to load plugin "local/fields" from the index: plugin manifest validation error: plugin manifest has apiVersion="", not supported in this version of krew (try updating plugin index or install a newer version of krew)

info

  • info of plugin from index with malformed yaml
failed to load plugin manifest: plugin manifest validation error: plugin manifest has apiVersion="", not supported in this version of krew (try updating plugin index or install a newer version of krew)

search

  • search with index that has no plugins directory
failed to load the list of plugins from the index: lstat /home/kimc/playground/index/local/plugins: no such file or directory
  • search with plugin from index with malformed yaml
    • still returned the rest of the plugins
failed to read or parse plugin manifest "fields": plugin manifest validation error: plugin manifest has apiVersion="", not supported in this version of krew (try updating plugin index or install a newer version of krew)

update

  • index with no plugins dir
    • no error
  • index with malformed plugin yaml
failed to read or parse plugin manifest "fields": plugin manifest validation error: plugin manifest has apiVersion="", not supported in this version of krew (try updating plugin index or install a newer version of krew)
  • delete remote index
$ KREW_ROOT="/home/kimc/playground" X_KREW_ENABLE_MULTI_INDEX=1 /home/kimc/go/src/sigs.k8s.io/krew/out/bin/krew-linux_amd64 update
Updated the local copy of plugin index "c".
Updated the local copy of plugin index.
Updated the local copy of plugin index "foo".
W0621 10:04:09.069045   19863 update.go:168] failed to update index "local": fetch index at "/home/kimc/playground/index/local" failed: command execution failure, output="fatal: '/home/kimc/playground/temp' does not appear to be a git repository\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n": exit status 128
F0621 10:04:09.131058   19863 root.go:79] failed to update the following indexes: local
: fetch index at "/home/kimc/playground/index/local" failed: command execution failure, output="fatal: '/home/kimc/playground/temp' does not appear to be a git repository\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n": exit status 128

upgrade

  • plugin after deleting its manifest from index
    • plugin "local/fields" does not exist in the plugin index
@chriskim06
Copy link
Member Author

/area multi-index

@ahmetb
Copy link
Member

ahmetb commented Jun 22, 2020

Thanks for this research.
Something I was hoping to find out is imagine there are indexes a, default, f. If there’s an issue in f, how badly does that break update, upgrade, install, search commands for other indexes. (do they continue working or are they completely bricked due to a bad index)

@ahmetb
Copy link
Member

ahmetb commented Jun 22, 2020

Some issues I noticed:

  • search: failed to load the list of plugins from the index: lstat [...] this doesn't mention index name (solution: add a "%q" with name)

  • info: what if apiVersion etc was correct BUT later in the doc there was a syntax error in yaml? I suspect that returns a better error?

@chriskim06
Copy link
Member Author

If there’s an issue in f, how badly does that break update, upgrade, install, search commands for other indexes

no plugins dir

  • update
    • works fine; all indexes get updated
  • upgrade
    • plugin installed, then plugin dir gets deleted from index: other plugins upgrade fine
  • install
    • works fine installing other plugins
  • search
    • doesn't work

malformed yaml

  • update
    • works, but shows errors for when we try to list the available upgrades diff from this function (error occurs twice since this gets called before and after index updates)
  • upgrade
    • plugin installed, then its yaml becomes malformed: fails when it gets to the plugin with malformed yaml
  • install
    • fails to install malformed plugin
    • installing other plugins works fine
  • search
    • still works for everything but shows the error I mentioned above in addition to search results

what if apiVersion etc was correct BUT later in the doc there was a syntax error in yaml? I suspect that returns a better error?

Good idea, I didn't think to test that (I just looked at missing/misspelled keys). When I create a syntax error I see something like:

F0622 13:49:34.457835   27639 root.go:79] failed to load plugin manifest: failed to parse yaml file: error converting YAML to JSON: yaml: line 16: did not find expected key

@chriskim06
Copy link
Member Author

@ahmetb @corneliusweig what do you guys think? How much of this falls under the unsupported behavior aspect of custom indexes?

If most of this seems good I can submit a PR to address:

search: failed to load the list of plugins from the index: lstat [...] this doesn't mention index name (solution: add a "%q" with name)

and whatever else that needs to be addressed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants