runservice: move all scheduler etcd data to own dir
This commit is contained in:
parent
e1368d18d6
commit
33c328b3f5
|
@ -36,18 +36,23 @@ func (e ErrNotExist) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
EtcdRunsDir = "runs"
|
EtcdSchedulerBaseDir = "scheduler"
|
||||||
EtcdRunSequenceKey = "runsequence"
|
|
||||||
EtcdRunEventKey = "runevents"
|
|
||||||
EtcdRunEventSequenceKey = "runeventsequence"
|
|
||||||
|
|
||||||
EtcdChangeGroupsDir = "changegroups"
|
EtcdRunsDir = path.Join(EtcdSchedulerBaseDir, "runs")
|
||||||
EtcdChangeGroupMinRevisionKey = "changegroupsminrev"
|
EtcdRunSequenceKey = path.Join(EtcdSchedulerBaseDir, "runsequence")
|
||||||
|
EtcdRunEventKey = path.Join(EtcdSchedulerBaseDir, "runevents")
|
||||||
|
EtcdRunEventSequenceKey = path.Join(EtcdSchedulerBaseDir, "runeventsequence")
|
||||||
|
|
||||||
EtcdExecutorsDir = "executors"
|
EtcdChangeGroupsDir = path.Join(EtcdSchedulerBaseDir, "changegroups")
|
||||||
EtcdTasksDir = "tasks"
|
EtcdChangeGroupMinRevisionKey = path.Join(EtcdSchedulerBaseDir, "changegroupsminrev")
|
||||||
|
|
||||||
EtcdPingKey = "ping"
|
EtcdExecutorsDir = path.Join(EtcdSchedulerBaseDir, "executors")
|
||||||
|
EtcdTasksDir = path.Join(EtcdSchedulerBaseDir, "tasks")
|
||||||
|
|
||||||
|
EtcdPingKey = path.Join(EtcdSchedulerBaseDir, "ping")
|
||||||
|
|
||||||
|
EtcdCacheCleanerLockKey = path.Join(EtcdSchedulerBaseDir, "locks", "cachecleaner")
|
||||||
|
EtcdTaskUpdaterLockKey = path.Join(EtcdSchedulerBaseDir, "locks", "taskupdater")
|
||||||
)
|
)
|
||||||
|
|
||||||
func EtcdRunKey(runID string) string { return path.Join(EtcdRunsDir, runID) }
|
func EtcdRunKey(runID string) string { return path.Join(EtcdRunsDir, runID) }
|
||||||
|
|
|
@ -377,7 +377,7 @@ func (r *ReadDB) HandleEvents(ctx context.Context) error {
|
||||||
wctx, cancel := context.WithCancel(ctx)
|
wctx, cancel := context.WithCancel(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
wctx = etcdclientv3.WithRequireLeader(wctx)
|
wctx = etcdclientv3.WithRequireLeader(wctx)
|
||||||
wch := r.e.Watch(wctx, "", revision+1)
|
wch := r.e.Watch(wctx, common.EtcdSchedulerBaseDir+"/", revision+1)
|
||||||
for wresp := range wch {
|
for wresp := range wch {
|
||||||
if wresp.Canceled {
|
if wresp.Canceled {
|
||||||
err = wresp.Err()
|
err = wresp.Err()
|
||||||
|
|
|
@ -54,9 +54,6 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
cacheCleanerInterval = 1 * 24 * time.Hour
|
cacheCleanerInterval = 1 * 24 * time.Hour
|
||||||
|
|
||||||
cacheCleanerLock = "locks/cachecleaner"
|
|
||||||
taskUpdaterLock = "locks/taskupdater"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var level = zap.NewAtomicLevelAt(zapcore.InfoLevel)
|
var level = zap.NewAtomicLevelAt(zapcore.InfoLevel)
|
||||||
|
@ -835,7 +832,7 @@ func (s *Scheduler) runTasksUpdater(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
|
|
||||||
m := concurrency.NewMutex(session, taskUpdaterLock)
|
m := concurrency.NewMutex(session, common.EtcdTaskUpdaterLockKey)
|
||||||
|
|
||||||
// TODO(sgotti) find a way to use a trylock so we'll just return if already
|
// TODO(sgotti) find a way to use a trylock so we'll just return if already
|
||||||
// locked. Currently multiple task updaters will enqueue and start when another
|
// locked. Currently multiple task updaters will enqueue and start when another
|
||||||
|
@ -1504,7 +1501,7 @@ func (s *Scheduler) cacheCleaner(ctx context.Context, cacheExpireInterval time.D
|
||||||
}
|
}
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
|
|
||||||
m := concurrency.NewMutex(session, cacheCleanerLock)
|
m := concurrency.NewMutex(session, common.EtcdCacheCleanerLockKey)
|
||||||
|
|
||||||
// TODO(sgotti) find a way to use a trylock so we'll just return if already
|
// TODO(sgotti) find a way to use a trylock so we'll just return if already
|
||||||
// locked. Currently multiple cachecleaners will enqueue and start when another
|
// locked. Currently multiple cachecleaners will enqueue and start when another
|
||||||
|
|
Loading…
Reference in New Issue