Skip to content

Fix a bug in deletion of webhook service for replacement #2606

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/controller/install/certresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (i *StrategyDeploymentInstaller) installCertRequirementsForDeployment(deplo

// Delete the Service to replace
deleteErr := i.strategyClient.GetOpClient().DeleteService(service.GetNamespace(), service.GetName(), &metav1.DeleteOptions{})
if err != nil && !k8serrors.IsNotFound(deleteErr) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like something that should have been picked up by unit testing. Would it be a lot of effort to add a test?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since e2e is green, let's merge and put the unit test in a follow up PR. Would that work for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although I'm not sure how can we check this particular case in a unit test, in which the service could not be deleted and therefore the installCertRequirementsForDeployment method returns an error.
I assume we'll need to use:

mockOpClient.EXPECT().DeleteService(namespace, "test-service", &metav1.DeleteOptions{}).Return(fmt.Errorf("could not delete existing service test-service"))

But not quite sure how to proceed.

if deleteErr != nil && !k8serrors.IsNotFound(deleteErr) {
return nil, nil, fmt.Errorf("could not delete existing service %s", service.GetName())
}
}
Expand Down