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

Handle nil pointer in Lb delete #277

Conversation

shyamradhakrishnan
Copy link
Member

@shyamradhakrishnan shyamradhakrishnan commented Jun 1, 2023

What this PR does / why we need it:

Handle nil pointer in Lb backend delete. This happens when instance was created, but was not added to backend because the instance does not have IP address. Then when instance is deleted, we get the following stack trace.

panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0

goroutine 553 [running]:
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile.func1()
        /workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:118 +0x1f4
panic({0x1dd91a0, 0xc0001c0b10})
        /usr/local/go/src/runtime/panic.go:884 +0x212
github.com/oracle/cluster-api-provider-oci/cloud/scope.(*MachineScope).IP(...)
        /workspace/cloud/scope/machine.go:402
github.com/oracle/cluster-api-provider-oci/cloud/scope.(*MachineScope).ReconcileDeleteInstanceOnLB(0xc000a02280, {0x2236998, 0xc000ce69c0})
        /workspace/cloud/scope/machine.go:621 +0xf49
github.com/oracle/cluster-api-provider-oci/controllers.(*OCIMachineReconciler).deleteInstanceFromControlPlaneLB(0xc0003b4ff0, {0x2236998, 0xc000ce69c0}, 0xc000a02280)
        /workspace/controllers/ocimachine_controller.go:376 +0x85
github.com/oracle/cluster-api-provider-oci/controllers.(*OCIMachineReconciler).reconcileDelete(0xc0003b4ff0, {0x2236998, 0xc000ce69c0}, 0xc000a02280)
        /workspace/controllers/ocimachine_controller.go:324 +0x54d
github.com/oracle/cluster-api-provider-oci/controllers.(*OCIMachineReconciler).Reconcile(0xc0003b4ff0, {0x2236998, 0xc000ce69c0}, {{{0xc0007b2020?, 0x10?}, {0xc000f19d00?, 0x40db67?}}})
        /workspace/controllers/ocimachine_controller.go:161 +0xada
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0x22368f0?, {0x2236998?, 0xc000ce69c0?}, {{{0xc0007b2020?, 0x1e40220?}, {0xc000f19d00?, 0x4045d4?}}})
        /workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:121 +0xc8
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc000196820, {0x22368f0, 0xc00020b500}, {0x1cdf440?, 0xc0001bb340?})
        /workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:320 +0x33c
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc000196820, {0x22368f0, 0xc00020b500})
        /workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:273 +0x1d9
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
        /workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:234 +0x85
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2
        /workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:230 +0x333

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #275

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jun 1, 2023
@shyamradhakrishnan
Copy link
Member Author

e2e


Ran 6 of 25 Specs in 2610.524 seconds
SUCCESS! -- 6 Passed | 0 Failed | 0 Pending | 19 Skipped

@shyamradhakrishnan
Copy link
Member Author

unit test

?   	github.com/oracle/cluster-api-provider-oci	[no test files]
ok  	github.com/oracle/cluster-api-provider-oci/api/v1beta1	41.273s	coverage: 24.1% of statements
ok  	github.com/oracle/cluster-api-provider-oci/api/v1beta2	0.043s	coverage: 15.8% of statements
?   	github.com/oracle/cluster-api-provider-oci/cloud/config	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/metrics	[no test files]
ok  	github.com/oracle/cluster-api-provider-oci/cloud/ociutil	0.004s	coverage: 19.6% of statements
ok  	github.com/oracle/cluster-api-provider-oci/cloud/scope	241.278s	coverage: 76.3% of statements
?   	github.com/oracle/cluster-api-provider-oci/cloud/scope/mocks	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/base	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/base/mock_base	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/compute	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/compute/mock_compute	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/computemanagement	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/computemanagement/mock_computemanagement	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/containerengine	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/containerengine/mock_containerengine	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/identity	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/identity/mock_identity	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/loadbalancer	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/loadbalancer/mock_lb	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/networkloadbalancer	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/networkloadbalancer/mock_nlb	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/vcn	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/cloud/services/vcn/mock_vcn	[no test files]
ok  	github.com/oracle/cluster-api-provider-oci/cloud/util	0.128s	coverage: 76.1% of statements
ok  	github.com/oracle/cluster-api-provider-oci/controllers	26.128s	coverage: 67.5% of statements
ok  	github.com/oracle/cluster-api-provider-oci/exp/api/v1beta1	27.261s	coverage: 21.8% of statements
ok  	github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2	0.023s	coverage: 10.9% of statements
ok  	github.com/oracle/cluster-api-provider-oci/exp/controllers	1.095s	coverage: 56.3% of statements
?   	github.com/oracle/cluster-api-provider-oci/feature	[no test files]
?   	github.com/oracle/cluster-api-provider-oci/version	[no test files]

@shyamradhakrishnan shyamradhakrishnan self-assigned this Jun 1, 2023
@shyamradhakrishnan shyamradhakrishnan merged commit 764e32d into oracle:main Jun 1, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CAPOCI pod crash on exception
2 participants