Repository navigation
traffic watch base functionality - #213
Conversation
- allow exp-middleware: in sandbox spec - support free revtuns
|
@scott-cotton, something that was making some noise on my mind for a while (and that I finally see it clear now) is the fact that the Because of that, I don’t see much value in running with I guess it might be worth digging deeper into this aspect of the devex, since it could imply some changes in the operator. |
Indeed metadata here is metadata about the request outside of any TCP payload: it's the extra stuff we know due to the middleware/traffic-manager system. That's clearly outside the kinds of things you mention, but also necessary and critically gives a request id and time and host. While I agree folks are likely to want more in metadata, I disagree that --meta-only is not useful. It shows when things happen to what hosts, live. For adding non-metadata in the sense of stuff in TCP payloads, I guess it should be possible to restrict to request headers, HTTP protocol info, and possibly the same for response headers and include info without needing to stream everything. However, I am unsure of what you are implying w.r.t. MVP and our timeline: as this observation is quite late in that regard I'm unsure of what to do in terms of that and this comment. |
| return nil | ||
| } | ||
|
|
||
| func safeClose(c chan struct{}) { |
There was a problem hiding this comment.
One question, with this we ensure that pending/enqueue requests are written to the file before closing?
There was a problem hiding this comment.
We can't in general ensure that because then It might never close, the file being a stream, and closing should always succeed.
Because of that, adding a more graceful shutdown would be complicated. In general the files will be written before ending the application. Between the low impact and the complexity of adding a stronger guarantee, this seems perhaps out of scope for MVP to me.
But I guess we could add a time limit for writing requests and responses to files and then wait for that. Just seems to be a lot of work for something that may never be a problem -- it seems ok to me to define the closing of a traffic watch as an interruption because at any rate the user cannot be aware of what was received until it is written, and so having closing distinguish between received and written requests doesn't seem to help much.
please see 414e20c This now depends on https://github.com/signadot/libconnect/pull/132 |
- output only meta jsons - log to stderr - fix a close race that was losing log messages sometimes
|
I have changed the output a bit and fixed a problem that led to some missing log messages in 3f28b91 |
|
Gitar automatically fixes CI failures and addresses comments starting with ⚙️ Options:
🔄 To revert changes, post a comment: * Gitar never force pushes to your branch |
- --short was not printing newlines - stderr log does non-json
There was a problem hiding this comment.
Here is another case:
$ signadot traffic watch --sandbox location-watch --short
{"middlewareRequestID":"5fb2035c","watchOptions":"+stream/+stream","when":"2025-10-09T13:24:49.632531329Z","normHost":"location.hotrod-devmesh.svc.cluster.local:8081","routingKey":"9h8zb3gwjq3f4","destWorkload":"Deployment/hotrod-devmesh/location","requestURI":"http://location.hotrod-devmesh.svc:8081/locations","method":"GET","proto":"HTTP/1.1","userAgent":"curl/8.5.0"}
{"middlewareRequestID":"8c9efeab","watchOptions":"+stream/+stream","when":"2025-10-09T13:24:49.929906615Z","normHost":"location.hotrod-devmesh.svc.cluster.local:8081","routingKey":"9h8zb3gwjq3f4","destWorkload":"Deployment/hotrod-devmesh/location","requestURI":"http://location.hotrod-devmesh.svc:8081/locations","method":"GET","proto":"HTTP/1.1","userAgent":"curl/8.5.0"}
I'm surprised to see "watchOptions":"+stream/+stream" when I specify --short. Going back to https://github.com/signadot/libconnect/pull/132#discussion_r2406002003, what's the value of having watchOptions as part of the metadata?.
There was a problem hiding this comment.
Yes, it is the watchOptions of the other side of traffic watch. I guess they could be elided when --short because one would never be surprised to not get some info. OTOH, it's more uniform to just always have the same fields. Personally I prefer keeping it uniform and certainly without behavior that appears to be a bug but isn't, like not getting a request message body when one has asked for it.
I suppose we could do a sort of `report the most restrictive watch options that applied'
seems awfully cosmetic to me and sufficient to have documentation of what the fields are that the user can refer to.
Doing that most restrictive thing would also complicate the documentation...
There was a problem hiding this comment.
Yes, it is the watchOptions of the other side of traffic watch. I guess they could be elided when --short because one would never be surprised to not get some info. OTOH, it's more uniform to just always have the same fields. Personally I prefer keeping it uniform and certainly without behavior that appears to be a bug but isn't, like not getting a request message body when one has asked for it.
I suppose we could do a sort of `report the most restrictive watch options that applied'
seems awfully cosmetic to me and sufficient to have documentation of what the fields are that the user can refer to.
Doing that most restrictive thing would also complicate the documentation...
There was a problem hiding this comment.
Mm, I see, there are two watch options, once for the producer and one for the consumer, the one displayed there is the producer one. This mental model makes it easier for me to understand it. I see value now on having that field (tough maybe a rename would make it more clear). Docs will help in clarify this too.
There was a problem hiding this comment.
I wonder if it would be better to group requests/responses by normHost on the file system.
Using a sandbox like this one:
$ signadot sandbox apply -f - <<EOF
name: hotrod-watch
spec:
cluster: test
virtual:
- name: location-watch
workload:
kind: Deployment
namespace: hotrod-devmesh
name: location
- name: route-watch
workload:
kind: Deployment
namespace: hotrod-devmesh
name: route
middleware:
- name: trafficwatch-client
match:
- workload: "*"
EOFWhen running a traffic watch, I get:
$ find /tmp/tw1
/tmp/tw1
/tmp/tw1/meta.jsons
/tmp/tw1/2c5a1679
/tmp/tw1/2c5a1679/meta.json
/tmp/tw1/2c5a1679/response
/tmp/tw1/2c5a1679/request
/tmp/tw1/2d4fa9c8
/tmp/tw1/2d4fa9c8/meta.json
/tmp/tw1/2d4fa9c8/response
/tmp/tw1/2d4fa9c8/request
/tmp/tw1/6de09246
/tmp/tw1/6de09246/meta.json
/tmp/tw1/6de09246/response
/tmp/tw1/6de09246/request
/tmp/tw1/30c0d6c5
/tmp/tw1/30c0d6c5/meta.json
/tmp/tw1/30c0d6c5/response
/tmp/tw1/30c0d6c5/request
/tmp/tw1/5fc8412b
/tmp/tw1/5fc8412b/meta.json
/tmp/tw1/5fc8412b/response
/tmp/tw1/5fc8412b/request
/tmp/tw1/4322a8cb
/tmp/tw1/4322a8cb/meta.json
/tmp/tw1/4322a8cb/response
/tmp/tw1/4322a8cb/request
...Producing something like below may be clearer (and it shouldn't affect any programmatic consumption of the output):
$ find /tmp/tw1
/tmp/tw1
/tmp/tw1/meta.jsons
/tmp/tw1/location.hotrod-devmesh.svc.cluster.local:8081
/tmp/tw1/location.hotrod-devmesh.svc.cluster.local:8081/68b10e07
/tmp/tw1/location.hotrod-devmesh.svc.cluster.local:8081/68b10e07/meta.json
/tmp/tw1/location.hotrod-devmesh.svc.cluster.local:8081/68b10e07/response
/tmp/tw1/location.hotrod-devmesh.svc.cluster.local:8081/68b10e07/request
/tmp/tw1/route.hotrod-devmesh.svc.cluster.local:8083
/tmp/tw1/route.hotrod-devmesh.svc.cluster.local:8083/2c5a1679
/tmp/tw1/route.hotrod-devmesh.svc.cluster.local:8083/2c5a1679/meta.json
/tmp/tw1/route.hotrod-devmesh.svc.cluster.local:8083/2c5a1679/response
/tmp/tw1/route.hotrod-devmesh.svc.cluster.local:8083/2c5a1679/request
...WDYT?
There was a problem hiding this comment.
I think it looks nicer but has some drawbacks too:
- less flat: harder to grep and the like
- norm host may change, either the resolved one due to a change in services or our def of it
I was thinking of an all-in-1 yaml format and the possibility of tooling on top of some structure, like building an html to make things more visually appealing.
Not sure that those future hypotheticals would benefit.
There was a problem hiding this comment.
Yes... I'm not sure.
I agree having some tooling on top of the flat struct would help (and in a way I like the flat struct), but for the average case, maybe it's better to have the 2-level struct.
@foxish, do you have any opinion on this? (I would say I'm 60% in favor of the 2-level struct).
There was a problem hiding this comment.
I expect most users will consume it interactively, so, as long as there's some option that doesn't write any files, I'm ok with anything. For the output format, I do agree the 2 levels of grouping does make it easier to parse - but I don't feel strongly here.
There was a problem hiding this comment.
I expect most users will consume it interactively, as long as there's some option that doesn't write any files
Well.. I'm not sure I agree with this, otherwise it's just like looking at an access log (which is a good thing to have, but nobody will use signadot just for that). IMO, the main use case is the one that write files, and the one that will be used the most (files could be body-less or the full req/resp).
depends on https://github.com/signadot/libconnect/pull/131 and https://github.com/signadot/signadot/pull/6249
TODO probably on stacked PR(s):
middleware:changesBut, hey, it works! tested locally in various scenarios:
--meta-onlyand not