f812597410
Implement runservice maintenance mode and export/import. When runservice is set in maintenance mode it'll start only the maintenance and export/import handlers. Setting maintenance mode will set a key in etcd so all the runservice instances will detect it and enter in maintenance mode. This is done asyncronously so it could take some time (future improvements will add some api to show all the runservice states) Export is always available and will export the datamanager contents. Currently only datamanager contents are exported (no logs and workspace archives). Import is available only during maintenance, given a datamanager export will import it and reset etcd to this import state.
83 lines
2.5 KiB
Go
83 lines
2.5 KiB
Go
// Copyright 2019 Sorint.lab
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package common
|
|
|
|
import (
|
|
"path"
|
|
)
|
|
|
|
const (
|
|
MaxCacheKeyLength = 200
|
|
)
|
|
|
|
type ErrNotExist struct {
|
|
err error
|
|
}
|
|
|
|
func NewErrNotExist(err error) error {
|
|
return ErrNotExist{err: err}
|
|
}
|
|
|
|
func (e ErrNotExist) Error() string {
|
|
return e.err.Error()
|
|
}
|
|
|
|
var (
|
|
EtcdSchedulerBaseDir = "scheduler"
|
|
|
|
EtcdRunsDir = path.Join(EtcdSchedulerBaseDir, "runs")
|
|
EtcdRunSequenceKey = path.Join(EtcdSchedulerBaseDir, "runsequence")
|
|
EtcdRunEventKey = path.Join(EtcdSchedulerBaseDir, "runevents")
|
|
EtcdRunEventSequenceKey = path.Join(EtcdSchedulerBaseDir, "runeventsequence")
|
|
|
|
EtcdChangeGroupsDir = path.Join(EtcdSchedulerBaseDir, "changegroups")
|
|
EtcdChangeGroupMinRevisionKey = path.Join(EtcdSchedulerBaseDir, "changegroupsminrev")
|
|
|
|
EtcdExecutorsDir = path.Join(EtcdSchedulerBaseDir, "executors")
|
|
EtcdTasksDir = path.Join(EtcdSchedulerBaseDir, "tasks")
|
|
|
|
EtcdPingKey = path.Join(EtcdSchedulerBaseDir, "ping")
|
|
|
|
EtcdCompactChangeGroupsLockKey = path.Join(EtcdSchedulerBaseDir, "compactchangegroupslock")
|
|
EtcdCacheCleanerLockKey = path.Join(EtcdSchedulerBaseDir, "locks", "cachecleaner")
|
|
EtcdTaskUpdaterLockKey = path.Join(EtcdSchedulerBaseDir, "locks", "taskupdater")
|
|
|
|
EtcdMaintenanceKey = "maintenance"
|
|
)
|
|
|
|
func EtcdRunKey(runID string) string { return path.Join(EtcdRunsDir, runID) }
|
|
func EtcdExecutorKey(taskID string) string { return path.Join(EtcdExecutorsDir, taskID) }
|
|
func EtcdTaskKey(taskID string) string { return path.Join(EtcdTasksDir, taskID) }
|
|
|
|
const (
|
|
EtcdChangeGroupMinRevisionRange = 100
|
|
)
|
|
|
|
var (
|
|
StorageDataDir = ""
|
|
StorageRunsDir = path.Join(StorageDataDir, "runs")
|
|
StorageRunsConfigDir = path.Join(StorageDataDir, "runsconfig")
|
|
StorageRunsIndexesDir = path.Join(StorageDataDir, "runsindexes")
|
|
StorageCountersDir = path.Join(StorageDataDir, "counters")
|
|
)
|
|
|
|
type DataType string
|
|
|
|
const (
|
|
DataTypeRun DataType = "run"
|
|
DataTypeRunConfig DataType = "runconfig"
|
|
DataTypeRunCounter DataType = "runcounter"
|
|
)
|