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

Running kustomize build panics #4240

Closed
MikaelSmith opened this issue Oct 14, 2021 · 6 comments · Fixed by #4312
Closed

Running kustomize build panics #4240

MikaelSmith opened this issue Oct 14, 2021 · 6 comments · Fixed by #4312
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@MikaelSmith
Copy link
Contributor

MikaelSmith commented Oct 14, 2021

Describe the bug
Panic when building a project with an entry namespace: . kubectl apply doesn't complain about this, and it's hard to debug what causes it.

panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
sigs.k8s.io/kustomize/api/resmap.getNamespacesForRoleBinding(0xc000355270)
        sigs.k8s.io/kustomize/api@v0.10.0/resmap/reswrangler.go:439 +0x21b
sigs.k8s.io/kustomize/api/resmap.(*resWrangler).SubsetThatCouldBeReferencedByResource(0xc00000f500, 0x4735da0)
        sigs.k8s.io/kustomize/api@v0.10.0/resmap/reswrangler.go:399 +0x105
sigs.k8s.io/kustomize/api/internal/accumulator.(*nameReferenceTransformer).Transform(0xc000ac10f0, {0x475bbd0, 0xc00000f500})
        sigs.k8s.io/kustomize/api@v0.10.0/internal/accumulator/namereferencetransformer.go:55 +0xdc
sigs.k8s.io/kustomize/api/internal/accumulator.(*ResAccumulator).Transform(...)
        sigs.k8s.io/kustomize/api@v0.10.0/internal/accumulator/resaccumulator.go:142
sigs.k8s.io/kustomize/api/internal/accumulator.(*ResAccumulator).FixBackReferences(0xd0)
        sigs.k8s.io/kustomize/api@v0.10.0/internal/accumulator/resaccumulator.go:168 +0xc5
sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).makeCustomizedResMap(0xc0003860d0)
        sigs.k8s.io/kustomize/api@v0.10.0/internal/target/kusttarget.go:131 +0x6f
sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).MakeCustomizedResMap(...)
        sigs.k8s.io/kustomize/api@v0.10.0/internal/target/kusttarget.go:112
sigs.k8s.io/kustomize/api/krusty.(*Kustomizer).Run(0xc002327d98, {0x4755d60, 0x4b84ac8}, {0x7ffeefbff1b0, 0x1d})
        sigs.k8s.io/kustomize/api@v0.10.0/krusty/kustomizer.go:88 +0x39c
sigs.k8s.io/kustomize/kustomize/v4/commands/build.NewCmdBuild.func1(0xc000356580, {0xc000317900, 0x1, 0x1})
        sigs.k8s.io/kustomize/kustomize/v4/commands/build/build.go:80 +0x176
github.com/spf13/cobra.(*Command).execute(0xc000356580, {0xc0003178d0, 0x1, 0x1})
        github.com/spf13/cobra@v1.0.0/command.go:842 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000356000)
        github.com/spf13/cobra@v1.0.0/command.go:950 +0x3ad
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.0.0/command.go:887
main.main()
        sigs.k8s.io/kustomize/kustomize/v4/main.go:14 +0x1e

Resources

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: test
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: test
rules: []
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: test
subjects:
- kind: ServiceAccount
  name: test
  namespace:
roleRef:
  kind: Role
  name: test
  apiGroup: rbac.authorization.k8s.io

Kustomize version

{Version:kustomize/v4.4.0 GitCommit:63ec6bdb3d737a7c66901828c5743656c49b60e1 BuildDate:2021-09-27T16:13:36Z GoOs:darwin GoArch:amd64}

on macOS.

@MikaelSmith MikaelSmith added the kind/bug Categorizes issue or PR as related to a bug. label Oct 14, 2021
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Oct 14, 2021
@natasha41575
Copy link
Contributor

To clarify, is the resource stream you've provided the input to kustomize or the output? If it is the output, could you please provide the input?

If it is the input, I'm curious how does kubectl apply handle an empty namespace? Is it treated the same as default namespace?

@natasha41575 natasha41575 added the triage/needs-information Indicates an issue needs more information in order to work on it. label Oct 15, 2021
@MikaelSmith
Copy link
Contributor Author

It's the input, but I was paring down from several thousand lines of code and omitted the very basic kustomization.yaml associated with it.

I haven't checked what Kubernetes does with it. There's some templating that normally puts a string there, and just didn't in this particular case. So I haven't used it this way extensively. Just ended up hard to debug.

@KnVerey
Copy link
Contributor

KnVerey commented Oct 27, 2021

I was able to reproduce this. The input isn't valid, so we don't need to do anything fancy to accommodate it, but we definitely should not panic in this situation.

/triage accepted
/kind bug

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 27, 2021
@KnVerey
Copy link
Contributor

KnVerey commented Oct 27, 2021

/assign @m-Bilal

@k8s-ci-robot
Copy link
Contributor

@KnVerey: GitHub didn't allow me to assign the following users: m-Bilal.

Note that only kubernetes-sigs members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @m-Bilal

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@m-Bilal
Copy link
Member

m-Bilal commented Oct 27, 2021

/assign

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. triage/accepted Indicates an issue or PR is ready to be actively worked on. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants