From 2aa76094f76373645ad674ceca02c3c516278bde Mon Sep 17 00:00:00 2001 From: gamoutatsumi Date: Mon, 13 Nov 2023 11:04:31 +0900 Subject: [PATCH] fix re-queue bad-label jobs --- go.mod | 1 - go.sum | 2 -- pkg/starter/starter.go | 10 ++++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 673440f..e60192f 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 7a0c2a3..c22ce51 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/starter/starter.go b/pkg/starter/starter.go index b904ad9..8b5c7ab 100644 --- a/pkg/starter/starter.go +++ b/pkg/starter/starter.go @@ -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" @@ -378,8 +378,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 + } } if j.GetStatus() == "queued" { repoURL := run.GetRepository().GetHTMLURL() @@ -415,7 +417,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) }