Skip to content

ci: add tracing support to integration tests. - #2440

Merged
samalba merged 4 commits into
dagger:mainfrom
sipsma:ci-tracing
May 13, 2022
Merged

samalba merged 4 commits into
dagger:mainfrom
sipsma:ci-tracing

Conversation

@sipsma

@sipsma sipsma commented May 12, 2022

Copy link
Copy Markdown
Contributor

This sets up Jaeger to run inside GHA during integration tests,
instruments dagger and buildkit to write to it and exports the resulting
data as an artifact of the run.

This enables us to get insight into what actually happened during our CI
runs, which is helpful for debugging and getting insight into the
performance of caching.

Jaeger seems to be mostly designed for "live" use, but it has an
experimental mode for persisting its data to disk, which I use here to
enable exporting it.

This is not a completely ideal solution. It requires setting up Buildkit
and Jaeger in docker separate from our actual test run. The much better
solution will be to use async #Start and #Stop tasks to run at least
Jaeger (and probably Buildkit itself too). This will allows us to
dogfood our own features and also open the interesting possibility of
making it easier for other users to setup Jaeger or other
opentelemetry-related daemons too (they can just re-use their Buildkit
infra instead of setting up something else).

#Start will need a few more features first though, the main one being
support for sending SIGTERM before SIGKILL (right now it is just
instantly SIGKILL'd). Without that, the Jaeger data is corrupted. Once
that support is merged, we will be able to switch over to #Start.

Signed-off-by: Erik Sipsma [email protected]


Separate important commit:

ci: add plan for viewing Jaeger CI traces locally

This allows you to run a single dagger do command that pulls down jaeger
data from the artifacts of a GHA run, start a local Jaeger daemon with
it and then view it in your web browser.

The dagger do command for this is printed at the end of GHA runs with
all the --with parameters filled out, for convenience.

It uses GH credentials, which it assumes you have previously setup on
your local machine via "gh auth login" (gh is the github cli).

This would be a great use-case for client-side proxying, but that
doesn't exist yet, so the Jaeger daemon will just end up listening on
the localhost of the machine running Buildkit. This is better than
nothing for now and use of SSH port forwarding can help cases where its
otherwise convenient.

It is also a bit weird in that this is a plan that is expected to just
keep running indefinitely until you cancel it (e.g. with ctrl-C).
However, I have not experienced any issues with the previously, other
than a weirdly flashing tty output while its running (which is a
separate issue).

Signed-off-by: Erik Sipsma [email protected]


Extra notes:

  • While this is helpful, Buildkit is missing a lot of traces that could provide a lot of value, especially for caching. I have a branch in my Buildkit fork which I've been testing this against that adds a lot more traces. I will get that merged upstream so we can pick it up ASAP.
  • I made the decision here to enhance observability through tracing rather than through progress logs, but both would have been an option. I feel that because tracing is a more open standard with more available tooling and because Buildkit's progress implementation is mostly specialized for buildctl/buildx output rather than truly general observability, tracing was the better route.
  • If we are good with this I'll follow up with the same change to the universe tests. This will probably also entail adding a new test run to GHA that exercises the "default" buildkitd created in docker so that we still have coverage for that path (part of the update here is to pre-initialize buildkit so it can be instrumented with jaeger)
  • Also note in the commit messages a few other follow ups that will allow us to run Jaeger via core.#Start. I'll be sending out the updates need to #Start to enable that soon too.

@sipsma
sipsma requested review from a team, aluzzardi, samalba and shykes as code owners May 12, 2022 18:20

@aluzzardi aluzzardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

sipsma added 4 commits May 12, 2022 14:41
Before this, when trying to use opentelemetry libs it was possible to
get an error "cannot merge resource due to conflicting Schema URL".

The error indicates that different versions of opentelemetry are being
used at the same time. This seems to have ultimately resulted from the
fact that we setup tracers and also provide those to some Buildkit libs,
but buildkit is still on v1.4.1 while we recently upgraded to v1.7.0.

This, for reasons that are not yet clear to me, only happened in the
integration tests where the dagger client is running inside dagger. It
may have something to do with a difference in how we build dagger inside
dagger compared to when it is built directly in GHA, but not sure.

Either way, this downgrade unblocks us for the moment until we have a
better way of solving this.

Signed-off-by: Erik Sipsma <[email protected]>
This sets up Jaeger to run inside GHA during integration tests,
instruments dagger and buildkit to write to it and exports the resulting
data as an artifact of the run.

This enables us to get insight into what actually happened during our CI
runs, which is helpful for debugging and getting insight into the
performance of caching.

Jaeger seems to be mostly designed for "live" use, but it has an
experimental mode for persisting its data to disk, which I use here to
enable exporting it.

This is not a completely ideal solution. It requires setting up Buildkit
and Jaeger in docker separate from our actual test run. The much better
solution will be to use async \#Start and \#Stop tasks to run at least
Jaeger (and probably Buildkit itself too). This will allows use to
dogfood our own features and also open the interesting possibility of
making it easier for other users to setup Jaeger or other
opentelemetry-related daemons too (they can just re-use their Buildkit
infra instead of setting up something else).

\#Start will need a few more features first though, the main one being
support for sending SIGTERM before SIGKILL (right now it is just
instantly SIGKILL'd). Without that, the Jaeger data is corrupted. Once
that support is merged, we will be able to switch over to \#Start.

Signed-off-by: Erik Sipsma <[email protected]>
This makes exported traces easier to identify by test.

Signed-off-by: Erik Sipsma <[email protected]>
This allows you to run a single dagger do command that pulls down jaeger
data from the artifacts of a GHA run, start a local Jaeger daemon with
it and then view it in your web browser.

The dagger do command for this is printed at the end of GHA runs with
all the --with parameters filled out, for convenience.

It uses GH credentials, which it assumes you have previously setup on
your local machine via "gh auth login" (gh is the github cli).

This would be a great use-case for client-side proxying, but that
doesn't exist yet, so the Jaeger daemon will just end up listening on
the localhost of the machine running Buildkit. This is better than
nothing for now and use of SSH port forwarding can help cases where its
otherwise convenient.

It is also a bit weird in that this is a plan that is expected to just
keep running indefinitely until you cancel it (e.g. with ctrl-C).
However, I have not experienced any issues with the previously, other
than a weirdly flashing tty output while its running (which is a
separate issue).

Signed-off-by: Erik Sipsma <[email protected]>
@samalba
samalba merged commit 40a15bf into dagger:main May 13, 2022
@sipsma sipsma mentioned this pull request May 18, 2022
5 of 14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants