Skip to content

Recreate listener Service when deleted#2387

Open
AryanP123 wants to merge 2 commits intoskupperproject:mainfrom
AryanP123:delete-service
Open

Recreate listener Service when deleted#2387
AryanP123 wants to merge 2 commits intoskupperproject:mainfrom
AryanP123:delete-service

Conversation

@AryanP123
Copy link
Contributor

Fixes #2383


func (s *Site) EnsureListenerService(listener *skupperv2alpha1.Listener) {
if listener != nil && s.site != nil {
s.bindings.ListenerUpdated(listener)
Copy link
Member

Choose a reason for hiding this comment

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

Calling ListenerUpdated results in query to api server (via Expose) which would be good to avoid if possible.

Suggest looking at updating CheckListenerService to handle the delete case (e.g. svc == nil) and possibly use isHostExposed to distinguish deletion due to listener deletion versus user deletion.

The question will be whether there is enough context available to re-create the user deleted service (E.g. could isHostExposed return ports, etc. If not, maybe storing what is needed in a site scoped cm that tracks the service lifecycle might be an alternative.

Copy link
Member

Choose a reason for hiding this comment

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

The HandleDeletedListenerService seems to be doing what is needed.
Is EnsureListenerService really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, you're right. Didn't notice the redundancy, will fix. Thanks!

@AryanP123 AryanP123 force-pushed the delete-service branch 2 times, most recently from 92edba4 to 6c45e69 Compare March 2, 2026 18:20
ctrl.eventProcessor.TestProcess()
}
deleteListenerService("mysvc", "test")(t, clients)
for !waitForService("mysvc", "test")(t, clients) {
Copy link
Member

Choose a reason for hiding this comment

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

Better to use a retry mechanism here (i.e.: internal/utils/retry.go).

if existing, ok := a.exposed[listener.Spec.Host]; ok {
exposed = existing
}
if exposed := a.exposed.Expose(listener.Spec.Host, port); exposed != nil {
Copy link
Member

Choose a reason for hiding this comment

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

The original code was only going to call context.Expose if a change is needed,
now it seems to be calling it either way. I see that the context.Expose has mechanisms
to detect if something has changed or not, but once it is called it tries to retrieve the latest
service from the kube api.
Did you find a reason to change this (sorry if it is obvious but I am not seeing it)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the only effect of the change is to recreate the Service earlier in the case where a Listener event is processed before the Service delete event, mainly added it as a defensive path during implementation. It does not add a path that’s required for correctness, the delete path (HandleDeletedListenerService) already guarantees recreation. Looking at it again, I do suppose this change here is unnecessary, so I can revert this. Thanks for pointing it out.

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.

Listener service should be re-created if deleted

3 participants