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

Panic in reconcile loop and " Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: the server could not find the requested resource" #344

Closed
lukehoban opened this issue Oct 19, 2022 · 4 comments
Assignees
Labels
impact/panic This bug represents a panic or unexpected crash kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@lukehoban
Copy link
Contributor

I was running the example in #339, and when I updated the Stack resource to point to a new stackname (since I had used an invalid one initially), I saw this in logs.

E1019 04:36:47.002143       1 reflector.go:138] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: the server could not find the requested resource

Nothing else happened though, so I destroyed the app stack (the pulumi.com/v1/stack, Secret and source.toolkit.fluxcd.io/v1beta2/GitRpository resources). That led to this:

E1019 04:37:19.908322       1 reflector.go:138] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: the server could not find the requested resource
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x1659330]

goroutine 1098 [running]:
github.com/pulumi/pulumi-kubernetes-operator/pkg/controller/stack.(*ReconcileStack).Reconcile(0xc0009324b0, {0x1d8f7a0, 0xc0004c6de0}, {{{0xc0006b36b0?, 0x198d120?}, {0xc0006b36a0?, 0xc0006d9840?}}})
	/home/runner/work/pulumi-kubernetes-operator/pulumi-kubernetes-operator/pkg/controller/stack/stack_controller.go:462 +0x2770
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc000950000, {0x1d8f6f8, 0xc000895800}, {0x18eaca0?, 0xc00055c3e0?})
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:298 +0x303
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc000950000, {0x1d8f6f8, 0xc000895800})
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:253 +0x1d9
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:214 +0x85
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:210 +0x307
@lukehoban lukehoban added kind/bug Some behavior is incorrect or out of spec impact/panic This bug represents a panic or unexpected crash needs-triage Needs attention from the triage team labels Oct 19, 2022
@squaremo squaremo self-assigned this Oct 19, 2022
@squaremo
Copy link
Contributor

/home/runner/work/pulumi-kubernetes-operator/pulumi-kubernetes-operator/pkg/controller/stack/stack_controller.go:462

This line is after it should have bailed from not finding the resource; no wonder it's an NPE. I'll start with a test case to reproduce.

@squaremo
Copy link
Contributor

squaremo commented Oct 19, 2022

Thankfully, referring to an unknown group/kind doesn't cause an NPE (I just added a test case for that).

This is the line referred to in the crash log:

if instance.Status.LastUpdate != nil {
   if instance.Status.LastUpdate.LastSuccessfulCommit == currentCommit && !stack.ContinueResyncOnCommitMatch

I'm struggling to see how that line leads to an NPE given the condition immediately before it. stack is a shared.StackSpec rather than a pointer. (L462 in the branch with the example is a closing brace).

Ah! The field ContinueResyncOnCommitMatch is from the embedded *GitSource, and that is nil if none of its fields are set.

@squaremo
Copy link
Contributor

Fixed by #346.

@pulumi-bot pulumi-bot reopened this Oct 19, 2022
@pulumi-bot
Copy link
Contributor

Cannot close issue without required labels: resolution/

@squaremo squaremo added resolution/fixed This issue was fixed and removed needs-triage Needs attention from the triage team labels Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/panic This bug represents a panic or unexpected crash kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

3 participants