-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
roachprod, roachtest: add grafana annotations API #120019
roachprod, roachtest: add grafana annotations API #120019
Conversation
Last commit can be dropped if we don't think the annotations are helpful there. It was more of a proof of concept + way to test that it actually works. Note: if you want to play around with it yourself, I've only added annotation queries to the sql dashboard so far. I played around with using I also found another edge case: if we run the same test multiple times using We could just not support these edge cases, but between:
The former seems like the less bad solution to me. So I opted to go with that, but I'm open to other's opinions though. For what it's worth, instead of directly passing |
2e20911
to
a3c8642
Compare
@@ -242,6 +243,13 @@ func (tr *testRunner) runSingleStep(ctx context.Context, ss *singleStep, l *logg | |||
defer func() { | |||
prefix := fmt.Sprintf("FINISHED [%s]", timeutil.Since(start)) | |||
tr.logStep(prefix, ss, l) | |||
annotation := fmt.Sprintf("(%d): %s", ss.ID, ss.impl.Description()) | |||
_, err := tr.cluster.AddGrafanaAnnotation(tr.ctx, tr.logger, false /*internal*/, grafana.AddAnnotationRequest{ |
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.
Nice! Do you have a screenshot of how this looks for the whole (test) run?
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's what follower-reads/mixed-version/single-region
looks like.
Not sure how soon the data gets GC, but the grafana link in case you see this before it does.
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 how soon the data gets GC, but the grafana link in case you see this before it does.
Thanks. By default annotations are kept forever [1], and we're using the default. I'll add the following settings to make sure we don't forget to GC,
[annotations.dashboard]
max_age = 3M
[annotations.api]
max_age = 3M
Nice work! I've only gone through the code and left a few minor comments. I'll play around with the annotations to get a better idea of the "look & feel". |
a3c8642
to
e381adf
Compare
92de6b2
to
2d54365
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.
Annotations look good to me! If need be, we can easily tweak things in subsequent PR(s). Let's give @renatolabs a chance to review the changes since it touches the mixedversion runner. Otherwise, 🚢
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.
Great work!
All my comments are ignorable nits.
2d54365
to
5200855
Compare
😞 Unfortunately adding a One easy solution would be to just wrap it in a |
fb9aa1a
to
69dff21
Compare
Yes, definitely an overkill. We've had to fix similar problems in the past; e.g., see how we mock the architecture for tests: cockroach/pkg/cmd/roachtest/roachtestutil/mixedversion/mixedversion.go Lines 624 to 630 in f2985c3
I kind of prefer having this type of behaviour encapsulated in a function rather than having func (r runner) addGrafanaAnnotation() {
if r._addAnnotation != nil {
r._addAnnotation(annotation) // test-only
return
}
r.cluster.AddGrafanaAnnotation(annotation)
} Needless to say, the above is pseudo-code to illustrate the idea. Does that make sense? You could then even inject your own annotation function in the test to validate the annotation we're sending. |
69dff21
to
8f227fa
Compare
Yes that makes perfect sense! Thank you! |
This change adds a Grafana annotation API for roachprod. It adds support to add annotations to a specified grafana instance. The Grafana OpenAPI is used to create an HTTP client and easily create requests.
AddGrafanaAnnotation allows roachtests to create grafana annotations. Roachtests can either add to the centralized Grafana instance that contains metrics for all GCE runs, or the internal Grafana instance created through cluster.StartGrafana. Depending on the instance chosen, AddGrafanaAnnotation will resolve the host name for the caller.
2c69b24
to
b14a2a0
Compare
Now that we have the ability to create grafana annotations in roachtests, we can annotate each mixed version step in grafana.
b14a2a0
to
b4994a9
Compare
CI is finally happy and confirmed it works on TC with the env variables. TFTRs! bors r=renatolabs, srosenberg |
Build succeeded: |
This change adds the ability to create Grafana annotations from both roachprod and roachtests. The API handles authentication as well as creating an HTTP client and request. See individual commits for more details.
Release note: none
Epic: none
Fixes: #119821