Getting an error panic: runtime error: invalid memory address or nil pointer dereference

758 views
Skip to first unread message

Kishan Kumar

unread,
Nov 15, 2022, 7:04:03 AM11/15/22
to Operator Framework
/mnt/e/DMS/operator/nginx-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
/mnt/e/DMS/operator/nginx-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
go run ./main.go
I1115 16:26:54.266215    7904 request.go:601] Waited for 1.0416693s due to client-side throttling, not priority and fairness, request: GET:https://api.oc-prod.decisionsfirst.com:6443/apis/infinispan.org/v1?timeout=32s
1.668509818654929e+09   INFO    controller-runtime.metrics      Metrics server is starting to listen    {"addr": ":8080"}
1.6685098186594653e+09  INFO    setup   starting manager
1.6685098186604502e+09  INFO    Starting server {"kind": "health probe", "addr": "[::]:8081"}
1.668509818660458e+09   INFO    Starting server {"path": "/metrics", "kind": "metrics", "addr": "[::]:8080"}
1.6685098186607473e+09  INFO    Starting EventSource    {"controller": "nginx", "controllerGroup": "cache.example.com", "controllerKind": "Nginx", "source": "kind source: *v1alpha1.Nginx"}
1.6685098186608796e+09  INFO    Starting EventSource    {"controller": "nginx", "controllerGroup": "cache.example.com", "controllerKind": "Nginx", "source": "kind source: *v1.Deployment"}
1.6685098186609592e+09  INFO    Starting Controller     {"controller": "nginx", "controllerGroup": "cache.example.com", "controllerKind": "Nginx"}
1.6685098198639538e+09  INFO    Starting workers        {"controller": "nginx", "controllerGroup": "cache.example.com", "controllerKind": "Nginx", "worker count": 1}
1.6685098198643909e+09  INFO    Observed a panic in reconciler: runtime error: invalid memory address or nil pointer dereference        {"controller": "nginx", "controllerGroup": "cache.example.com", "controllerKind": "Nginx", "nginx": {"name":"nginx-sample","namespace":"nginx-operator"}, "namespace": "nginx-operator", "name": "nginx-sample", "reconcileID": "277d5868-80d7-4087-86c3-25975aff5951"}
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x1393697]

goroutine 581 [running]:
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile.func1()
        /home/kishan/go/pkg/mod/sigs.k8s.io/controlle...@v0.12.1/pkg/internal/controller/controller.go:118 +0x1f4
panic({0x14d18a0, 0x235fb80})
        /usr/lib/go-1.19/src/runtime/panic.go:884 +0x212
github.com/go-logr/logr.Logger.WithValues(...)
        /home/kishan/go/pkg/mod/github.com/go-logr/lo...@v1.2.0/logr.go:283
github.com/example/nginx-operator/controllers.(*NginxReconciler).Reconcile(0xc000411bf0, {0x18ce7d8, 0xc000862ba0}, {{{0xc0009bb670, 0xe}, {0xc0009bb660, 0xc}}})
        /mnt/e/DMS/operator/nginx-operator/controllers/nginx_controller.go:58 +0xf7
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0x18ce730?, {0x18ce7d8?, 0xc000862ba0?}, {{{0xc0009bb670?, 0x15d5c20?}, {0xc0009bb660?, 0x405014?}}})
        /home/kishan/go/pkg/mod/sigs.k8s.io/controlle...@v0.12.1/pkg/internal/controller/controller.go:121 +0xc8
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc000298320, {0x18ce730, 0xc000aa0c40}, {0x1522360?, 0xc000090000?})
        /home/kishan/go/pkg/mod/sigs.k8s.io/controlle...@v0.12.1/pkg/internal/controller/controller.go:320 +0x33c
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc000298320, {0x18ce730, 0xc000aa0c40})
        /home/kishan/go/pkg/mod/sigs.k8s.io/controlle...@v0.12.1/pkg/internal/controller/controller.go:273 +0x1d9
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
        /home/kishan/go/pkg/mod/sigs.k8s.io/controlle...@v0.12.1/pkg/internal/controller/controller.go:234 +0x85
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2
        /home/kishan/go/pkg/mod/sigs.k8s.io/controlle...@v0.12.1/pkg/internal/controller/controller.go:230 +0x333
exit status 2
make: *** [Makefile:117: run] Error 1


Thanks & Best Regard,
Kishan Kumar

Varsha Prasad Narsing

unread,
Nov 16, 2022, 12:36:43 PM11/16/22
to Kishan Kumar, Operator Framework
Hi Kishan Kumar,

This seems to be a segmentation error caused by null pointer. If your project is open source, can you share the project repository so that it will be easier to look into it. 

Also some pointers here:
- Looks like the nil pointer is occurring in your reconciler. I'd suggest taking a look at that piece of code carefully and verify if any variable that is declared is getting instantiated properly.
- Most of the time this error is caused when the logger is not instantiated properly when the reconciler starts. You can take a look at this issue (https://github.com/operator-framework/operator-sdk/issues/4966) to check if it is a similar case.

Hope this helps.

Thank you
Varsha


--
You received this message because you are subscribed to the Google Groups "Operator Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to operator-framew...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/operator-framework/c9ba5bbc-6f9d-48cf-a996-e5d6c4ebe923n%40googlegroups.com.


--
Varsha Prasad
Software Engineer
Operator SDK Team
Red Hat Inc. San Francisco
Reply all
Reply to author
Forward
0 new messages