-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Misc. cleanups in hubble and monitor packages #14103
Misc. cleanups in hubble and monitor packages #14103
Conversation
It might contain a monitorAPI.AgentNotifyMessage as emitted by the *Message constructor funcs. Signed-off-by: Tobias Klauser <[email protected]>
2e3135e
to
63a64bd
Compare
test-me-please |
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 change with regard to newCompatFlow
is not strictly equivalent for l7.Decode
.
Previously, we had this (added comment for clarity):
flow := &pb.Flow{}
if err := p.l7.Decode(&logrecord, flow); err != nil { // l7.Decode sets `flow.Time` from logrecord.Timestamp
return nil, err
}
flow.Time = ts // flow.Time is overwritten here with monitorEvent.Timestamp
flow.NodeName = monitorEvent.NodeName
With your change:
flow := newCompatFlow(ts, monitorEvent.NodeName) // flow.Time is set from monitorEvent.Timestamp
if err := p.l7.Decode(&logrecord, flow); err != nil { // l7.Decode overwrites `flow.Time` from logrecord.Timestamp
return nil, err
}
Ultimately, I think these are equivalent. Did you actually verify?
Oh, you're right. I overlooked that cilium/pkg/hubble/monitor/consumer.go Lines 90 to 99 in 9d3bf0e
while cilium/pkg/proxy/logger/logger.go Lines 88 to 99 in 9d3bf0e
|
Correct godoc comments for type AgentNotifyMessage and func StartMessage to state the proper name. Signed-off-by: Tobias Klauser <[email protected]>
63a64bd
to
960e70e
Compare
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.
I'm curious how you discovered this bug. (I mean how it only popped up now)
From godoc on (t Time) String()
:
// The returned string is meant for debugging; for a stable serialized
// representation, use t.MarshalText, t.MarshalBinary, or t.Format
// with an explicit format string.
☝️ Referencing this fact in the commit message might be useful for future travellers. :)
I had a hunch this was not an isolated case, but a quick glance at the codebase doesn't reveal any other such occurrences. 😰
I discovered it in a test I wrote for the successive PR, where I'm decoding the
The commit message mentions https://golang.org/pkg/time/#Time.String already but I agree that copying that part will make things easier to understand. Will amend.
Yeah, I was worried too but a quick grep showed nothing on my side either. Though, it might also be very non-obvious, e.g. when using something like ts := time.Now()
fmt.Sprintf("%s", ts) which will also invoke |
time.Time.String() may include a monotonic clock reading, e.g. when t is time.Now() which is e.g. the case for the agent start timestamp. The godoc for time.Time.String [1] states: If the time has a monotonic clock reading, the returned string includes a final field "m=±<value>", where value is the monotonic clock reading formatted as a decimal number of seconds. [1] https://golang.org/pkg/time/#Time.String The format including the monotonic clock reading is hard to decode because there is no predefined format string in the stdlib time package. Also, the monotonic clock reading isn't really useful for the agent start timestamp, the walltime clock should be enough. Thus, format the timestamp string in RFC3339Nano format which can easily be decoded using time.Parse(time.RFC3339Nano, t), e.g in the hubble API parser. Signed-off-by: Tobias Klauser <[email protected]>
960e70e
to
ff6cd2b
Compare
Yup, that's true. Counterpoint: |
Is it me or is this a breaking change that was overlooked by the Go team? AFAIK, monotonic clock support was added in Go 1.9 which means that Go code compiled with Go < 1.9 would not suffer from this problem whereas with Go >= 1.9, the behavior of @tklauser About |
AFAIK the Go team doesn't consider the
Indeed, let's wait for their feedback and in case we decide that we want to set from |
test-me-please GKE cluster provisioning failure: https://jenkins.cilium.io/job/Cilium-PR-K8s-GKE/3344 |
retest-gke |
For some historical context: The Now for the question if The Unfortunately, the current implementation is probably buggy, because the So given these constraints, it it seems intentional that we do not populate As for why Ultimately, I think having two different timestamps (Flow.Time/StartAgent.Time="this is when the event actually happened" vs. GetFlowsResponse.Time="this is when the event was observed by Hubble") is probably more correct, we just have to communicate it clearly to the user that the filters act on the latter timestamp. |
retest-gke previous failure: https://jenkins.cilium.io/job/Cilium-PR-K8s-GKE/3358/ GKE provisioning failed |
retest-gke |
retest-gke GKE still failed to provisioning: https://jenkins.cilium.io/job/Cilium-PR-K8s-GKE/3377/ |
retest-gke |
Small godoc comment fixes and preparatory factoring for successive PRs. See individual commits for details.
The last commit might need closer inspection as I'm not sure whether this would break API: