From 533da0b6bb492c5843f5c0ee28c62cc661ea00c3 Mon Sep 17 00:00:00 2001 From: Rafael Soares Date: Mon, 22 Apr 2024 16:44:42 -0300 Subject: [PATCH] add new configs for rollup timeouts --- archives/archives.go | 4 ++-- archives/config.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/archives/archives.go b/archives/archives.go index f72f9b5..c9aad4b 100644 --- a/archives/archives.go +++ b/archives/archives.go @@ -319,7 +319,7 @@ func GetMissingMonthlyArchives(ctx context.Context, db *sqlx.DB, now time.Time, // BuildRollupArchive builds a monthly archive from the files present on S3 func BuildRollupArchive(ctx context.Context, db *sqlx.DB, conf *Config, s3Client s3iface.S3API, monthlyArchive *Archive, now time.Time, org Org, archiveType ArchiveType) error { - ctx, cancel := context.WithTimeout(ctx, time.Hour) + ctx, cancel := context.WithTimeout(ctx, time.Hour*time.Duration(conf.BuildRollupArchiveTimeout)) defer cancel() start := time.Now() @@ -813,7 +813,7 @@ func createArchives(ctx context.Context, db *sqlx.DB, config *Config, s3Client s // RollupOrgArchives rolls up monthly archives from our daily archives func RollupOrgArchives(ctx context.Context, now time.Time, config *Config, db *sqlx.DB, s3Client s3iface.S3API, org Org, archiveType ArchiveType) ([]*Archive, error) { - ctx, cancel := context.WithTimeout(ctx, time.Hour*3) + ctx, cancel := context.WithTimeout(ctx, time.Hour*time.Duration(config.RollupOrgTimeout)) defer cancel() log := logrus.WithFields(logrus.Fields{ diff --git a/archives/config.go b/archives/config.go index 5ec635a..1113aa2 100644 --- a/archives/config.go +++ b/archives/config.go @@ -25,6 +25,9 @@ type Config struct { Delete bool `help:"whether to delete messages and runs from the db after archival (default false)"` ExitOnCompletion bool `help:"whether archiver should exit after completing archiving job (default false)"` StartTime string `help:"what time archive jobs should run in UTC HH:MM "` + + RollupOrgTimeout int `help:"rollup timeout for all org archives, limit in hours (default 3)"` + BuildRollupArchiveTimeout int `help:"rollup for single archive timeout, limit in hours (default 1)"` } // NewConfig returns a new default configuration object @@ -52,6 +55,9 @@ func NewConfig() *Config { Delete: false, ExitOnCompletion: false, StartTime: "00:01", + + RollupOrgTimeout: 3, + BuildRollupArchiveTimeout: 1, } return &config