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

krew install fails to print error when no selector matches #344

Closed
verb opened this issue Sep 23, 2019 · 7 comments · Fixed by #345
Closed

krew install fails to print error when no selector matches #344

verb opened this issue Sep 23, 2019 · 7 comments · Fixed by #345
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/P1 P1 issues or PRs

Comments

@verb
Copy link

verb commented Sep 23, 2019

I ran into this while developing my first plugin. I glanced at the code and it appears that an error should be thrown, so I'm not sure why no errors were printed.

Here's what I did wrong. I used this manifest (notice the capitalization of os: Linux):

apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
  name: alpha-pod-debug
spec:
  version: v0.1.0
  platforms:
  - selector:
      matchLabels:
        os: Linux
        arch: amd64
    uri: https://github.com/verb/kubectl-debug/releases/download/v0.1.0/kubectl-debug_linux_amd64.tar.gz
    sha256: "098fb817c3a8ad631177008462b4bbe18bf2504bc7bc5bfd33c986b95bbf644c"
    bin: "./kubectl-debug"
  shortDescription: Attach ephemeral debug container to running pod
  homepage: https://github.com/verb/kubectl-debug
  caveats: |
    This plugin requires the alpha EphemeralContainers feature to be enabled in the cluster.
    See https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/ for
    enabling features.
  description: |
    This plugin attaches an Ephemeral Container to a running pod for use as an interactive
    debugging session. For more information on Ephemeral Containers, and to understand their
    limitations, see https://kubernetes.io/docs/concepts/workloads/pods/ephemeral-containers/

Then I ran:

% kubectl krew install --alsologtostderr -v=6 --manifest=alpha-pod-debug.yaml
                                        
I0923 11:47:31.447216   16590 install.go:144] --manifest specified, not ensuring plugin index
I0923 11:47:31.447971   16590 install.go:113] Will install plugin: alpha-pod-debug
Installing plugin: alpha-pod-debug             
I0923 11:47:31.448002   16590 install.go:59] Looking for installed versions
I0923 11:47:31.448020   16590 platform.go:43] Matching platform for labels(arch=amd64,os=linux)
CAVEATS:                                  
\                                            
 |  This plugin requires the alpha EphemeralContainers feature to be enabled in the cluster.
 |  See https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/ for
 |  enabling features.                  
/                                            
Installed plugin: alpha-pod-debug             
WARNING: You installed a plugin from the krew-index plugin repository.
   These plugins are not audited for security by the Krew maintainers.
   Run them at your own risk.

This printed the caveat and Installed plugin, but in fact no files were copied.

% kubectl krew list                                                           
PLUGIN  VERSION                                                                                                                   
krew    v0.3.0
% kubectl version
Client Version: version.Info{Major:"1", Minor:"17+", GitVersion:"v1.17.0-alpha.0.1093+aa087703261a79", GitCommit:"aa087703261a7906
e9ebbbd8c2ca6ca871c8111d", GitTreeState:"clean", BuildDate:"2019-09-23T11:16:30Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"
linux/amd64"}
@verb
Copy link
Author

verb commented Sep 23, 2019

Ok, here's the way easier way to reproduce:

% KREW_OS=BLARGGGGGGGG kubectl krew --v=2 install pod-logs                   
I0923 12:11:11.986577   32511 update.go:45] Updating the local copy of plugin index (/home/verb/.krew/index)                     
From https://github.com/kubernetes-sigs/krew-index                                                                               
 = [up to date]      master         -> origin/master
 = [up to date]      ahmetb-patch-1 -> origin/ahmetb-patch-1
 = [up to date]      v0.2.1         -> origin/v0.2.1
HEAD is now at 230f892 Bump grep to v1.2.0 (#246)                                                                                
Updated the local copy of plugin index.                                                                                          
I0923 12:11:12.472395   32511 install.go:113] Will install plugin: pod-logs                                                      
Installing plugin: pod-logs
I0923 12:11:12.472438   32511 install.go:59] Looking for installed versions
I0923 12:11:12.472466   32511 platform.go:43] Matching platform for labels(arch=amd64,os=BLARGGGGGGGG)
Installed plugin: pod-logs
WARNING: You installed a plugin from the krew-index plugin repository.
   These plugins are not audited for security by the Krew maintainers.
   Run them at your own risk.

@ahmetb
Copy link
Member

ahmetb commented Sep 23, 2019

Seems to be a major case unhandled. Thanks for the report. Mu guess is this is due to some recent refactoring we’ve done and zero-values.

@ahmetb
Copy link
Member

ahmetb commented Sep 23, 2019

/kind bug
/priority P1

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. priority/P1 P1 issues or PRs labels Sep 23, 2019
@corneliusweig
Copy link
Contributor

Hey @verb, thanks for your thorough bug report. This made it very easy to find the bug.

@ahmetb So this affects all users/plugins where there is no match in the platforms. Krew's behavior is not broken per se, but the success message is slightly awkward. Do you think we should create a bugfix release for this?

@ahmetb
Copy link
Member

ahmetb commented Sep 24, 2019

@corneliusweig

  • we have a list of supported os/arch combinations
  • manifest validator checks all platform selectors in a pluginSpec to make sure they match to at least one of these os/arch combinations (i.e. no unused PlatformSpecs)

Did that plugin somehow pass the validation with “Linux” spelling?

Feel free to make a release, I think it’s not too critical.

@verb
Copy link
Author

verb commented Sep 25, 2019

@ahmetb I didn't run any validation on the snippet I pasted. I was just following the developer guide locally.

@ahmetb
Copy link
Member

ahmetb commented Sep 25, 2019

I was referring to the krew-manifest-validator that runs as part of krew-index CI tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/P1 P1 issues or PRs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants