Skip to content

Commit e3ed966

Browse files
authored
feat: deprecate stuck statue and auto re-onboard stuck repos [CM-1098] (#4034)
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent 6745534 commit e3ed966

7 files changed

Lines changed: 3 additions & 28 deletions

File tree

backend/src/database/migrations/U1776428661__dropStuckFlagFromRepositoryProcessing.sql

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE git."repositoryProcessing" DROP COLUMN IF EXISTS "stuckRequiresReOnboard";

services/apps/git_integration/src/crowdgit/database/crud.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
rp.branch,
3232
rp."maintainerFile",
3333
rp."lastMaintainerRunAt",
34-
rp."stuckRequiresReOnboard",
3534
rp."reOnboardingCount"
3635
"""
3736

@@ -166,7 +165,6 @@ async def acquire_recurrent_repo() -> Repository | None:
166165
states_to_exclude = (
167166
RepositoryState.PENDING,
168167
RepositoryState.PROCESSING,
169-
RepositoryState.STUCK,
170168
RepositoryState.PENDING_REONBOARD,
171169
RepositoryState.AUTH_REQUIRED,
172170
)

services/apps/git_integration/src/crowdgit/enums.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class ErrorCode(str, Enum):
2121
CLEANUP_FAILED = "cleanup-failed"
2222
PARENT_REPO_INVALID = "parent-repo-invalid"
2323
REONBOARDING_REQUIRED = "reonboarding-required"
24-
STUCK_REPO = "stuck-repo"
2524
REPO_AUTH_REQUIRED = "repo-auth-required"
2625
RATE_LIMITED = "rate-limited"
2726
ACCESS_FORBIDDEN = "access-forbidden"
@@ -37,7 +36,6 @@ class RepositoryState(str, Enum):
3736
COMPLETED = "completed"
3837
FAILED = "failed"
3938
REQUIRES_PARENT = "requires_parent" # fork repo without valid parent repo in out system
40-
STUCK = "stuck" # requires manual resolution
4139
PENDING_REONBOARD = "pending_reonboard" # re-onboarding deferred until weekend
4240
AUTH_REQUIRED = "auth_required" # private repo or repo requiring authentication
4341

services/apps/git_integration/src/crowdgit/errors.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,6 @@ class ReOnboardingRequiredError(CrowdGitError):
116116
error_code: ErrorCode = ErrorCode.REONBOARDING_REQUIRED
117117

118118

119-
@dataclass
120-
class StuckRepoError(CrowdGitError):
121-
error_message = "Repos stuck in processing state for a long time"
122-
error_code: ErrorCode = ErrorCode.STUCK_REPO
123-
124-
125119
@dataclass
126120
class RepoAuthRequiredError(CrowdGitError):
127121
error_message: str = "Repository requires authentication (likely private or deleted)"

services/apps/git_integration/src/crowdgit/models/repository.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ class Repository(BaseModel):
4141
parent_repo: Repository | None = Field(
4242
None, description="The parent repository (in case of fork) object from our database"
4343
)
44-
stuck_requires_re_onboard: bool = Field(
45-
default=False,
46-
description="Indicates if the stuck repository is resolved by a re-onboarding",
47-
)
4844
re_onboarding_count: int = Field(
4945
default=0,
5046
description="Tracks the number of times this repository has been re-onboarded. Used to identify unreachable commits via activity.attributes.cycle matching pattern onboarding-{reOnboardingCount}",
@@ -71,7 +67,6 @@ def from_db(cls, db_data: dict[str, Any]) -> Repository:
7167
"maintainerFile": "maintainer_file",
7268
"lastMaintainerRunAt": "last_maintainer_run_at",
7369
"forkedFrom": "forked_from",
74-
"stuckRequiresReOnboard": "stuck_requires_re_onboard",
7570
"reOnboardingCount": "re_onboarding_count",
7671
}
7772
for db_field, model_field in field_mapping.items():

services/apps/git_integration/src/crowdgit/worker/repository_worker.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
ParentRepoInvalidError,
1515
ReOnboardingRequiredError,
1616
RepoAuthRequiredError,
17-
StuckRepoError,
1817
)
1918

2019
# Import configured loguru logger from crowdgit.logger
@@ -117,14 +116,9 @@ async def _ensure_repo_not_stuck(self, repository: Repository):
117116
# handling
118117
if repo_stuck:
119118
logger.warning(
120-
f"Repo {repository.url} is stuck for {processing_duration_hours} hours!"
119+
f"Repo {repository.url} is stuck for {processing_duration_hours} hours — queuing for re-onboarding"
121120
)
122-
if repository.stuck_requires_re_onboard:
123-
logger.warning(
124-
f"Repo {repository.url} is stuck due to force-push or dangling commit. Will be re-onboarded"
125-
)
126-
raise ReOnboardingRequiredError()
127-
raise StuckRepoError()
121+
raise ReOnboardingRequiredError()
128122

129123
async def _process_repositories(self):
130124
"""
@@ -258,11 +252,6 @@ async def _process_single_repository(self, repository: Repository):
258252

259253
logger.info("Incremental processing completed successfully")
260254
processing_state = RepositoryState.COMPLETED
261-
except StuckRepoError:
262-
logger.error(
263-
f"Repo {repository.url} is stuck for unkown reason, marking it as stuck until manually resolved!"
264-
)
265-
processing_state = RepositoryState.STUCK
266255
except ReOnboardingRequiredError:
267256
logger.info(f"Repo {repository.url} needs re-onboarding, deferring until weekend")
268257
processing_state = RepositoryState.PENDING_REONBOARD

0 commit comments

Comments
 (0)