This repository was archived by the owner on Sep 30, 2024. It is now read-only.
chore(worker): move event_logs janitor routines to worker#63981
Merged
Conversation
This moves the janitor jobs for event logs from frontend to the worker. Test plan: - new unit test
Comment on lines
+21
to
+36
| // Only clean up if security event logs are being stored in the database. | ||
| c := conf.Get() | ||
| if c.Log == nil || c.Log.SecurityEventLog == nil { | ||
| return nil | ||
| } | ||
| if c.Log.SecurityEventLog.Location != "database" && c.Log.SecurityEventLog.Location != "all" { | ||
| return nil | ||
| } | ||
|
|
||
| // We choose 30 days as the interval to ensure that we have at least the last month's worth of | ||
| // logs at all times. | ||
| _, err := db.ExecContext( | ||
| ctx, | ||
| `DELETE FROM security_event_logs WHERE "timestamp" < now() - interval '30' day`, | ||
| ) | ||
| return err |
Check notice
Code scanning / Semgrep OSS
Semgrep Finding: security-semgrep-rules.semgrep-rules.generic.comment-tagging-rule
eseliger
approved these changes
Jul 22, 2024
| "github.com/sourcegraph/sourcegraph/internal/metrics" | ||
|
|
||
| workerdb "github.com/sourcegraph/sourcegraph/cmd/worker/shared/init/db" | ||
| "github.com/sourcegraph/sourcegraph/internal/bg" |
Member
There was a problem hiding this comment.
can we move this package under cmd/worker/internal/eventlogs/? It's only imported here, and by being under a specific cmd/X directory, it is very obvious to someone reading the code which service will run this.
Comment on lines
+21
to
+36
| // Only clean up if security event logs are being stored in the database. | ||
| c := conf.Get() | ||
| if c.Log == nil || c.Log.SecurityEventLog == nil { | ||
| return nil | ||
| } | ||
| if c.Log.SecurityEventLog.Location != "database" && c.Log.SecurityEventLog.Location != "all" { | ||
| return nil | ||
| } | ||
|
|
||
| // We choose 30 days as the interval to ensure that we have at least the last month's worth of | ||
| // logs at all times. | ||
| _, err := db.ExecContext( | ||
| ctx, | ||
| `DELETE FROM security_event_logs WHERE "timestamp" < now() - interval '30' day`, | ||
| ) | ||
| return err |
Check notice
Code scanning / Semgrep OSS
Semgrep Finding: security-semgrep-rules.semgrep-rules.generic.comment-tagging-rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This moves the janitor jobs for event logs from
frontendtoworker.Next up: move the other recurring jobs as well.
Test plan