-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Honor c8y.mqtt setting on tedge connect #2789
fix: Honor c8y.mqtt setting on tedge connect #2789
Conversation
Robot Results
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
b37d514
to
845a49e
Compare
// The configured `c8y.http` setting may have a port value specified, | ||
// but the incoming URL is less likely to have any port specified. | ||
// Hence just matching the host prefix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option was to change the C8yEndPoint::c8y_host
field into a HostPort
and just validate the host
part of it against the incoming host. But, that would be have been a huge change needing the generic port parameter <P>
to be added to C8yEndPoint
as well, since HostPort<P>
is generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The system test "tedge-agent should terminate on SIGINT while downloading file" is failing, because the url http://localhost/speedlimit/10MB
is erroneously rewritten http://127.0.0.1:8001/c8y/speedlimit/10MB
, preventing the download to start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found one thing I'm unsure of, otherwise LGTM
let url = Url::parse(url).ok()?; | ||
let url_host = url.domain()?; | ||
|
||
let (_, host) = url_host.split_once('.').unwrap_or((url_host, "")); | ||
let (_, c8y_host) = tenant_uri.split_once('.').unwrap(); | ||
let (_, c8y_host) = tenant_host.split_once('.').unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this unwrap
is safe. What's about a C8Y Edge tenant known only by its host name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is something that @reubenmiller and I were discussing in the morning and the conclusion was that this whole subdomain based check is fragile and must be replaced with a proper check that retrieves the real tenant URL behind any custom domain and validates the incoming URL against that. But, since that work is a bit more involved, we decided to create a separate issue for that, and just resolve the port aspect in this PR (keeping the existing fragile mechanism as-is for now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, let's go with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is ticket for the custom domain issue: #2804
In the mean time, I've just updated the unwrap logic to at least avoid a panic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
282bfb8
to
2fa7266
Compare
Proposed changes
c8y.mqtt
setting while establishing direct connection to c8y ontedge connect c8y
BridgeConfig
to useHostPort
instead of separate host and port settingsTypes of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments