Skip to content

Commit

Permalink
Store the last error when fetching details.
Browse files Browse the repository at this point in the history
When fetching the detailed bulk build report and there is an error,
store the error in the database and surface it on the build page.

There is more to be done here (including a better UI) but this at least
shows that there has been a problem.

Update #5
  • Loading branch information
bsiegert committed Jul 16, 2024
1 parent 7e6ddf5 commit 7e6cfbf
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ddao/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ddao/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 25 additions & 4 deletions ddao/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions ingest/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
package ingest

import (
"database/sql"

"github.com/bsiegert/BulkTracker/bulk"
"github.com/bsiegert/BulkTracker/ddao"
"github.com/bsiegert/BulkTracker/log"
Expand Down Expand Up @@ -247,6 +249,13 @@ func (i *IncomingMailHandler) FetchReport(ctx context.Context, buildID int64, ur
status.LastErr = err
status.Current = Failed
status.Put(ctx)
i.DB.SetBuildLastError(ctx, ddao.SetBuildLastErrorParams{
BuildID: buildID,
LastError: sql.NullString{
Valid: true,
String: fmt.Sprintf("failed to fetch: %s", err),
},
})
return
}
defer resp.Body.Close()
Expand All @@ -256,6 +265,13 @@ func (i *IncomingMailHandler) FetchReport(ctx context.Context, buildID int64, ur
status.LastErr = err
status.Current = Failed
status.Put(ctx)
i.DB.SetBuildLastError(ctx, ddao.SetBuildLastErrorParams{
BuildID: buildID,
LastError: sql.NullString{
Valid: true,
String: fmt.Sprintf("failed to uncompress: %s", err),
},
})
return
}
pkgs, err := bulk.PkgsFromReport(r)
Expand All @@ -264,6 +280,13 @@ func (i *IncomingMailHandler) FetchReport(ctx context.Context, buildID int64, ur
status.LastErr = err
status.Current = Failed
status.Put(ctx)
i.DB.SetBuildLastError(ctx, ddao.SetBuildLastErrorParams{
BuildID: buildID,
LastError: sql.NullString{
Valid: true,
String: fmt.Sprintf("failed to parse: %s", err),
},
})
return
}

Expand Down
8 changes: 8 additions & 0 deletions queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,11 @@ VALUES (?, ?);
INSERT INTO results
(build_id, pkg_id, pkg_name, build_status, breaks, failed_deps)
VALUES (?, ?, ?, ?, ?, ?);

-- name: SetBuildLastError :exec

-- SetBuildLastError sets the last_error column on a given build.
UPDATE builds
SET last_error = ?
WHERE build_id = ?;

9 changes: 7 additions & 2 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ CREATE TABLE IF NOT EXISTS builds (
num_prefailed INTEGER NOT NULL,
num_failed INTEGER NOT NULL,
num_indirect_failed INTEGER NOT NULL,
num_indirect_prefailed INTEGER NOT NULL
num_indirect_prefailed INTEGER NOT NULL,

last_error text
);

-- Schema update:
-- ALTER TABLE builds ADD COLUMN last_error text;

CREATE TABLE IF NOT EXISTS pkgs (
pkg_id INTEGER PRIMARY KEY ASC,
category text NOT NULL,
Expand All @@ -55,4 +60,4 @@ CREATE TABLE IF NOT EXISTS results (
breaks INTEGER NOT NULL
);

CREATE INDEX results_i_build_pkg ON results (build_id, pkg_id);
CREATE INDEX results_i_build_pkg ON results (build_id, pkg_id);
6 changes: 6 additions & 0 deletions templates/bulk_build_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<a href="{{.ReportUrl}}">{{.ReportUrl}}</a>
</dd>
{{end}}
{{if .LastError.Valid}}
<dt>Last error</dt>
<dd style = "color: red">
{{.LastError.String}}
</dd>
{{end}}
</dl>
</div>
<div class="col-md-3">
Expand Down

0 comments on commit 7e6cfbf

Please sign in to comment.