Skip to content

Commit 2ec2935

Browse files
authored
Touch mirrors on even on fail to update (#19217) (#19233)
Backport #19217 If a mirror fails to be synchronised it should be pushed to the bottom of the queue of the awaiting mirrors to be synchronised. At present if there LIMIT number of broken mirrors they can effectively prevent all other mirrors from being synchronized as their last_updated time will remain earlier than other mirrors. Signed-off-by: Andrew Thornton <[email protected]>
1 parent 540541c commit 2ec2935

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

models/repo/mirror.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package repo
77

88
import (
9+
"context"
910
"errors"
1011
"fmt"
1112
"time"
@@ -115,6 +116,13 @@ func UpdateMirror(m *Mirror) error {
115116
return updateMirror(db.GetEngine(db.DefaultContext), m)
116117
}
117118

119+
// TouchMirror updates the mirror updatedUnix
120+
func TouchMirror(ctx context.Context, m *Mirror) error {
121+
m.UpdatedUnix = timeutil.TimeStampNow()
122+
_, err := db.GetEngine(ctx).ID(m.ID).Cols("updated_unix").Update(m)
123+
return err
124+
}
125+
118126
// DeleteMirrorByRepoID deletes a mirror by repoID
119127
func DeleteMirrorByRepoID(repoID int64) error {
120128
_, err := db.GetEngine(db.DefaultContext).Delete(&Mirror{RepoID: repoID})

services/mirror/mirror_pull.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
387387
log.Trace("SyncMirrors [repo: %-v]: Running Sync", m.Repo)
388388
results, ok := runSync(ctx, m)
389389
if !ok {
390+
if err = repo_model.TouchMirror(ctx, m); err != nil {
391+
log.Error("SyncMirrors [repo: %-v]: failed to TouchMirror: %v", m.Repo, err)
392+
}
390393
return false
391394
}
392395

0 commit comments

Comments
 (0)