Skip to content

Commit

Permalink
Merge pull request #186 from gamoutatsumi/fix/requeue-bad-label
Browse files Browse the repository at this point in the history
fix re-queue bad label jobs
  • Loading branch information
whywaita authored Nov 16, 2023
2 parents 5529176 + b655674 commit f243c75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ require (
github.com/r3labs/diff/v2 v2.15.1
github.com/satori/go.uuid v1.2.0
goji.io v2.0.2+incompatible
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
google.golang.org/grpc v1.45.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME=
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
11 changes: 7 additions & 4 deletions pkg/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"errors"
"fmt"
"net/url"
"strings"
"sync"
"sync/atomic"
"time"

"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/sync/semaphore"

Expand Down Expand Up @@ -370,6 +370,7 @@ func (s *Starter) reRunWorkflow(ctx context.Context) {
return true
}

JL: // job loop
for _, j := range jobs.Jobs {
if value, ok := reQueuedJobs.Load(j.GetID()); ok {
expired := value.(time.Time)
Expand All @@ -378,8 +379,10 @@ func (s *Starter) reRunWorkflow(ctx context.Context) {
}
continue
}
if !slices.Contains(j.Labels, "self-hosted") && !slices.Contains(j.Labels, "myshoes") {
continue
for _, label := range j.Labels {
if !(strings.EqualFold(label, "self-hosted")) {
continue JL
}
}
if j.GetStatus() == "queued" {
repoURL := run.GetRepository().GetHTMLURL()
Expand Down Expand Up @@ -415,7 +418,7 @@ func (s *Starter) reRunWorkflow(ctx context.Context) {
logger.Logf(false, "failed to enqueue job: %+v", err)
continue
}
reQueuedJobs.Store(j.GetID(), time.Now().Add(30*time.Minute))
reQueuedJobs.Store(j.GetID(), time.Now().Add(12*time.Hour))
countRecovered, _ := CountRecovered.LoadOrStore(target.Scope, 0)
CountRecovered.Store(target.Scope, countRecovered.(int)+1)
}
Expand Down

0 comments on commit f243c75

Please sign in to comment.