Skip to content

Commit

Permalink
cmd/coordinator,internal,maintner: prioritize relui builds
Browse files Browse the repository at this point in the history
Populates a new User field on SchedItem which will keep track of either
the gomote user or the commit author email for trybots.

Sets relui related builds to the highest priority, PriorityUrgent.

Fixes golang/go#48857

Change-Id: I8930a0e8c6bdb1becd454e953779f42f3885fbef
Reviewed-on: https://go-review.googlesource.com/c/build/+/419428
Run-TryBot: Jenny Rakoczy <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
  • Loading branch information
toothrot committed Jul 28, 2022
1 parent 19189db commit 669914d
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 230 deletions.
3 changes: 3 additions & 0 deletions cmd/coordinator/buildstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func (st *buildStatus) onceInitHelpersFunc() {
IsTry: st.isTry(),
CommitTime: st.commitTime(),
Branch: st.branch(),
User: st.AuthorEmail,
}
st.helpers = getBuildlets(st.ctx, st.conf.NumTestHelpers(st.isTry()), schedTmpl, st)
}
Expand Down Expand Up @@ -379,6 +380,7 @@ func (st *buildStatus) getBuildlet() (buildlet.Client, error) {
BuilderRev: st.BuilderRev,
CommitTime: st.commitTime(),
Branch: st.branch(),
User: st.AuthorEmail,
}
st.mu.Lock()
st.schedItem = schedItem
Expand Down Expand Up @@ -700,6 +702,7 @@ func (st *buildStatus) crossCompileMakeAndSnapshot(config *dashboard.CrossCompil
BuilderRev: st.BuilderRev,
CommitTime: st.commitTime(),
Branch: st.branch(),
User: st.AuthorEmail,
})
sp.Done(err)
if err != nil {
Expand Down
16 changes: 13 additions & 3 deletions cmd/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,16 @@ type commitDetail struct {

// Branch for BuilderRev.SubRev, if it exists.
SubRevBranch string

// AuthorId is the gerrit-internal ID for the commit author, if
// available. For sub-repo trybots, this is the author of the
// commit from the trybot CL.
AuthorId int64

// AuthorEmail is the commit author from Gerrit, if available.
// For sub-repo trybots, this is the author of the
// commit from the trybot CL.
AuthorEmail string
}

// addWorkDetail adds some work to (maybe) do, if it's not already
Expand Down Expand Up @@ -1265,7 +1275,7 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
continue
}
brev := tryKeyToBuilderRev(bconf.Name, key, mainBuildGoCommit)
bs, err := newBuild(brev, commitDetail{RevBranch: goBranch, SubRevBranch: subBranch})
bs, err := newBuild(brev, commitDetail{RevBranch: goBranch, SubRevBranch: subBranch, AuthorEmail: work.AuthorEmail})
if err != nil {
log.Printf("can't create build for %q: %v", brev, err)
continue
Expand Down Expand Up @@ -1294,7 +1304,7 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
continue
}
brev := tryKeyToBuilderRev(linuxBuilder.Name, key, goRev)
bs, err := newBuild(brev, commitDetail{RevBranch: branch, SubRevBranch: subBranch})
bs, err := newBuild(brev, commitDetail{RevBranch: branch, SubRevBranch: subBranch, AuthorEmail: work.AuthorEmail})
if err != nil {
log.Printf("can't create build for %q: %v", brev, err)
continue
Expand Down Expand Up @@ -1340,7 +1350,7 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
SubRev: rev,
}
// getRepoHead always fetches master, so use that as the SubRevBranch.
bs, err := newBuild(brev, commitDetail{RevBranch: branch, SubRevBranch: "master"})
bs, err := newBuild(brev, commitDetail{RevBranch: branch, SubRevBranch: "master", AuthorEmail: work.AuthorEmail})
if err != nil {
log.Printf("can't create x/%s trybot build for go/master commit %s: %v", project, rev, err)
return nil
Expand Down
6 changes: 4 additions & 2 deletions cmd/coordinator/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ func handleBuildletCreate(w http.ResponseWriter, r *http.Request) {
}

si := &queue.SchedItem{
HostType: bconf.HostType,
IsGomote: true,
HostType: bconf.HostType,
IsGomote: true,
IsRelease: user == "user-relui",
User: user,
}

ctx := r.Context()
Expand Down
5 changes: 4 additions & 1 deletion internal/coordinator/pool/queue/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
type SchedItem struct {
buildgo.BuilderRev // not set for gomote
HostType string
IsRelease bool
IsGomote bool
IsTry bool
IsHelper bool
Expand All @@ -39,12 +40,14 @@ type SchedItem struct {
// being newer, or master being newer).
CommitTime time.Time
RequestTime time.Time
tryFor string // TODO: which user. (user with 1 trybot >> user with 50 trybots)
User string
}

// Priority returns the BuildletPriority for a SchedItem.
func (s *SchedItem) Priority() BuildletPriority {
switch {
case s.IsRelease:
return PriorityUrgent
case s.IsGomote:
return PriorityInteractive
case s.IsTry:
Expand Down
1 change: 1 addition & 0 deletions internal/gomote/gomote.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (s *Server) CreateInstance(req *protos.CreateInstanceRequest, stream protos
si := &queue.SchedItem{
HostType: bconf.HostType,
IsGomote: true,
User: creds.Email,
}
type result struct {
buildletClient buildlet.Client
Expand Down
258 changes: 134 additions & 124 deletions maintner/maintnerd/apipb/api.pb.go

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions maintner/maintnerd/apipb/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ message GerritTryWorkItem {
string change_id = 3; // "I1a27695838409259d1586a0adfa9f92bccf7ceba"
string commit = 4; // "ecf3dffc81dc21408fb02159af352651882a8383"

int32 version = 9; // which Gerrit revision number commit is

// go_commit is set for subrepos and is the Go commit(s) to test against.
// go_branch is a branch name of go_commit, for showing to users when
// a try set fails.
Expand All @@ -73,6 +71,9 @@ message GerritTryWorkItem {
// try_message is the list of TRY=xxxx messages associated with Run-TryBot votes.
// It's sorted from oldest to newest.
repeated TryVoteMessage try_message = 8;

int32 version = 9; // which Gerrit revision number commit is
string author_email = 10; // "[email protected]"
}

message TryVoteMessage {
Expand Down
11 changes: 6 additions & 5 deletions maintner/maintnerd/maintapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ func tryWorkItem(
goProj refer, develVersion apipb.MajorMinor, supportedReleases []*apipb.GoRelease,
) (*apipb.GerritTryWorkItem, error) {
w := &apipb.GerritTryWorkItem{
Project: cl.Project.Project(),
Branch: strings.TrimPrefix(cl.Branch(), "refs/heads/"),
ChangeId: cl.ChangeID(),
Commit: cl.Commit.Hash.String(),
Project: cl.Project.Project(),
Branch: strings.TrimPrefix(cl.Branch(), "refs/heads/"),
ChangeId: cl.ChangeID(),
Commit: cl.Commit.Hash.String(),
AuthorEmail: cl.Owner().Email(),
}
if ci.CurrentRevision != "" {
// In case maintner is behind.
Expand Down Expand Up @@ -313,7 +314,7 @@ func (s apiService) GoFindTryWork(ctx context.Context, req *apipb.GoFindTryWorkR
func goFindTryWork(ctx context.Context, gerritc *gerrit.Client, maintc *maintner.Corpus) (*apipb.GoFindTryWorkResponse, error) {
const query = "label:Run-TryBot=1 label:TryBot-Result=0 status:open"
cis, err := gerritc.QueryChanges(ctx, query, gerrit.QueryChangesOpt{
Fields: []string{"CURRENT_REVISION", "CURRENT_COMMIT", "MESSAGES"},
Fields: []string{"CURRENT_REVISION", "CURRENT_COMMIT", "MESSAGES", "DETAILED_ACCOUNTS"},
})
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 669914d

Please sign in to comment.