mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-24 12:29:05 +01:00
Extend config schema
This commit is contained in:
parent
09d30d0ead
commit
72f178a088
@ -32,6 +32,8 @@ type ArchiveBackend interface {
|
||||
|
||||
CleanUp() error
|
||||
|
||||
// Compress() error
|
||||
|
||||
Iter(loadMetricData bool) <-chan JobContainer
|
||||
}
|
||||
|
||||
@ -46,21 +48,31 @@ var useArchive bool
|
||||
|
||||
func Init(rawConfig json.RawMessage, disableArchive bool) error {
|
||||
useArchive = !disableArchive
|
||||
var kind struct {
|
||||
|
||||
type retention struct {
|
||||
Age int `json:"age"`
|
||||
Policy string `json:"policy"`
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
var cfg struct {
|
||||
Kind string `json:"kind"`
|
||||
Compression int `json:"compression"`
|
||||
Retention retention `json:"retention"`
|
||||
}
|
||||
if err := json.Unmarshal(rawConfig, &kind); err != nil {
|
||||
|
||||
if err := json.Unmarshal(rawConfig, &cfg); err != nil {
|
||||
log.Warn("Error while unmarshaling raw config json")
|
||||
return err
|
||||
}
|
||||
|
||||
switch kind.Kind {
|
||||
switch cfg.Kind {
|
||||
case "file":
|
||||
ar = &FsArchive{}
|
||||
// case "s3":
|
||||
// ar = &S3Archive{}
|
||||
default:
|
||||
return fmt.Errorf("ARCHIVE/ARCHIVE > unkown archive backend '%s''", kind.Kind)
|
||||
return fmt.Errorf("ARCHIVE/ARCHIVE > unkown archive backend '%s''", cfg.Kind)
|
||||
}
|
||||
|
||||
version, err := ar.Init(rawConfig)
|
||||
@ -69,6 +81,11 @@ func Init(rawConfig json.RawMessage, disableArchive bool) error {
|
||||
return err
|
||||
}
|
||||
log.Infof("Load archive version %d", version)
|
||||
|
||||
switch cfg. {
|
||||
case condition:
|
||||
|
||||
}
|
||||
return initClusterConfig()
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,10 @@
|
||||
"description": "Path to job archive for file backend",
|
||||
"type": "string"
|
||||
},
|
||||
"compression": {
|
||||
"description": "Setup automatic compression for jobs older than number of days",
|
||||
"type": "integer"
|
||||
},
|
||||
"retention": {
|
||||
"description": "Configuration keys for retention",
|
||||
"type": "object",
|
||||
@ -69,11 +73,11 @@
|
||||
"move"
|
||||
]
|
||||
},
|
||||
"time": {
|
||||
"description": "Act on jobs with startTime older than time",
|
||||
"age": {
|
||||
"description": "Act on jobs with startTime older than age (in days)",
|
||||
"type": "integer"
|
||||
},
|
||||
"directory": {
|
||||
"location": {
|
||||
"description": "The target directory for retention. Only applicable for retention move.",
|
||||
"type": "string"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user