Skip to content

Changed code to report invalid host - #2544

Open
evanwang9x wants to merge 1 commit into
skupperproject:mainfrom
evanwang9x:Evan/fix-multilistener-ready
Open

Changed code to report invalid host#2544
evanwang9x wants to merge 1 commit into
skupperproject:mainfrom
evanwang9x:Evan/fix-multilistener-ready

Conversation

@evanwang9x

@evanwang9x evanwang9x commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Addresses #2542

Changed code to return an error instead of smoothing over it and having it only appearing in the control log

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling when listeners are created, updated, deleted, or exposed.
    • Invalid listener hostnames are now rejected with clear status errors.
    • Prevented services from being created for invalid host values.
    • Initialization and configuration failures are now surfaced instead of being silently ignored.
  • Tests

    • Added coverage for invalid hosts on standard and multi-key listeners.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b942a0ab-3645-4721-9748-d93394b9281d

📥 Commits

Reviewing files that changed from the base of the PR and between 56ff420 and e1ac8f6.

📒 Files selected for processing (7)
  • internal/kube/site/extended_bindings.go
  • internal/kube/site/ports.go
  • internal/kube/site/site.go
  • internal/kube/site/site_test.go
  • internal/site/bindings.go
  • internal/site/bindings_test.go
  • pkg/nonkube/api/site_state.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • pkg/nonkube/api/site_state.go
  • internal/kube/site/ports.go
  • internal/site/bindings_test.go
  • internal/kube/site/site_test.go
  • internal/kube/site/extended_bindings.go
  • internal/kube/site/site.go
  • internal/site/bindings.go

📝 Walkthrough

Walkthrough

Listener binding callbacks now propagate errors through site exposure and listener update flows. Exposed hosts are validated as DNS-1035 labels, and listener status reports validation or binding failures. Tests cover invalid listener and multi-key-listener hosts and prevent Service creation for invalid values.

Changes

Listener error propagation and host validation

Layer / File(s) Summary
Binding callback error contracts
internal/site/bindings.go, internal/site/bindings_test.go, pkg/nonkube/api/site_state.go
Listener callbacks and listener update methods now return errors, aggregate callback failures, and update implementations and callers for the new signatures.
Exposure validation and error propagation
internal/kube/site/ports.go, internal/kube/site/extended_bindings.go, internal/kube/site/site.go
Listener and multi-key-listener exposure paths validate hosts and return errors from port lookup, expose, unexpose, initialization, and binding updates.
Status handling and invalid-host coverage
internal/kube/site/site.go, internal/kube/site/site_test.go
Configured status now reflects host and binding errors, with tests covering invalid hosts and the absence of created Services.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Bindings
  participant ExtendedBindings
  participant HostValidation
  participant PortAllocator
  participant ExposeOperation
  participant ListenerStatus
  Bindings->>ExtendedBindings: update listener binding
  ExtendedBindings->>HostValidation: validate exposed host
  HostValidation-->>ExtendedBindings: validation result
  ExtendedBindings->>PortAllocator: allocate port
  PortAllocator-->>ExtendedBindings: port or error
  ExtendedBindings->>ExposeOperation: expose listener
  ExposeOperation-->>ExtendedBindings: configuration update or error
  ExtendedBindings-->>Bindings: return update and error
  Bindings-->>ListenerStatus: report binding error
Loading

Suggested reviewers: nluaces, aryanp123

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: reporting errors for invalid hosts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@evanwang9x
evanwang9x requested review from AryanP123 and Copilot and removed request for Copilot July 27, 2026 17:44

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/kube/site/site_test.go (1)

778-843: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Good targeted regression coverage for the PR's core fix.

Both new tests correctly assert the listener/MKL status reflects "Invalid host" and that no Service gets created. Consider also asserting that no router bridge/listener entry is created for the invalid host, since s.updateRouterConfig(update) currently still runs regardless of the validation error (see the related comment in internal/site/bindings.go).


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 04348bd8-003f-49e0-99cd-fcbfab2287ee

📥 Commits

Reviewing files that changed from the base of the PR and between 80b1ba6 and 56ff420.

📒 Files selected for processing (7)
  • internal/kube/site/extended_bindings.go
  • internal/kube/site/ports.go
  • internal/kube/site/site.go
  • internal/kube/site/site_test.go
  • internal/site/bindings.go
  • internal/site/bindings_test.go
  • pkg/nonkube/api/site_state.go

Comment thread internal/site/bindings.go

@fgiorgetti fgiorgetti left a comment

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.

It works great with both Listeners and MultiKeyListeners.
My only suggestion is to add the same host validation at the CLI level, when running skupper listener create or skupper listener generate.

@fgiorgetti

Copy link
Copy Markdown
Member

It works great with both Listeners and MultiKeyListeners. My only suggestion is to add the same host validation at the CLI level, when running skupper listener create or skupper listener generate.

But one thing to be cautions about it. On system sites (nonkube) the host can represent either a FQDN or an IP Address. So if we add such validation, it must be done exclusively to kubernetes sites. @nluaces @c-kruse thoughts?

@nluaces

nluaces commented Jul 30, 2026

Copy link
Copy Markdown
Member

But one thing to be cautions about it. On system sites (nonkube) the host can represent either a FQDN or an IP Address. So if we add such validation, it must be done exclusively to kubernetes sites.

It makes sense, currently the listener commands for create and generate in kubernetes platforms don't validate the hostname.

But there is already a host validation for the non-kube commands listener create/generate:

hostname: hostStringValidator.Evaluate(cmd.Flags.Host)
IP: net.ParseIP(cmd.Flags.Host)

(for the listener generate command the host validation is identical)

@c-kruse c-kruse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@evanwang9x want to give rebasing a try? Looks like we're on each other's toes. Doesn't look too bad, though.

For ExtendedBindings.init it is important that exposed and selectors don't get stomped on subsequent init calls. I think this should be fine:

	if a.exposed == nil {
		a.exposed = ExposedPorts{}
	}
	if a.selectors == nil {
		a.selectors = map[string]TargetSelection{}
	}
	err := a.bindings.SetBindingEventHandler(a)

For Site.setBindingsConfiguredStatus it looks to me like we've got yet another error to jam into that stderrors.Join. Now that I look at it, that's probably a bug in one of our implementations - I included the passed err and you ignore it (it was unused before my change.) I think we want to include it.

@evanwang9x
evanwang9x force-pushed the Evan/fix-multilistener-ready branch from 56ff420 to e1ac8f6 Compare August 4, 2026 17:08
@evanwang9x

Copy link
Copy Markdown
Contributor Author

Thanks Christian, I rebased it with your suggestion.

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