Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2020-03-11 10:57:59 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2020-03-11 12:25:01 +0300
commit4341cd464913a32da78c19806243c0e25c54f917 (patch)
tree449ce0288bc847ccb34149ca5dbfed9d599a54b1 /internal/praefect/replicator.go
parentaa910b0b6fbc3f005a9924dee731123dfca2e48d (diff)
Praefect: use enum values for job states
Move out from `int` as enum values that need to be stored in DB. Base type for `JobState` and `ChangeType` changed from `int` type with `iota + 1` initialization to `string`. It is hard to use binary arithmetic with SQL storage and it is hard to determine actual value of such type in the logs. Unused errors were removed as well.
Diffstat (limited to 'internal/praefect/replicator.go')
-rw-r--r--internal/praefect/replicator.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/praefect/replicator.go b/internal/praefect/replicator.go
index 769d3a56c..70ca77537 100644
--- a/internal/praefect/replicator.go
+++ b/internal/praefect/replicator.go
@@ -305,7 +305,7 @@ func (r ReplMgr) ProcessBacklog(ctx context.Context, b BackoffFunc) error {
primary, secondaries, err := r.getPrimaryAndSecondaries()
if err == nil {
for _, secondary := range secondaries {
- jobs, err := r.datastore.GetJobs(datastore.JobStateReady|datastore.JobStateFailed, secondary.GetStorage(), 10)
+ jobs, err := r.datastore.GetJobs([]datastore.JobState{datastore.JobStateReady, datastore.JobStateFailed}, secondary.GetStorage(), 10)
if err != nil {
return err
}
@@ -429,7 +429,7 @@ func (r ReplMgr) processReplJob(ctx context.Context, job datastore.ReplJob, sour
case datastore.RenameRepo:
err = r.replicator.Rename(injectedCtx, job, targetCC)
default:
- err = fmt.Errorf("unknown replication change type encountered: %d", job.Change)
+ err = fmt.Errorf("unknown replication change type encountered: %q", job.Change)
}
if err != nil {
l.WithError(err).Error("unable to replicate")
@@ -439,7 +439,7 @@ func (r ReplMgr) processReplJob(ctx context.Context, job datastore.ReplJob, sour
replDuration := time.Since(replStart)
r.replLatencyMetric.Observe(float64(replDuration) / float64(time.Second))
- if err := r.datastore.UpdateReplJobState(job.ID, datastore.JobStateComplete); err != nil {
+ if err := r.datastore.UpdateReplJobState(job.ID, datastore.JobStateCompleted); err != nil {
r.log.WithError(err).Error("error when updating replication job status to complete")
}