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

Fix: unused ingress resources cleanup for external listeners #954

Merged
merged 8 commits into from
Mar 30, 2023

Conversation

bartam1
Copy link
Contributor

@bartam1 bartam1 commented Mar 22, 2023

Q A
Bug fix? yes
New feature? no
API breaks? no
Deprecations? no
License Apache 2.0

What's in this PR?

Removing unused ingress resources (nodePort services, istio ingress, envoy ingress) for external listeners

Why?

Koperator uses envoy as the ingress controller by default. When the users want to expose their Kafka brokers via LoadBalancer, the Koperator deploys these necessary resources: . But it doesn’t seem to remove these resources when they are not needed, for example, the users switch from LoadBalancer to NodePort. Moreover, the brokers are still reachable via the stale loadbalancer service. Same applies when changing from NodePort to LoadBalancer and from istioingress ingresscontroller to envoy ingress controller and vice-versa.

Additional context

Checklist

  • Implementation tested
  • Error handling code meets the guideline
  • Logging code meets the guideline

@bartam1 bartam1 requested a review from a team as a code owner March 22, 2023 13:05
Copy link
Contributor

@Kuvesz Kuvesz left a comment

Choose a reason for hiding this comment

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

Nothing major really from me, though I'm no expert on this.

pkg/resources/envoy/envoy.go Outdated Show resolved Hide resolved
Comment on lines +95 to +92
for _, res := range externalListenerResources {
o := res(log, eListener, ingressConfig, name, defaultControllerName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming here is once again a bit hard to understand with res and o.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is from the previous state of the repo.

Copy link
Contributor

@Kuvesz Kuvesz Mar 28, 2023

Choose a reason for hiding this comment

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

I know, it's more of a comment that I don't think it's the greatest naming scheme ever. :D
You don't need to change it (my approval doesn't depend on it at all), it just would be nicer I think.

pkg/resources/envoy/envoy.go Outdated Show resolved Hide resolved
pkg/resources/envoy/envoy.go Show resolved Hide resolved
pkg/resources/envoy/envoy.go Outdated Show resolved Hide resolved
pkg/resources/envoy/envoy.go Outdated Show resolved Hide resolved
pkg/resources/istioingress/istioingress.go Outdated Show resolved Hide resolved
pkg/resources/istioingress/istioingress.go Show resolved Hide resolved
pkg/resources/istioingress/istioingress.go Outdated Show resolved Hide resolved
pkg/resources/istioingress/istioingress.go Outdated Show resolved Hide resolved
pregnor
pregnor previously approved these changes Mar 28, 2023
Comment on lines +143 to +149
deletionCounter++
}
}
if deletionCounter > 0 {
log.Info(fmt.Sprintf("Removed '%d' resources for envoy ingress", deletionCounter))
}
Copy link
Member

Choose a reason for hiding this comment

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

Question: Wouldn't it be better to put a log message in the place of deleteCounter++ stating deleted envoy ingress resource %s where %s is the name of the object?
This way we will see removed 5 resources for envoy ingress, not sure if that is more useful than seeing removed resources for envoy ingress vs. the more informative listing of removed resources.
I can be convinced we don't need the resource level info, just curious.

Same for the Istio version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then it would be 5 remove message in case envoy. I think it is a good idea to do this with lower log level like: log.V(1).Info(...) What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think this one line would be great for info and maybe we could add a debug level message for the individual resources.

Kuvesz
Kuvesz previously approved these changes Mar 28, 2023
Copy link
Contributor

@Kuvesz Kuvesz left a comment

Choose a reason for hiding this comment

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

I'm still not too keen on some of these EListener shorhands but I wouldn't block the PR on that. Otherwise all looks good to me!

@bartam1 bartam1 dismissed stale reviews from Kuvesz and pregnor via 90ca970 March 29, 2023 08:51
pregnor
pregnor previously approved these changes Mar 29, 2023
pkg/resources/istioingress/istioingress.go Outdated Show resolved Hide resolved
@bartam1
Copy link
Contributor Author

bartam1 commented Mar 29, 2023

I'm still not too keen on some of these EListener shorhands but I wouldn't block the PR on that. Otherwise all looks good to me!
In the half of the codebase eListener is used and the otherhalf externalListener

Kuvesz
Kuvesz previously approved these changes Mar 29, 2023
@bartam1 bartam1 force-pushed the fix_remove_unused_externel_res branch from d90d972 to 2ce938d Compare March 29, 2023 15:04
@bartam1 bartam1 merged commit 12af3cd into master Mar 30, 2023
@bartam1 bartam1 deleted the fix_remove_unused_externel_res branch March 30, 2023 12:33
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.

3 participants