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

bug(shutdown): Fix panic when webhooks are disabled #760

Merged

Conversation

zeeke
Copy link
Member

@zeeke zeeke commented Aug 21, 2024

When webooks are disabled, shutdown procedure produces the following panic error:

2024-08-13T12:45:04.971685297Z	INFO	shutdown	utils/shutdown.go:22	Done clearing finalizers on exit
2024-08-13T12:45:04.971713179Z	INFO	shutdown	utils/shutdown.go:23	Seting webhook failure policies to Ignore on exit
2024-08-13T12:45:04.978386488Z	ERROR	shutdown	utils/shutdown.go:64	Error getting webhook	{"error": "validatingwebhookconfigurations.admissionregistration.k8s.io \"sriov-operator-webhook-config\" not found"}
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils.updateValidatingWebhook(0x37d7788?)
	/go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils/shutdown.go:75 +0x198
github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils.updateWebhooks()
	/go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils/shutdown.go:64 +0xa5
github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils.Shutdown()
	/go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils/shutdown.go:23 +0x14
main.main()
	/go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/main.go:296 +0x1e6a

Fix the panic error and add an end2end test case to cover it.

When webooks are disabled, shutdown procedure produces the following
panic error:
```
2024-08-13T12:45:04.971685297Z	INFO	shutdown	utils/shutdown.go:22	Done clearing finalizers on exit
2024-08-13T12:45:04.971713179Z	INFO	shutdown	utils/shutdown.go:23	Seting webhook failure policies to Ignore on exit
2024-08-13T12:45:04.978386488Z	ERROR	shutdown	utils/shutdown.go:64	Error getting webhook	{"error": "validatingwebhookconfigurations.admissionregistration.k8s.io \"sriov-operator-webhook-config\" not found"}
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils.updateValidatingWebhook(0x37d7788?)
	/go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils/shutdown.go:75 +0x198
github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils.updateWebhooks()
	/go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils/shutdown.go:64 +0xa5
github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils.Shutdown()
	/go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils/shutdown.go:23 +0x14
main.main()
	/go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/main.go:296 +0x1e6a
```

Fix the panic error and add an end2end test case to cover it.

Signed-off-by: Andrea Panattoni <[email protected]>
Copy link

Thanks for your PR,
To run vendors CIs, Maintainers can use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs, Maintainers can use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 10487195141

Details

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.02%) to 44.976%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/utils/shutdown.go 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
controllers/drain_controller.go 3 67.1%
Totals Coverage Status
Change from base Build 10454628601: -0.02%
Covered Lines: 6530
Relevant Lines: 14519

💛 - Coveralls

@adrianchiris adrianchiris merged commit e1f5b74 into k8snetworkplumbingwg:master Aug 22, 2024
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants