Skip to content

Recreate listener Service when deleted#2387

Merged
AryanP123 merged 2 commits intoskupperproject:mainfrom
AryanP123:delete-service
Apr 2, 2026
Merged

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

Conversation

@AryanP123
Copy link
Copy Markdown
Contributor

Fixes #2383

Comment thread internal/kube/site/site.go Outdated

func (s *Site) EnsureListenerService(listener *skupperv2alpha1.Listener) {
if listener != nil && s.site != nil {
s.bindings.ListenerUpdated(listener)
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@fgiorgetti fgiorgetti self-requested a review April 1, 2026 14:29
fgiorgetti

This comment was marked as off-topic.

@AryanP123 AryanP123 requested a review from ajssmith April 1, 2026 18:10
@fgiorgetti fgiorgetti self-requested a review April 1, 2026 18:39
@fgiorgetti fgiorgetti dismissed their stale review April 1, 2026 18:40

I will review it again.

Copy link
Copy Markdown
Member

@fgiorgetti fgiorgetti left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@ajssmith ajssmith left a comment

Choose a reason for hiding this comment

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

lgtm, thank you

@AryanP123 AryanP123 merged commit 4507dd2 into skupperproject:main Apr 2, 2026
2 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.

Listener service should be re-created if deleted

3 participants