Report Connector Status when host and selector are both missing#2517
Report Connector Status when host and selector are both missing#2517evanwang9x wants to merge 1 commit into
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 (2)
📝 WalkthroughWalkthroughSite.CheckConnector now validates that a connector's spec defines either host or selector, recording a spec error otherwise, and joins this error with existing TLS and router errors when updating the Configured status. Corresponding test cases and assertions were added/updated to verify this behavior. ChangesConnector Spec Validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
c-kruse
left a comment
There was a problem hiding this comment.
Looks good! Just a nit pick on the wording.
| ) | ||
| } | ||
| if connector.Spec.Host == "" && connector.Spec.Selector == "" { | ||
| specErr = stderrors.New("Connector must define either spec.host or spec.selector") |
There was a problem hiding this comment.
Suggest including "non-empty" as a qualifier here: Connector must define a non-empty spec.host or spec.selector. If anyone ever sees this message, they have already defined one of these fields.
As I'm sure you noticed when testing, the kubernetes API refuses an invalid Connector that does not satisfy a oneOf required selector or host.
$ cat << EOF | kubectl apply -f -
apiVersion: skupper.io/v2alpha1
kind: Connector
metadata:
name: invalid
spec:
port: 8888
routingKey: test
EOF
The Connector "invalid" is invalid:
* <nil>: Invalid value: "": "spec" must validate one and only one schema (oneOf). Found none valid
* spec.selector: Required value
$ cat << EOF | kubectl apply -f -
apiVersion: skupper.io/v2alpha1
kind: Connector
metadata:
name: invalid
spec:
port: 8888
routingKey: test
host: ""
selector: ""
EOF
The Connector "invalid" is invalid: <nil>: Invalid value: "": "spec" must validate one and only one schema (oneOf). Found 2 valid alternatives
To "trick" it you need to provide either host or selector with an empty string (really was a miss on our api spec side.) Because of how our go types were set up, we end up missing that distinction and can't easily plainly say "Invalid value for host|selector. Must not be empty".
There was a problem hiding this comment.
I see thanks for letting me know, I'll implement that change later today👍.
Closes #2512
Summary by CodeRabbit
Bug Fixes
Tests