Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

repo-updater: run repo purge on regular interval with generous TTL#44753

Merged
bobheadxi merged 5 commits into
mainfrom
repo-updater-repo-purge-all-the-time
Nov 23, 2022
Merged

repo-updater: run repo purge on regular interval with generous TTL#44753
bobheadxi merged 5 commits into
mainfrom
repo-updater-repo-purge-all-the-time

Conversation

@bobheadxi

@bobheadxi bobheadxi commented Nov 23, 2022

Copy link
Copy Markdown
Member

We only clear deleted repos on weekends, documented as a stopgap to mitigate the impact of accidental deletions. This seems to cause large numbers of repositories to linger around if a massive code host is added and deleted, consuming disk space that the percentage-based janitor seems to struggle to keep up with - we saw this in S2 recently: thread

60-75 minutes seems a sufficiently generous amount of time to allow for a mistaken deletion to be reverted, so we remove the weekend constraint to allow this to run more frequently.

Test plan

CI, tested site configuration with sg start

@cla-bot cla-bot Bot added the cla-signed label Nov 23, 2022
@bobheadxi bobheadxi force-pushed the repo-updater-repo-purge-all-the-time branch from a2c4dc4 to 63ba56a Compare November 23, 2022 17:36
@bobheadxi bobheadxi requested review from a team November 23, 2022 17:40
@bobheadxi bobheadxi marked this pull request as ready for review November 23, 2022 17:41
@sourcegraph-bot

sourcegraph-bot commented Nov 23, 2022

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 12be752...b1da12c.

Notify File(s)
@indradhanush internal/repos/purge.go
internal/repos/purge_test.go
@ryanslade internal/repos/purge.go
internal/repos/purge_test.go
@sashaostrikov internal/repos/purge.go
internal/repos/purge_test.go

@bobheadxi bobheadxi force-pushed the repo-updater-repo-purge-all-the-time branch from 63ba56a to 59336df Compare November 23, 2022 17:42

@varsanojidan varsanojidan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice LGTM 👍 .

I'm speaking from just gut feeling but I feel like 30 min is a bit short for a grace period, how would you feel about an hour? That way there's more of a chance that if someone does a config change that removes repos and doesn't realize it, there's more of a chance that someone else might notice and alert it 😅 .

Comment thread cmd/repo-updater/shared/main.go Outdated
Comment thread internal/repos/purge.go Outdated
// gitserver, but not enabled/present in our repos table. ttl, should be >= 0 and
// specifies how long ago a repo must be deleted before it is purged.
func RunRepositoryPurgeWorker(ctx context.Context, logger log.Logger, db database.DB, ttl time.Duration) {
func RunRepositoryPurgeWorker(ctx context.Context, logger log.Logger, db database.DB, ttl time.Duration, baseInterval time.Duration) {

@michaellzc michaellzc Nov 23, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to make this an operation (so we can have traces and stuff)? not sure how valuable it would be, but I suppose we want to know when we are purging repos

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now we can rely on logs - we can add tracing in a followup

@michaellzc michaellzc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments but :lgtm

@bobheadxi

bobheadxi commented Nov 23, 2022

Copy link
Copy Markdown
Member Author

I'm speaking from just gut feeling but I feel like 30 min is a bit short for a grace period, how would you feel about an hour?

SGTM, bumped to an hour, which will also now be configurable via https://github.com/sourcegraph/sourcegraph/pull/44753/commits/81ecfaa0f66d667771909c137951c691601df655

Comment thread schema/site.schema.json Outdated
Comment thread schema/site.schema.json Outdated
bobheadxi and others added 2 commits November 23, 2022 11:48
Co-authored-by: Michael Lin <mlzc@hey.com>
@bobheadxi bobheadxi requested a review from michaellzc November 23, 2022 19:50
Comment thread internal/repos/purge.go
Comment on lines -117 to -119
// According to The Cure, 10:15 Saturday Night you should be sitting in your
// kitchen sink, not adjusting your external service configuration.
return t.Format("Mon 15") == "Sat 22"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

@bobheadxi bobheadxi enabled auto-merge (squash) November 23, 2022 19:56
@bobheadxi bobheadxi merged commit ebe1989 into main Nov 23, 2022
@bobheadxi bobheadxi deleted the repo-updater-repo-purge-all-the-time branch November 23, 2022 20:01
Comment thread schema/site.schema.json
"default": "15",
"minimum": 0
},
"deletedTTLMintues": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minutes not Mintues - that should be fixed, since it's user-visible

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread schema/site.schema.json
"deletedTTL": 60
},
"properties": {
"intervalMintues": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minutes not Mintues - that should be fixed, since it's user-visible

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants