Skip to content

Fix for scheduler#251

Merged
vizsatiz merged 10 commits into
developfrom
fix/scheduler_issue
Mar 25, 2026
Merged

Fix for scheduler#251
vizsatiz merged 10 commits into
developfrom
fix/scheduler_issue

Conversation

@vizsatiz
Copy link
Copy Markdown
Member

@vizsatiz vizsatiz commented Mar 24, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Scheduler now uses in-memory job persistence to avoid Redis-related issues.
    • Service role now grants immediate admin access for the designated service identity.
    • Email-driven jobs now fail fast on missing/invalid dynamic queries or result rows to reduce silent errors.
  • Improvements

    • Dynamic query email jobs generate CSV reports, upload them to cloud storage, and include a 7-day presigned download link.
  • Refactor

    • Simplified scheduler initialization and startup flow.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Removed passing config into SchedulerManager at import; swapped APScheduler job store from Redis to in-memory; added a role-id short-circuit for 'floconsole-service'; refactored dynamic-query email job to use datasource config + DynamicQueryService, produce CSV, upload to cloud storage, and send a presigned download URL (7 days).

Changes

Cohort / File(s) Summary
Scheduler server entry & manager
wavefront/server/apps/floware/floware/server.py, wavefront/server/apps/floware/floware/services/scheduler_manager.py
Instantiate SchedulerManager() without config at import; removed config parameter from SchedulerManager.__init__; replaced APScheduler RedisJobStore with MemoryJobStore; scheduler lifecycle calls (start, register pollers/recovery, shutdown) unchanged.
Authorization fast-path
wavefront/server/modules/user_management_module/user_management_module/utils/user_utils.py
check_is_admin now immediately returns True when role_id == 'floconsole-service', bypassing role_repository lookup; otherwise behavior unchanged.
Scheduled email / dynamic query flow
wavefront/server/apps/floware/floware/services/scheduled_job_service.py
_execute_email_dynamic_query_job now accepts job_timezone, resolves runtime params, loads datasource via get_datasource_config(...), obtains dynamic YAML via DynamicQueryService.get_dynamic_yaml_query(...), errors on empty query set, validates results, converts rows to CSV, uploads to cloud storage, and embeds a presigned download URL (SIGNED_URL_EXPIRY_SECONDS = 7 days) in the email; JSON attachment creation removed.

Sequence Diagram(s)

sequenceDiagram
    participant Scheduler as SchedulerManager
    participant JobSvc as ScheduledJobService
    participant DynSvc as DynamicQueryService
    participant Plugin as DatasourcePlugin
    participant Storage as CloudStorage
    participant Mail as EmailService

    Scheduler->>JobSvc: trigger email dynamic-query job (job_row, timezone)
    JobSvc->>JobSvc: resolve runtime params (job_timezone)
    JobSvc->>DynSvc: get_dynamic_yaml_query(query_id)
    DynSvc-->>JobSvc: yaml_query (or empty -> error)
    alt empty query set
        JobSvc-->>Scheduler: raise ValueError (fail job)
    else query present
        JobSvc->>Plugin: build plugin with datasource_config
        Plugin->>Plugin: execute query -> rows
        Plugin-->>JobSvc: result {status, result}
        JobSvc->>JobSvc: validate structure (status == "success", list rows)
        JobSvc->>Storage: upload CSV report
        Storage-->>JobSvc: presigned_url (7d)
        JobSvc->>Mail: send email with presigned_url
        Mail-->>Scheduler: send status
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through schedulers, took Redis off the trail,

gave a service a shortcut and watched params set sail,
I spun YAML queries into tidy CSV art,
uploaded a link and sent it to depart,
a little rabbit's patchwork fix — light-footed and hale.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix for scheduler' is overly vague and does not clearly describe the actual changes. The PR modifies scheduler initialization, job store persistence (Redis to Memory), authorization logic, and email job execution—none of which are conveyed by the generic title. Provide a more specific title that describes the main change, such as 'Replace Redis job store with in-memory storage in scheduler' or 'Update scheduler initialization and job persistence strategy'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/scheduler_issue

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@vizsatiz vizsatiz merged commit 8c1ecab into develop Mar 25, 2026
10 checks passed
@vizsatiz vizsatiz deleted the fix/scheduler_issue branch March 25, 2026 06:24
thomastomy5 pushed a commit that referenced this pull request Apr 27, 2026
* Fix for scheduler

* Fix for service auth roleid

* Fix for datasource init

* fix for scheduled querries

* fix for scheduled querries for sending csv link as email

* fix for dynamic query

* fix for dynamic query

* fix for scheduled queries and its UI

* fix for scheduled job to send as CSV

* Making export rate limit to 5 secs
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.

1 participant