controller-tools icon indicating copy to clipboard operation
controller-tools copied to clipboard

controller-gen crashes in structToSchema

Open Porges opened this issue 4 years ago • 23 comments

If RawSpec is not set on the schemaContext’s info *markers.TypeInfo member, then structToSchema will crash here.

I think the fix is probably that:

if ctx.info.RawSpec.Type != structType {

Should become:

if ctx.info.RawSpec == nil || ctx.info.RawSpec.Type != structType {

Another option is that RawSpec should be preserved every time a new context is created with ctx.ForInfo.

Example stacktrace:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xab448c]

goroutine 1 [running]:
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc008d5e5a0, 0xc008b82be0, 0xc004b16fe0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:322 +0x9c
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc008d5e5a0, 0xe03480, 0xc008b82be0, 0x4f0e88)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:164 +0x374
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc008d5e5a0, 0xe03440, 0xc008b82c00, 0x1f)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:162 +0x32a
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc004b17638, 0xc008b83e20, 0x0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:375 +0x484
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc004b17638, 0xe03480, 0xc008b83e20, 0x0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:164 +0x374
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:107
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc0001840f0, 0xc0001dc260, 0xc007b5fe80, 0x1a)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:174 +0x321
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc008d5e510, 0x0, 0x0, 0xc007b5fe80, 0x1a)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:99 +0x9e
sigs.k8s.io/controller-tools/pkg/crd.localNamedToSchema(0xc008d5e510, 0xc008b82480, 0x0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:220 +0x1b4
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc008d5e510, 0xe03040, 0xc008b82480, 0x1f)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:154 +0x194
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc004b18030, 0xc008b82560, 0x0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:375 +0x484
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc004b18030, 0xe03480, 0xc008b82560, 0x0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:164 +0x374
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:107
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc0001840f0, 0xc0001dc260, 0xc007b5fcc0, 0x14)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:174 +0x321
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc008d5e420, 0x0, 0x0, 0xc007b5fcc0, 0x14)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:99 +0x9e
sigs.k8s.io/controller-tools/pkg/crd.localNamedToSchema(0xc008d5e420, 0xc008b82720, 0x0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:220 +0x1b4
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc008d5e420, 0xe03040, 0xc008b82720, 0x1f)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:154 +0x194
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc004b18a28, 0xc008b82780, 0x0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:375 +0x484
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc004b18a28, 0xe03480, 0xc008b82780, 0x0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:164 +0x374
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:107
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc0001840f0, 0xc0001dc260, 0xc007b747e0, 0x10)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:174 +0x321
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedFlattenedSchemaFor(0xc0001840f0, 0xc0001dc260, 0xc007b747e0, 0x10)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:186 +0xd8
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedCRDFor(0xc0001840f0, 0xc008c0438e, 0x2a, 0xc007b747e0, 0x10, 0x0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/spec.go:85 +0x60e
sigs.k8s.io/controller-tools/pkg/crd.Generator.Generate(0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0001840a0, 0xdf32c0, 0xdf32c0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/gen.go:108 +0x35b
sigs.k8s.io/controller-tools/pkg/genall.(*Runtime).Run(0xc000b53200, 0xc000252ed0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/genall/genall.go:171 +0x15e
main.main.func1(0xc000171b80, 0xc000252ed0, 0x3, 0x3, 0x0, 0x0)
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/cmd/controller-gen/main.go:176 +0xa6
github.com/spf13/cobra.(*Command).execute(0xc000171b80, 0xc0000320d0, 0x3, 0x3, 0xc000171b80, 0xc0000320d0)
        /home/george/go/pkg/mod/github.com/spf13/[email protected]/command.go:826 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0xc000171b80, 0xc0002502c0, 0x4, 0x0)
        /home/george/go/pkg/mod/github.com/spf13/[email protected]/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
        /home/george/go/pkg/mod/github.com/spf13/[email protected]/command.go:864
main.main()
        /home/george/go/pkg/mod/sigs.k8s.io/[email protected]/cmd/controller-gen/main.go:200 +0x34a

Porges avatar May 21 '20 02:05 Porges

/kind bug

Porges avatar May 25 '20 03:05 Porges

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Aug 23 '20 03:08 fejta-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot avatar Sep 22 '20 04:09 fejta-bot

/remove-lifecycle rotten

What is the version used by you? We ewould need to check it with the latest one to know if it is solved or not already.

camilamacedo86 avatar Sep 22 '20 10:09 camilamacedo86

I’m not sure what version this was. The way to reproduce it was to have a field with a struct type inline instead of named:

type Outer struct {
    Inner struct {
        X int
    }
}

Instead of:

type Outer struct {
    Inner InnerType
}

type InnerType struct {
    X int
}

Porges avatar Sep 23 '20 23:09 Porges

Inline struct type crashes latest controller-gen as of Oct-30:

sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc000f6b9b0, 0xc0002b0340, 0x0)
	/Users/arkadi/Work/go/src/sigs.k8s.io/controller-tools/pkg/crd/schema.go:328 +0x9c
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc000f6b9b0, 0x1a25f40, 0xc0002b0340, 0x0)
	/Users/arkadi/Work/go/src/sigs.k8s.io/controller-tools/pkg/crd/schema.go:168 +0x354

arkadijs avatar Oct 30 '20 15:10 arkadijs

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Jan 28 '21 15:01 fejta-bot

stop that bot!

/remove-lifecycle stale

Porges avatar Jan 28 '21 21:01 Porges

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale

fejta-bot avatar Apr 28 '21 22:04 fejta-bot

hold your horses

/remove-lifecycle stale

Porges avatar Apr 28 '21 22:04 Porges

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale

k8s-triage-robot avatar Jul 27 '21 23:07 k8s-triage-robot

slow thyself

/remove-lifecycle stale

Porges avatar Jul 27 '21 23:07 Porges

same here

killwing avatar Aug 14 '21 13:08 killwing

Is there any workaround for this?

benbooth493 avatar Sep 23 '21 07:09 benbooth493

@benbooth493 Is there any workaround for this?

Don’t use inline struct types, name every struct type like in https://github.com/kubernetes-sigs/controller-tools/issues/442#issuecomment-698017299

Porges avatar Sep 23 '21 07:09 Porges

@Porges I am trying to add https://github.com/solo-io/solo-apis/blob/6c6820ee9fd480a5092f76a02c29efc3aa34f858/pkg/api/gloo.solo.io/v1/options.pb.go#L459

type MyCRD struct {
        Options *v1.VirtualHostOptions `json:"options,omitempty"`
}

This results in:

/Users/ben.booth/code/getndazn/gateway-operator/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x16a812b]

goroutine 1 [running]:
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedPackage(0xc000d34000, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:231 +0x6b
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc000d34000, 0x0, 0xc001969330, 0x6)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:164 +0x65
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc0046be550, 0xc000328ae0, 0x2f, 0xc001969330, 0x6)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:103 +0x9d
sigs.k8s.io/controller-tools/pkg/crd.namedToSchema(0xc0046be550, 0xc000622b88, 0xc0046be470)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:241 +0x2b8
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046be550, 0x19cef40, 0xc000622b88, 0xc005f4a0c0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:160 +0x2c5
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046be550, 0x19cefd0, 0xc000622ba0, 0x19c5360)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:166 +0x325
sigs.k8s.io/controller-tools/pkg/crd.mapToSchema(0xc003e590b0, 0xc00064c240, 0x30)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:305 +0x756
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc003e590b0, 0x19cee50, 0xc00064c240, 0x1f)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:164 +0x278
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc0046bec70, 0xc000622bb8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:381 +0x479
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046bec70, 0x19cf000, 0xc000622bb8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:168 +0x36e
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:111
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc000d34000, 0xc000088fc0, 0xc000518750, 0xa)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:187 +0x33b
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc003e58fc0, 0x0, 0x0, 0xc000518750, 0xa)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:103 +0x9d
sigs.k8s.io/controller-tools/pkg/crd.localNamedToSchema(0xc003e58fc0, 0xc000e83d80, 0xc000de1ac5)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:224 +0x1bf
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc003e58fc0, 0x19cecd0, 0xc000e83d80, 0xc003e58fc0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:158 +0x8b
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc003e58fc0, 0x19cefd0, 0xc000e8a468, 0x1f)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:166 +0x325
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc0046bf6b0, 0xc000e8aca8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:381 +0x479
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046bf6b0, 0x19cf000, 0xc000e8aca8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:168 +0x36e
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:111
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc000d34000, 0xc000088fc0, 0xc000392a38, 0x12)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:187 +0x33b
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc0026d8540, 0xc000f06840, 0x34, 0xc000392a38, 0x12)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:103 +0x9d
sigs.k8s.io/controller-tools/pkg/crd.namedToSchema(0xc0026d8540, 0xc000d9a468, 0xc0014022a7)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:241 +0x2b8
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0026d8540, 0x19cef40, 0xc000d9a468, 0xc0026d8540)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:160 +0x2c5
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0026d8540, 0x19cefd0, 0xc000d9a480, 0x1f)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:166 +0x325
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc0046c00d8, 0xc000d9a498, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:381 +0x479
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046c00d8, 0x19cf000, 0xc000d9a498, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:168 +0x36e
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:111
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc000d34000, 0xc0014380a0, 0xc0010261d0, 0xf)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:187 +0x33b
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc0021fdc20, 0x0, 0x0, 0xc0010261d0, 0xf)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:103 +0x9d
sigs.k8s.io/controller-tools/pkg/crd.localNamedToSchema(0xc0021fdc20, 0xc001032c60, 0x30)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:224 +0x1bf
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0021fdc20, 0x19cecd0, 0xc001032c60, 0x1f)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:158 +0x8b
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc0046c0aa0, 0xc000d9a5e8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:381 +0x479
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046c0aa0, 0x19cf000, 0xc000d9a5e8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:168 +0x36e
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:111
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc000d34000, 0xc0014380a0, 0xc001026230, 0xb)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:187 +0x33b
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedFlattenedSchemaFor(0xc000d34000, 0xc0014380a0, 0xc001026230, 0xb)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:199 +0xde
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedCRDFor(0xc000d34000, 0xc00140204d, 0xf, 0xc001026230, 0xb, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/spec.go:85 +0x62c
sigs.k8s.io/controller-tools/pkg/crd.Generator.Generate(0x1, 0xc000206118, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc00009e140, 0x1, 0xc000780000)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/gen.go:128 +0x3af
sigs.k8s.io/controller-tools/pkg/genall.(*Runtime).Run(0xc00143a100, 0xc00009ff40)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/genall/genall.go:207 +0x1b7
main.main.func1(0xc00020a000, 0xc00009ff40, 0x5, 0x5, 0x0, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/cmd/controller-gen/main.go:176 +0xba
github.com/spf13/cobra.(*Command).execute(0xc00020a000, 0xc000032250, 0x5, 0x5, 0xc00020a000, 0xc000032250)
        /Users/ben.booth/go/pkg/mod/github.com/spf13/[email protected]/command.go:842 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc00020a000, 0xc00000e978, 0x4, 0x0)
        /Users/ben.booth/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/ben.booth/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main()
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/cmd/controller-gen/main.go:200 +0x346
make: *** [Makefile:44: manifests] Error 2

I'm really at a loss, I can't even re-implement the external type as it contains many interfaces that also cause a panic.

benbooth493 avatar Sep 23 '21 09:09 benbooth493

I suspect that your approach needs re-evaluation. Hard to tell about your project specifics, yet...

I, as a Kubernetes Operator developer, publish CRD which is my own type. I do not publish external (nested) types.

While the desire to reuse third-party API definitions as opaque pass-thru objects in the operator is understandable and might work, I would step back once again to review the decision.

arkadijs avatar Sep 23 '21 19:09 arkadijs

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Dec 22 '21 19:12 k8s-triage-robot

/remove-lifecycle stale

arkadijs avatar Dec 22 '21 20:12 arkadijs

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Mar 22 '22 20:03 k8s-triage-robot

/remove-lifecycle stale

arkadijs avatar Mar 29 '22 10:03 arkadijs

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jun 27 '22 11:06 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Jul 27 '22 12:07 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

k8s-triage-robot avatar Aug 26 '22 12:08 k8s-triage-robot

@k8s-triage-robot: Closing this issue.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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.

k8s-ci-robot avatar Aug 26 '22 12:08 k8s-ci-robot

@Porges I am trying to add https://github.com/solo-io/solo-apis/blob/6c6820ee9fd480a5092f76a02c29efc3aa34f858/pkg/api/gloo.solo.io/v1/options.pb.go#L459

type MyCRD struct {
        Options *v1.VirtualHostOptions `json:"options,omitempty"`
}

This results in:

/Users/ben.booth/code/getndazn/gateway-operator/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x16a812b]

goroutine 1 [running]:
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedPackage(0xc000d34000, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:231 +0x6b
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc000d34000, 0x0, 0xc001969330, 0x6)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:164 +0x65
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc0046be550, 0xc000328ae0, 0x2f, 0xc001969330, 0x6)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:103 +0x9d
sigs.k8s.io/controller-tools/pkg/crd.namedToSchema(0xc0046be550, 0xc000622b88, 0xc0046be470)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:241 +0x2b8
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046be550, 0x19cef40, 0xc000622b88, 0xc005f4a0c0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:160 +0x2c5
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046be550, 0x19cefd0, 0xc000622ba0, 0x19c5360)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:166 +0x325
sigs.k8s.io/controller-tools/pkg/crd.mapToSchema(0xc003e590b0, 0xc00064c240, 0x30)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:305 +0x756
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc003e590b0, 0x19cee50, 0xc00064c240, 0x1f)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:164 +0x278
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc0046bec70, 0xc000622bb8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:381 +0x479
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046bec70, 0x19cf000, 0xc000622bb8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:168 +0x36e
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:111
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc000d34000, 0xc000088fc0, 0xc000518750, 0xa)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:187 +0x33b
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc003e58fc0, 0x0, 0x0, 0xc000518750, 0xa)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:103 +0x9d
sigs.k8s.io/controller-tools/pkg/crd.localNamedToSchema(0xc003e58fc0, 0xc000e83d80, 0xc000de1ac5)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:224 +0x1bf
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc003e58fc0, 0x19cecd0, 0xc000e83d80, 0xc003e58fc0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:158 +0x8b
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc003e58fc0, 0x19cefd0, 0xc000e8a468, 0x1f)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:166 +0x325
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc0046bf6b0, 0xc000e8aca8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:381 +0x479
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046bf6b0, 0x19cf000, 0xc000e8aca8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:168 +0x36e
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:111
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc000d34000, 0xc000088fc0, 0xc000392a38, 0x12)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:187 +0x33b
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc0026d8540, 0xc000f06840, 0x34, 0xc000392a38, 0x12)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:103 +0x9d
sigs.k8s.io/controller-tools/pkg/crd.namedToSchema(0xc0026d8540, 0xc000d9a468, 0xc0014022a7)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:241 +0x2b8
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0026d8540, 0x19cef40, 0xc000d9a468, 0xc0026d8540)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:160 +0x2c5
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0026d8540, 0x19cefd0, 0xc000d9a480, 0x1f)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:166 +0x325
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc0046c00d8, 0xc000d9a498, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:381 +0x479
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046c00d8, 0x19cf000, 0xc000d9a498, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:168 +0x36e
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:111
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc000d34000, 0xc0014380a0, 0xc0010261d0, 0xf)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:187 +0x33b
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc0021fdc20, 0x0, 0x0, 0xc0010261d0, 0xf)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:103 +0x9d
sigs.k8s.io/controller-tools/pkg/crd.localNamedToSchema(0xc0021fdc20, 0xc001032c60, 0x30)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:224 +0x1bf
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0021fdc20, 0x19cecd0, 0xc001032c60, 0x1f)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:158 +0x8b
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc0046c0aa0, 0xc000d9a5e8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:381 +0x479
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc0046c0aa0, 0x19cf000, 0xc000d9a5e8, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:168 +0x36e
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(...)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema.go:111
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc000d34000, 0xc0014380a0, 0xc001026230, 0xb)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:187 +0x33b
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedFlattenedSchemaFor(0xc000d34000, 0xc0014380a0, 0xc001026230, 0xb)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:199 +0xde
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedCRDFor(0xc000d34000, 0xc00140204d, 0xf, 0xc001026230, 0xb, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/spec.go:85 +0x62c
sigs.k8s.io/controller-tools/pkg/crd.Generator.Generate(0x1, 0xc000206118, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc00009e140, 0x1, 0xc000780000)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/gen.go:128 +0x3af
sigs.k8s.io/controller-tools/pkg/genall.(*Runtime).Run(0xc00143a100, 0xc00009ff40)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/genall/genall.go:207 +0x1b7
main.main.func1(0xc00020a000, 0xc00009ff40, 0x5, 0x5, 0x0, 0x0)
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/cmd/controller-gen/main.go:176 +0xba
github.com/spf13/cobra.(*Command).execute(0xc00020a000, 0xc000032250, 0x5, 0x5, 0xc00020a000, 0xc000032250)
        /Users/ben.booth/go/pkg/mod/github.com/spf13/[email protected]/command.go:842 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc00020a000, 0xc00000e978, 0x4, 0x0)
        /Users/ben.booth/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/ben.booth/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main()
        /Users/ben.booth/go/pkg/mod/sigs.k8s.io/[email protected]/cmd/controller-gen/main.go:200 +0x346
make: *** [Makefile:44: manifests] Error 2

I'm really at a loss, I can't even re-implement the external type as it contains many interfaces that also cause a panic.

Same problem.Any solution? /remove-lifecycle stale

ktalg avatar Jan 03 '23 11:01 ktalg

/remove-lifecycle stale

ktalg avatar Jan 03 '23 11:01 ktalg