-
Notifications
You must be signed in to change notification settings - Fork 7
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
track actives map usage for use in error reporting #37
Merged
alexcb
merged 1 commit into
earthly-main
from
acb/inconsistent-graph-state-error-tracker
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package solver | ||
|
||
// earthly-specific: this is used to collect information related to "inconsistent graph state" errors | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
digest "github.com/opencontainers/go-digest" | ||
) | ||
|
||
var dgstTrackerInst = newDgstTracker() | ||
|
||
type dgstTrackerItem struct { | ||
dgst digest.Digest | ||
action string | ||
seen time.Time | ||
} | ||
|
||
type dgstTracker struct { | ||
head int | ||
records []dgstTrackerItem | ||
} | ||
|
||
func newDgstTracker() *dgstTracker { | ||
n := 10000 | ||
return &dgstTracker{ | ||
records: make([]dgstTrackerItem, n), | ||
} | ||
} | ||
|
||
func (d *dgstTracker) add(dgst digest.Digest, action string) { | ||
d.head += 1 | ||
if d.head >= len(d.records) { | ||
d.head = 0 | ||
} | ||
d.records[d.head].dgst = dgst | ||
d.records[d.head].action = action | ||
d.records[d.head].seen = time.Now() | ||
} | ||
|
||
func (d *dgstTracker) String() string { | ||
var sb strings.Builder | ||
|
||
for i := d.head; i >= 0; i-- { | ||
if d.records[i].seen.IsZero() { | ||
break | ||
} | ||
sb.WriteString(fmt.Sprintf("%s %s %s; ", d.records[i].dgst, d.records[i].action, d.records[i].seen)) | ||
} | ||
for i := len(d.records) - 1; i > d.head; i-- { | ||
if d.records[i].seen.IsZero() { | ||
break | ||
} | ||
sb.WriteString(fmt.Sprintf("%s %s %s; ", d.records[i].dgst, d.records[i].action, d.records[i].seen)) | ||
} | ||
return sb.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
maybe protect against
ee.Vertex = nil
?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.
(applies to other lines too)
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.
actually forget, i've seen that was assumed already in the old code
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.
yeah, buildkit makes this guarantee for us fortunately :)