Changed code to report invalid host - #2544
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughListener 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. ChangesListener error propagation and host validation
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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/kube/site/site_test.go (1)
778-843: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGood 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 ininternal/site/bindings.go).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 04348bd8-003f-49e0-99cd-fcbfab2287ee
📒 Files selected for processing (7)
internal/kube/site/extended_bindings.gointernal/kube/site/ports.gointernal/kube/site/site.gointernal/kube/site/site_test.gointernal/site/bindings.gointernal/site/bindings_test.gopkg/nonkube/api/site_state.go
fgiorgetti
left a comment
There was a problem hiding this comment.
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? |
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: (for the listener generate command the host validation is identical) |
c-kruse
left a comment
There was a problem hiding this comment.
@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.
56ff420 to
e1ac8f6
Compare
|
Thanks Christian, I rebased it with your suggestion. |
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
Tests