Skip to content

fix: remove stale anonymous cleaner job#2269

Merged
baktun14 merged 2 commits intomainfrom
fix/clean-up-anon-job
Nov 24, 2025
Merged

fix: remove stale anonymous cleaner job#2269
baktun14 merged 2 commits intomainfrom
fix/clean-up-anon-job

Conversation

@baktun14
Copy link
Contributor

@baktun14 baktun14 commented Nov 21, 2025

Summary by CodeRabbit

  • Chores

    • Removed the stale anonymous users cleanup feature, including its scheduled job, CLI command, config, service, summarizer, and repository paging logic.
  • Tests

    • Removed the functional test suite covering stale anonymous users cleanup.
  • Bug Fixes

    • Corrected active deployments counting logic so active deployments are properly identified.

✏️ Tip: You can customize this high-level summary in your review settings.

@baktun14 baktun14 marked this pull request as ready for review November 21, 2025 22:26
@baktun14 baktun14 requested a review from a team as a code owner November 21, 2025 22:26
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 21, 2025

Walkthrough

Removes the stale anonymous user cleanup feature: deletes the Helm scheduled job, CLI command, env schema and config service, controller method, repository paging method, the cleaner service and summarizer, and its functional test; also adjusts a deployment repository filter.

Changes

Cohort / File(s) Summary
Helm Infrastructure Configuration
\.helm/console-api-prod-mainnet-values.yaml``
Deleted the scheduled job definition for cleanup-stale-anonymous-users (weekly Monday 09:00 cron, command and args).
CLI Command Registration
apps/api/src/console.ts
Removed the cleanup-stale-anonymous-users CLI command registration and related imports/wiring.
User Configuration
apps/api/src/user/config/env.config.ts, apps/api/src/user/services/user-config/user-config.service.ts
Removed exported envSchema for STALE_ANONYMOUS_USERS_LIVE_IN_DAYS and deleted UserConfigService that used it.
Cleanup Service Layer
apps/api/src/user/services/stale-anonymous-users-cleaner/..., apps/api/src/user/services/stale-anonymous-users-cleaner-summarizer/...
Deleted StaleAnonymousUsersCleanerService, its options interface, and StaleAnonymousUsersCleanerSummarizer (all logic and summary counters removed).
Controller & Data Access
apps/api/src/user/controllers/user/user.controller.ts, apps/api/src/user/repositories/user/user.repository.ts
Removed UserController.cleanUpStaleAnonymousUsers and UserRepository.paginateStaleAnonymousUsers along with related imports.
Functional Tests
apps/api/test/functional/stale-anonymous-users-cleanup.spec.ts
Deleted the entire functional test spec that validated stale anonymous-user cleanup scenarios.
Deployment Repository Logic
apps/api/src/deployment/repositories/deployment/deployment.repository.ts
Changed countActiveByOwner filter on closedHeight from != null to == null (reversed closed/open criteria).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Scheduler as Helm Job / Cron
  participant CLI as CLI Handler
  participant Controller as UserController
  participant Cleaner as StaleAnonymousUsersCleanerService
  participant Repo as UserRepository
  participant WalletSvc as ManagedUserWalletService
  participant DB as Database

  Note over Scheduler,CLI `#D6EAF8`: (previously) scheduled cleanup run
  Scheduler->>CLI: invoke cleanup command
  CLI->>Controller: cleanUpStaleAnonymousUsers(options)
  Controller->>Cleaner: cleanUpStaleAnonymousUsers(options)
  Cleaner->>Repo: paginateStaleAnonymousUsers(inactivityDays,...)
  Repo->>DB: query stale users (paged)
  Cleaner->>WalletSvc: revoke wallets for userIds
  Cleaner->>DB: delete orphaned users
  Note right of Cleaner `#FDEBD0`: emit summary/log
Loading

(Note: the sequence represents the removed control flow; corresponding components/edges were deleted across the diff.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay extra attention to:
    • Ensure no remaining references to removed services/methods (CLI, controller, DI registrations).
    • The closedHeight filter change in deployment.repository.ts — verify intended semantics and tests.
    • Deleted functional test — confirm no other tests rely on its setup utilities.

Possibly related PRs

Suggested reviewers

  • stalniy
  • ygrishajev

Poem

🐰 I hopped through code at break of day,
I nudged the cron and tucked it away,
No cleaners left to chase the stale,
Quiet fields where rabbits trail. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the primary objective: removing the stale anonymous users cleaner job and all related infrastructure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/clean-up-anon-job

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d37605f and 2993664.

📒 Files selected for processing (1)
  • apps/api/src/deployment/repositories/deployment/deployment.repository.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-03T15:06:34.211Z
Learnt from: baktun14
Repo: akash-network/console PR: 1428
File: apps/api/src/deployment/controllers/deployment/deployment.controller.ts:0-0
Timestamp: 2025-06-03T15:06:34.211Z
Learning: The `getByOwnerAndDseq` method in `apps/api/src/deployment/controllers/deployment/deployment.controller.ts` is intentionally public without the `Protected` decorator because it serves public blockchain data from an indexer, following the pattern of public blockchain APIs.

Applied to files:

  • apps/api/src/deployment/repositories/deployment/deployment.repository.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: Analyze (javascript-typescript)

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Nov 21, 2025

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
730 3 727 0
View the top 3 failed test(s) by shortest run time
Managed Wallet API Deployment Flow should maintain read-only operations during blockchain node outages
Stack Traces | 33.5s run time
Error: expect(received).toMatchObject(expected)

Matcher error: received value must be a non-null object

Received has value: undefined
    at Object.<anonymous> (.../test/functional/managed-api-deployment-flow.spec.ts:201:21)
    at processTicksAndRejections (node:internal/process/task_queues:103:5)
Managed Wallet API Deployment Flow should execute a full deployment cycle with provider JWT auth
Stack Traces | 34.1s run time
Error: expect(received).toMatchObject(expected)

Matcher error: received value must be a non-null object

Received has value: undefined
    at .../test/functional/managed-api-deployment-flow.spec.ts:82:21
    at processTicksAndRejections (node:internal/process/task_queues:103:5)
Managed Wallet API Deployment Flow should execute a full deployment cycle with provider mTLS auth
Stack Traces | 45.2s run time
Error: expect(received).toMatchObject(expected)

Matcher error: received value must be a non-null object

Received has value: undefined
    at .../test/functional/managed-api-deployment-flow.spec.ts:82:21
    at processTicksAndRejections (node:internal/process/task_queues:103:5)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@baktun14 baktun14 merged commit c0c2b5d into main Nov 24, 2025
56 of 58 checks passed
@baktun14 baktun14 deleted the fix/clean-up-anon-job branch November 24, 2025 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments