Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new configs for rollup timeouts #4

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions archives/archives.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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{
Expand Down
6 changes: 6 additions & 0 deletions archives/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,6 +55,9 @@ func NewConfig() *Config {
Delete: false,
ExitOnCompletion: false,
StartTime: "00:01",

RollupOrgTimeout: 3,
BuildRollupArchiveTimeout: 1,
}

return &config
Expand Down
Loading