Remove obsolete config option disable-archive

This commit is contained in:
2026-01-19 16:42:30 +01:00
parent eb09504306
commit 5281f3bb60
14 changed files with 20 additions and 43 deletions

View File

@@ -12,7 +12,6 @@ import (
"encoding/json" "encoding/json"
"os" "os"
"github.com/ClusterCockpit/cc-backend/internal/config"
"github.com/ClusterCockpit/cc-backend/internal/repository" "github.com/ClusterCockpit/cc-backend/internal/repository"
"github.com/ClusterCockpit/cc-backend/pkg/archive" "github.com/ClusterCockpit/cc-backend/pkg/archive"
cclog "github.com/ClusterCockpit/cc-lib/v2/ccLogger" cclog "github.com/ClusterCockpit/cc-lib/v2/ccLogger"
@@ -89,7 +88,7 @@ func initEnv() {
cclog.Abortf("Could not create default ./var/job-archive folder with permissions '0o777'. Application initialization failed, exited.\nError: %s\n", err.Error()) cclog.Abortf("Could not create default ./var/job-archive folder with permissions '0o777'. Application initialization failed, exited.\nError: %s\n", err.Error())
} }
archiveCfg := "{\"kind\": \"file\",\"path\": \"./var/job-archive\"}" archiveCfg := "{\"kind\": \"file\",\"path\": \"./var/job-archive\"}"
if err := archive.Init(json.RawMessage(archiveCfg), config.Keys.DisableArchive); err != nil { if err := archive.Init(json.RawMessage(archiveCfg)); err != nil {
cclog.Abortf("Could not initialize job-archive, exited.\nError: %s\n", err.Error()) cclog.Abortf("Could not initialize job-archive, exited.\nError: %s\n", err.Error())
} }
} }

View File

@@ -274,7 +274,7 @@ func initSubsystems() error {
cclog.Debug("Archive configuration not found, using default archive configuration") cclog.Debug("Archive configuration not found, using default archive configuration")
archiveCfg = json.RawMessage(defaultArchiveConfig) archiveCfg = json.RawMessage(defaultArchiveConfig)
} }
if err := archive.Init(archiveCfg, config.Keys.DisableArchive); err != nil { if err := archive.Init(archiveCfg); err != nil {
return fmt.Errorf("initializing archive: %w", err) return fmt.Errorf("initializing archive: %w", err)
} }

View File

@@ -154,7 +154,7 @@ func setup(t *testing.T) *api.RestAPI {
repository.Connect("sqlite3", dbfilepath) repository.Connect("sqlite3", dbfilepath)
if err := archive.Init(json.RawMessage(archiveCfg), config.Keys.DisableArchive); err != nil { if err := archive.Init(json.RawMessage(archiveCfg)); err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -148,7 +148,7 @@ func setupNatsTest(t *testing.T) *NatsAPI {
repository.Connect("sqlite3", dbfilepath) repository.Connect("sqlite3", dbfilepath)
if err := archive.Init(json.RawMessage(archiveCfg), config.Keys.DisableArchive); err != nil { if err := archive.Init(json.RawMessage(archiveCfg)); err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -9,7 +9,6 @@ import (
"context" "context"
"math" "math"
"github.com/ClusterCockpit/cc-backend/internal/config"
"github.com/ClusterCockpit/cc-backend/internal/metricdispatch" "github.com/ClusterCockpit/cc-backend/internal/metricdispatch"
"github.com/ClusterCockpit/cc-backend/pkg/archive" "github.com/ClusterCockpit/cc-backend/pkg/archive"
cclog "github.com/ClusterCockpit/cc-lib/v2/ccLogger" cclog "github.com/ClusterCockpit/cc-lib/v2/ccLogger"
@@ -94,12 +93,5 @@ func ArchiveJob(job *schema.Job, ctx context.Context) (*schema.Job, error) {
} }
} }
// If the file based archive is disabled,
// only return the JobMeta structure as the
// statistics in there are needed.
if config.Keys.DisableArchive {
return job, nil
}
return job, archive.GetHandle().ImportJob(job, &jobData) return job, archive.GetHandle().ImportJob(job, &jobData)
} }

View File

@@ -43,10 +43,6 @@ type ProgramConfig struct {
// Path to SQLite database file // Path to SQLite database file
DB string `json:"db"` DB string `json:"db"`
// Keep all metric data in the metric data repositories,
// do not write to the job-archive.
DisableArchive bool `json:"disable-archive"`
EnableJobTaggers bool `json:"enable-job-taggers"` EnableJobTaggers bool `json:"enable-job-taggers"`
// Validate json input against schema // Validate json input against schema
@@ -117,7 +113,6 @@ var Keys ProgramConfig = ProgramConfig{
EmbedStaticFiles: true, EmbedStaticFiles: true,
DBDriver: "sqlite3", DBDriver: "sqlite3",
DB: "./var/job.db", DB: "./var/job.db",
DisableArchive: false,
Validate: false, Validate: false,
SessionMaxAge: "168h", SessionMaxAge: "168h",
StopJobsExceedingWalltime: 0, StopJobsExceedingWalltime: 0,

View File

@@ -44,10 +44,6 @@ var configSchema = `
"description": "Path to SQLite database file (e.g., './var/job.db')", "description": "Path to SQLite database file (e.g., './var/job.db')",
"type": "string" "type": "string"
}, },
"disable-archive": {
"description": "Keep all metric data in the metric data repositories, do not write to the job-archive.",
"type": "boolean"
},
"enable-job-taggers": { "enable-job-taggers": {
"description": "Turn on automatic application and jobclass taggers", "description": "Turn on automatic application and jobclass taggers",
"type": "boolean" "type": "boolean"

View File

@@ -100,7 +100,7 @@ func setup(t *testing.T) *repository.JobRepository {
archiveCfg := fmt.Sprintf("{\"kind\": \"file\",\"path\": \"%s\"}", jobarchive) archiveCfg := fmt.Sprintf("{\"kind\": \"file\",\"path\": \"%s\"}", jobarchive)
if err := archive.Init(json.RawMessage(archiveCfg), config.Keys.DisableArchive); err != nil { if err := archive.Init(json.RawMessage(archiveCfg)); err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -43,7 +43,6 @@ import (
"math" "math"
"time" "time"
"github.com/ClusterCockpit/cc-backend/internal/config"
"github.com/ClusterCockpit/cc-backend/internal/metricstore" "github.com/ClusterCockpit/cc-backend/internal/metricstore"
"github.com/ClusterCockpit/cc-backend/pkg/archive" "github.com/ClusterCockpit/cc-backend/pkg/archive"
cclog "github.com/ClusterCockpit/cc-lib/v2/ccLogger" cclog "github.com/ClusterCockpit/cc-lib/v2/ccLogger"
@@ -95,8 +94,7 @@ func LoadData(job *schema.Job,
var err error var err error
if job.State == schema.JobStateRunning || if job.State == schema.JobStateRunning ||
job.MonitoringStatus == schema.MonitoringStatusRunningOrArchiving || job.MonitoringStatus == schema.MonitoringStatusRunningOrArchiving {
config.Keys.DisableArchive {
if scopes == nil { if scopes == nil {
scopes = append(scopes, schema.MetricScopeNode) scopes = append(scopes, schema.MetricScopeNode)
@@ -234,7 +232,7 @@ func LoadAverages(
data [][]schema.Float, data [][]schema.Float,
ctx context.Context, ctx context.Context,
) error { ) error {
if job.State != schema.JobStateRunning && !config.Keys.DisableArchive { if job.State != schema.JobStateRunning {
return archive.LoadAveragesFromArchive(job, metrics, data) // #166 change also here? return archive.LoadAveragesFromArchive(job, metrics, data) // #166 change also here?
} }
@@ -271,7 +269,7 @@ func LoadScopedJobStats(
scopes []schema.MetricScope, scopes []schema.MetricScope,
ctx context.Context, ctx context.Context,
) (schema.ScopedJobStats, error) { ) (schema.ScopedJobStats, error) {
if job.State != schema.JobStateRunning && !config.Keys.DisableArchive { if job.State != schema.JobStateRunning {
return archive.LoadScopedStatsFromArchive(job, metrics, scopes) return archive.LoadScopedStatsFromArchive(job, metrics, scopes)
} }
@@ -293,7 +291,7 @@ func LoadJobStats(
metrics []string, metrics []string,
ctx context.Context, ctx context.Context,
) (map[string]schema.MetricStatistics, error) { ) (map[string]schema.MetricStatistics, error) {
if job.State != schema.JobStateRunning && !config.Keys.DisableArchive { if job.State != schema.JobStateRunning {
return archive.LoadStatsFromArchive(job, metrics) return archive.LoadStatsFromArchive(job, metrics)
} }

View File

@@ -141,7 +141,7 @@ func nodeTestSetup(t *testing.T) {
Connect("sqlite3", dbfilepath) Connect("sqlite3", dbfilepath)
if err := archive.Init(json.RawMessage(archiveCfg), config.Keys.DisableArchive); err != nil { if err := archive.Init(json.RawMessage(archiveCfg)); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }

View File

@@ -181,11 +181,10 @@ type JobContainer struct {
} }
var ( var (
initOnce sync.Once initOnce sync.Once
cache *lrucache.Cache = lrucache.New(128 * 1024 * 1024) cache *lrucache.Cache = lrucache.New(128 * 1024 * 1024)
ar ArchiveBackend ar ArchiveBackend
useArchive bool mutex sync.Mutex
mutex sync.Mutex
) )
// Init initializes the archive backend with the provided configuration. // Init initializes the archive backend with the provided configuration.
@@ -197,12 +196,10 @@ var (
// //
// The configuration determines which backend is used (file, s3, or sqlite). // The configuration determines which backend is used (file, s3, or sqlite).
// Returns an error if initialization fails or version is incompatible. // Returns an error if initialization fails or version is incompatible.
func Init(rawConfig json.RawMessage, disableArchive bool) error { func Init(rawConfig json.RawMessage) error {
var err error var err error
initOnce.Do(func() { initOnce.Do(func() {
useArchive = !disableArchive
var cfg struct { var cfg struct {
Kind string `json:"kind"` Kind string `json:"kind"`
} }
@@ -378,7 +375,7 @@ func UpdateMetadata(job *schema.Job, metadata map[string]string) error {
mutex.Lock() mutex.Lock()
defer mutex.Unlock() defer mutex.Unlock()
if job.State == schema.JobStateRunning || !useArchive { if job.State == schema.JobStateRunning {
return nil return nil
} }
@@ -401,7 +398,7 @@ func UpdateTags(job *schema.Job, tags []*schema.Tag) error {
mutex.Lock() mutex.Lock()
defer mutex.Unlock() defer mutex.Unlock()
if job.State == schema.JobStateRunning || !useArchive { if job.State == schema.JobStateRunning {
return nil return nil
} }

View File

@@ -23,7 +23,7 @@ func setup(t *testing.T) archive.ArchiveBackend {
util.CopyDir("./testdata/archive/", jobarchive) util.CopyDir("./testdata/archive/", jobarchive)
archiveCfg := fmt.Sprintf("{\"kind\": \"file\",\"path\": \"%s\"}", jobarchive) archiveCfg := fmt.Sprintf("{\"kind\": \"file\",\"path\": \"%s\"}", jobarchive)
if err := archive.Init(json.RawMessage(archiveCfg), false); err != nil { if err := archive.Init(json.RawMessage(archiveCfg)); err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -12,7 +12,7 @@ import (
) )
func TestClusterConfig(t *testing.T) { func TestClusterConfig(t *testing.T) {
if err := archive.Init(json.RawMessage("{\"kind\": \"file\",\"path\": \"testdata/archive\"}"), false); err != nil { if err := archive.Init(json.RawMessage("{\"kind\": \"file\",\"path\": \"testdata/archive\"}")); err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -438,7 +438,7 @@ func main() {
cclog.Abort("Main configuration must be present") cclog.Abort("Main configuration must be present")
} }
if err := archive.Init(json.RawMessage(archiveCfg), false); err != nil { if err := archive.Init(json.RawMessage(archiveCfg)); err != nil {
cclog.Fatal(err) cclog.Fatal(err)
} }
ar := archive.GetHandle() ar := archive.GetHandle()