Commit Graph

25 Commits

Author SHA1 Message Date
Tonis Tiigi
e05a89e0b8 improve stacks of cancels from defers
In this case the current stack trace points to the line
where the context was created. Instead the stack should be
captured when the defer is running so the return path to
the defer call is also part of the stack.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-11-19 18:40:00 -08:00
Jonathan A. Sternberg
2f18b835ce solver: move scheduler debug statements to their own functions
Move scheduler debug statements to their own functions and in their own
file so that scheduler debug statements don't make the scheduler logic
more complex to follow. Some of the scheduler logs can be quite long and
can make it difficult to follow the code logic. This changes these log
statements to `debugSchedulerXXX` where `XXX` is the message that would
be printed.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-09-18 15:49:34 -05:00
Jonathan A. Sternberg
ad64996f49 solver: pipe implementation utilizes generics for better typing
This updates the pipe library to use generics for the request payload
and the status value. This allows the solver to put in explicit types
rather than rely on type casting from interfaces which helps with type
safety and understandability.

The status value used by the solver uses the `any` type instead of an
explicit type because the `unpark` method takes a generic list of pipes
and the different pipes have different result types. We can likely
change this in the future or create a discriminated union for the
types that can be used in this package. That is left for future work
because at least the request payload is typed now.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-09-12 10:37:12 -05:00
Tonis Tiigi
5149ea81e9 solver: mark history and graph concistency errors as internal
Error during creating history or failure in graph concistency
checks are signs of either bugs or system configuration issue. This
makes sure that gRPC error code in the API error based on these
cases has correct value to signify it.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-17 16:28:41 -07:00
Tonis Tiigi
6737deb443 vendor: add go-csvvalue for more efficient CSV parsing
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-21 08:05:56 -07:00
Erik Sipsma
eab04dc35d solver: use logrus fields for more scheduler debug logs
While debugging solver bugs with scheduler debug logs I ended up with so
many logs that I needed to write a program that parsed them and
extracted relevant information so it could be summarized more
comprehensibly.

That was greatly simplified by updating some of the old scheduler debug
logs to use logrus fields rather than one-off `fmt.Sprintf`s. All the
same information as before is present, just formatted more consistently
for easier parsability.

I also ended up removing one of the logs I recently added that printed
each job for a vertex in `loadUnlocked`. I realized that information was
parsable from the rest of the logs and thus was mostly just extra noise.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2024-04-26 12:07:51 -07:00
Erik Sipsma
b2925c2e05 solver: add more debug logs to track down inconsistent graph state
Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2024-04-03 06:12:33 -07:00
Justin Chadwell
4e59c55b84 scheduler: always edge merge in one direction
When we perform a vertex merge, we should explicitly track the vertex
that it was merged into. This way, we can avoid the case where we merge
an index 0 edge from A->B and, later an index 1 edge from B->A.

With this patch, this scenario instead flips the direction of the merge
to merge from A->B for index 1.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-17 15:15:12 +00:00
Justin Chadwell
d3b1de8f94 chore: update merging log message to include index
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-17 14:14:39 +00:00
Tonis Tiigi
8a2a3e83ec replace context.WithCancel with WithCancelCause
Keep stack traces for cancellation errors where possible.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-12-06 22:15:06 -08:00
Tonis Tiigi
7b462d437f solver: allow debugging specific builder steps
This adds new environment variables for allowing
debugging scheduler for only specific steps. This
is useful because the scheduler debugging is quite
verbose so if you run it on production builds it can
generate lots of data that is hard to analyze. Old
behavior is unchanged.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-11-09 00:20:54 -08:00
David Gageot
1245e43085 Enable gosimple linter
Signed-off-by: David Gageot <david.gageot@doctolib.com>
2022-04-23 23:57:16 +02:00
Edgar Lee
465a30a31d Remove goto statements causing failed edges to never unpark
Signed-off-by: Edgar Lee <edgarhinshunlee@gmail.com>
2022-01-12 15:59:20 -08:00
Maxime Lagresle
e76cfcfa22 don't cast Value when pipe is errored
Signed-off-by: Maxime Lagresle <maxime@angel.co>
2021-10-02 11:08:27 +02:00
Maxime Lagresle
b6d092d81e return an error instead of panicking when failing to get edge
Signed-off-by: Maxime Lagresle <maxime@angel.co>
2021-09-30 14:17:07 +02:00
Morlay
18b49fd7dc refactor to use util/bklog instead of using logurs directly
Signed-off-by: Morlay <morlay.null@gmail.com>
2021-07-13 11:42:31 +08:00
Tonis Tiigi
bee77d81b9 solver: check for edge dependency before merging
In some cases edges that depend on each other
can have identical cache keys. This happens for
example when empty layers are optimized out by
the differ between identical commands. We need to
detect this case and avoid merge.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-03-18 19:55:35 -07:00
Tonis Tiigi
b4b0ece384 make sure result refs returned in errors are clone
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-02-03 10:49:38 -08:00
Tonis Tiigi
6a321dc574 solver: improve slow cache detection and add logging
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2020-12-01 22:38:15 -08:00
Akihiro Suda
bf571a519e update Go to 1.11
For consistency with Moby (moby/moby#37358)

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-09-15 14:25:11 +09:00
Tibor Vass
9d1b0e6b31 Merge pull request #597 from tonistiigi/graceful-scheduler-errors
solver: gracefully handle scheduler bugs
2018-08-30 10:56:39 -07:00
Tonis Tiigi
0d68543b1e solver: mark build failed instead of panicking on scheduler error
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-08-29 11:10:05 -07:00
Tonis Tiigi
1127380f91 solver: allow enabling debugger on runtime
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-08-27 16:16:35 -07:00
Tonis Tiigi
97ea41ee6a solver: improve multi-key root caching
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-07-23 14:27:35 -07:00
Tonis Tiigi
71f5e6dd21 solver: rename solver-next to solver
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-05-14 09:53:34 -07:00