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

[BUG] CLI Panic when assigning variables #1513

Closed
goffinf opened this issue Jan 31, 2021 · 1 comment
Closed

[BUG] CLI Panic when assigning variables #1513

goffinf opened this issue Jan 31, 2021 · 1 comment
Assignees
Labels
bug Something isn't working type:cli cli releated issue

Comments

@goffinf
Copy link

goffinf commented Jan 31, 2021

Software version numbers

kyverno version
Version: 1.3.1
Time: 2021-01-19T20:11:29Z
Git commit ID: aca98d3748f2a710a8fab2451d6bbf5e67664ed7
  • Kubernetes version:

1.20

  • Kyverno version:

kyverno CLI:

kyverno version
Version: 1.3.1
Time: 2021-01-19T20:11:29Z
Git commit ID: aca98d3748f2a710a8fab2451d6bbf5e67664ed7

kyverno K8s install:

helm list -n kyverno
NAME    NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
kyverno kyverno         1               2021-01-28 15:29:02.7925561 +0000 UTC   deployed        kyverno-v1.3.1  v1.3.1

Describe the bug

The example used is from the documentation at : https://kyverno.io/docs/kyverno-cli/#apply

  • add_network_policy.yaml
  • required_default_network_policy.yaml
  • value.yaml

The same behaviour appears to occur for other examples also.

The following panic error is output when running an apply when passing a variable either as a direct assignment or via a values file:

kyverno apply add_network_policy.yaml --resource required_default_network_policy.yaml -s request.object.metadata.name=devtest

panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/kyverno/kyverno/pkg/kyverno/apply.getVariable(0x7fff9a6e1155, 0x24, 0x0, 0x0, 0x10, 0x141c8a0, 0xc0003c4901, 0xc0003c4a20)
        /home/runner/work/kyverno/kyverno/pkg/kyverno/apply/command.go:296 +0x244
github.com/kyverno/kyverno/pkg/kyverno/apply.applyCommandHelper(0xc000594790, 0x1, 0x1, 0x1020000, 0x0, 0x0, 0x7fff9a6e1155, 0x24, 0x0, 0x0, ...)
        /home/runner/work/kyverno/kyverno/pkg/kyverno/apply/command.go:156 +0x92
github.com/kyverno/kyverno/pkg/kyverno/apply.Command.func1(0xc0002d82c0, 0xc00007d360, 0x1, 0x5, 0x0, 0x0)
        /home/runner/work/kyverno/kyverno/pkg/kyverno/apply/command.go:127 +0x13c
github.com/spf13/cobra.(*Command).execute(0xc0002d82c0, 0xc00007d310, 0x5, 0x5, 0xc0002d82c0, 0xc00007d310)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0xc00013bb80, 0xc0004bbf50, 0x3, 0x3)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
github.com/kyverno/kyverno/pkg/kyverno.CLI()
        /home/runner/work/kyverno/kyverno/pkg/kyverno/main.go:35 +0xf7
main.main()
        /home/runner/work/kyverno/kyverno/cmd/cli/kubectl-kyverno/main.go:8 +0x20

and using a values file ...

kyverno apply add_network_policy.yaml --resource required_default_network_policy.yaml -f value.yaml
panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/kyverno/kyverno/pkg/kyverno/apply.getVariable(0x0, 0x0, 0x7fffb182a16f, 0xa, 0x40be8c, 0x7fa144d9ae70, 0x13f, 0xc00034b3d0)
        /home/runner/work/kyverno/kyverno/pkg/kyverno/apply/command.go:321 +0x4b0
github.com/kyverno/kyverno/pkg/kyverno/apply.applyCommandHelper(0xc0001cc2b0, 0x1, 0x1, 0x7020000, 0x0, 0x0, 0x0, 0x0, 0x7fffb182a16f, 0xa, ...)
        /home/runner/work/kyverno/kyverno/pkg/kyverno/apply/command.go:156 +0x92
github.com/kyverno/kyverno/pkg/kyverno/apply.Command.func1(0xc0002d82c0, 0xc00007d360, 0x1, 0x5, 0x0, 0x0)
        /home/runner/work/kyverno/kyverno/pkg/kyverno/apply/command.go:127 +0x13c
github.com/spf13/cobra.(*Command).execute(0xc0002d82c0, 0xc00007d310, 0x5, 0x5, 0xc0002d82c0, 0xc00007d310)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0xc00013bb80, 0xc000623f50, 0x3, 0x3)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
github.com/kyverno/kyverno/pkg/kyverno.CLI()
        /home/runner/work/kyverno/kyverno/pkg/kyverno/main.go:35 +0xf7
main.main()
        /home/runner/work/kyverno/kyverno/cmd/cli/kubectl-kyverno/main.go:8 +0x20

The policy file reports as valid:

kyverno validate add_network_policy.yaml
----------------------------------------------------------------------
Policy add-networkpolicy is valid.

An apply WITHOUT the variable assignment does not crash (just skips):

kyverno apply add_network_policy.yaml --resource required_default_network_policy.yaml

applying 1 policy to 1 resource...

pass: 0, fail: 0, warn: 0, error: 0, skip: 1

To Reproduce

Attempt to run the example at: https://kyverno.io/docs/kyverno-cli/#apply

Expected behavior

Successful policy evaluation.

Screenshots

See CLI outputs above.

Additional context

I downloaded the CLI binary release: https://github.com/kyverno/kyverno/releases/download/v1.3.1/kyverno-cli_v1.3.1_linux_x86_64.tar.gz and extracted to /usr/local/bin

I also built the binary from source per the instructions (this created: v1.3.2-rc1-8-gac3a42d4). The behaviour was the same as v1.3.1

@goffinf goffinf added the bug Something isn't working label Jan 31, 2021
@JimBugwadia JimBugwadia added this to the Kyverno Release 1.3.2 milestone Feb 1, 2021
@realshuting realshuting added the type:cli cli releated issue label Feb 2, 2021
vyankyGH pushed a commit that referenced this issue Feb 3, 2021
Signed-off-by: vyankatesh_neualto <vyankatesh@neualto.com>
@realshuting
Copy link
Member

Closing via #1518.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working type:cli cli releated issue
Projects
None yet
Development

No branches or pull requests

4 participants