Skip to content

fix cloud provider #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025
Merged

fix cloud provider #191

merged 2 commits into from
Jun 4, 2025

Conversation

dudizimber
Copy link
Collaborator

@dudizimber dudizimber commented Jun 4, 2025

fix task parsing

fix #172

Summary by CodeRabbit

  • Bug Fixes
    • Improved task validation to automatically remove unknown properties and relax strictness during validation.
    • Standardized the cloud provider reference in job data to always use 'gcp' for relevant tasks.

fix task parsing
Copy link

coderabbitai bot commented Jun 4, 2025

Walkthrough

The changes update validation logic in the MongoDB task repository to strip unknown properties and relax strictness, and modify the task queue repository to use a hardcoded cloud provider value ('gcp') instead of dynamically referencing it from the task payload. No structural or control flow changes are introduced.

Changes

File(s) Change Summary
backend/services/db-importer-worker/src/repositories/tasks/TasksDBMongoRepository.ts Updated RDBTask.validateSync to use { stripUnknown: true, strict: false } options.
backend/services/db-importer/src/repositories/tasksQueue/TaskQueueBullMQRepository.ts Replaced task.payload.cloudProvider with static string 'gcp' in job data objects.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TaskQueueBullMQRepository
    participant JobNode

    User->>TaskQueueBullMQRepository: Submit RDB import/export task
    TaskQueueBullMQRepository->>JobNode: Enqueue job with cloudProvider='gcp'
    JobNode-->>TaskQueueBullMQRepository: Job status/progress
    TaskQueueBullMQRepository-->>User: Progress/notification updates
Loading

Assessment against linked issues

Objective Addressed Explanation
Develop RDB import/export service, integrate with API, handle file upload, validate files, enforce size, etc. (#172)
Use reliable protocols/tools, support RDB v12, provide progress, error handling, notifications, logging, etc. (#172)
Integrate with existing API, infra, authentication, authorization, and support GCS export (#172)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Poem

A bunny hopped through code so neat,
Swapping clouds for GCP’s seat.
Tasks now validate with care,
Stripping unknowns from everywhere.
With queues aligned and jobs in sync,
This rabbit’s work is done, I think!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Jun 4, 2025

Tofu Plan Output - observability_stack_ctrl_plane_infra


�[0m�[1m�[32mNo changes.�[0m�[1m Your infrastructure matches the configuration.�[0m

�[0mOpenTofu has compared your real infrastructure against your configuration and
found no differences, so no changes are needed.

Copy link

github-actions bot commented Jun 4, 2025

Tofu Plan Output - observability_stack_ctrl_plane_k8s


OpenTofu used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  �[33m~�[0m update in-place�[0m

OpenTofu will perform the following actions:

�[1m  # kubernetes_namespace.api�[0m will be updated in-place
�[0m  �[33m~�[0m�[0m resource "kubernetes_namespace" "api" {
        id                               = "api"
        �[90m# (1 unchanged attribute hidden)�[0m�[0m

      �[33m~�[0m�[0m metadata {
          �[33m~�[0m�[0m labels           = {
              �[31m-�[0m�[0m "argocd.argoproj.io/instance" = "observability-stack" �[90m-> null�[0m�[0m
            }
            name             = "api"
            �[90m# (4 unchanged attributes hidden)�[0m�[0m
        }
    }

�[1mPlan:�[0m 0 to add, 1 to change, 0 to destroy.
�[0m

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c2b4c11 and 26c0fa3.

📒 Files selected for processing (2)
  • backend/services/db-importer-worker/src/repositories/tasks/TasksDBMongoRepository.ts (1 hunks)
  • backend/services/db-importer/src/repositories/tasksQueue/TaskQueueBullMQRepository.ts (6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
backend/services/db-importer-worker/src/repositories/tasks/TasksDBMongoRepository.ts (1)
backend/services/db-importer-worker/src/schemas/rdb-task.ts (2)
  • RDBTask (87-120)
  • RDBTaskType (122-122)
🔇 Additional comments (2)
backend/services/db-importer/src/repositories/tasksQueue/TaskQueueBullMQRepository.ts (2)

214-214:

✅ Verification successful

Verify hardcoded cloud provider for control plane operations.

The multi-shard export flow now uses hardcoded 'gcp' instead of task.payload.cloudProvider for control plane operations (RDB merge monitoring and requesting). This suggests these operations always run on GCP regardless of the original task's cloud provider.

Please verify that this hardcoding aligns with the system architecture where control plane operations are exclusively on GCP:

Also applies to: 229-229


🏁 Script executed:

#!/bin/bash
# Description: Verify control plane operations and cloud provider usage patterns
# Expected: Confirm control plane jobs always use GCP

# Search for other control plane related cloud provider usage
rg -A 3 -B 3 "CTRL_PLANE" --type ts

# Search for cloudProvider usage in schemas to understand expected values
rg -A 5 -B 5 "cloudProvider.*gcp|gcp.*cloudProvider" --type ts

Length of output: 83097


Control plane operations correctly hardcode GCP

I’ve verified that every control-plane job node in TaskQueueBullMQRepository.ts—and its associated tests—consistently uses 'gcp' for cloudProvider, matching the architecture where control-plane tasks run exclusively on GCP. No further changes are needed.


393-393:

✅ Verification successful

Verify hardcoded cloud provider for validation jobs.

The import RDB flow now uses hardcoded 'gcp' for format and size validation jobs that run on the control plane. This change is consistent with the export flow modifications.

Please confirm that validation jobs (format and size validation) are designed to run exclusively on the GCP control plane:

Also applies to: 410-410, 430-430, 448-448


🏁 Script executed:

#!/bin/bash
# Description: Verify validation job schemas expect GCP cloud provider
# Expected: Validation job schemas should accept 'gcp' as cloudProvider

# Search for validation job schemas and their cloudProvider requirements
ast-grep --pattern 'RdbImportValidateRDBFormat: $_'
ast-grep --pattern 'RdbImportValidateRDBSize: $_'
ast-grep --pattern 'RdbImportMonitorFormatValidationProgress: $_'
ast-grep --pattern 'RdbImportMonitorSizeValidationProgress: $_'

Length of output: 239


I’m not seeing any schema definitions for those job types—let’s locate where they’re declared and how cloudProvider is consumed. Running these searches should clarify whether they accept only 'gcp':


🏁 Script executed:

#!/bin/bash
# Find references/definitions of the validation jobs
rg -n 'RdbImportValidateRDBFormat' -C5
rg -n 'RdbImportValidateRDBSize' -C5
rg -n 'RdbImportMonitorFormatValidationProgress' -C5
rg -n 'RdbImportMonitorSizeValidationProgress' -C5

# Inspect the enqueue calls in TaskQueueBullMQRepository around where cloudProvider is set
rg -n "cloudProvider" -C3 backend/services/db-importer/src/repositories/tasksQueue/TaskQueueBullMQRepository.ts
sed -n '380,480p' backend/services/db-importer/src/repositories/tasksQueue/TaskQueueBullMQRepository.ts

Length of output: 64580


Validation jobs scheduled on GCP control plane

I’ve confirmed that all four validation tasks in TaskQueueBullMQRepository.ts are explicitly queued with

cloudProvider: 'gcp'
clusterId: process.env.CTRL_PLANE_CLUSTER_ID
region:   process.env.CTRL_PLANE_REGION

and nested under the same control-plane environment (including projectId and namespace where applicable). Their corresponding TypeBox schemas (RdbImportValidateRDBFormatProcessorDataSchema, RdbImportValidateRDBSizeProcessorDataSchema, RdbImportMonitorFormatValidationProgressProcessorDataSchema, RdbImportMonitorSizeValidationProgressProcessorDataSchema) all use SupportedCloudProviderSchema, which includes 'gcp'.

No changes needed here.

Comment on lines +33 to +36
return RDBTask.validateSync(task, {
stripUnknown: true,
strict: false
}) as RDBTaskType;
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Approve relaxed validation to handle legacy data.

The change to use { stripUnknown: true, strict: false } makes task validation more permissive, which should resolve parsing issues with existing database records that contain extra fields not defined in the current schema.

Please verify that this change doesn't introduce data integrity risks by ensuring critical fields are still validated:


🏁 Script executed:

#!/bin/bash
# Description: Verify the RDBTask schema still validates required fields properly
# Expected: Required fields should still be enforced despite relaxed validation

# Check the RDBTask schema definition for required fields
rg -A 20 -B 5 "export const RDBTask.*=.*Yup\.object" backend/services/db-importer-worker/src/schemas/

# Look for any test cases that verify validation behavior
fd "test.*task.*ts$|spec.*task.*ts$" --exec rg -l "validateSync|RDBTask" {}

Length of output: 2647


Relaxed validation approved; ensure required fields are enforced

Verification confirms that the RDBTask schema still marks all critical properties as required:

  • taskId (required)
  • type (one of TaskTypes, required)
  • createdAt (required)
  • updatedAt (required)
  • status (default + required)

However, there are no existing tests exercising RDBTask.validateSync to verify that missing required fields still cause validation errors under the new { stripUnknown: true, strict: false } options.

Please add or update unit tests to confirm that:

  • A task missing any required field is rejected by validateSync.
  • Unknown or extra properties are stripped without impacting required-field enforcement.
🤖 Prompt for AI Agents
In
backend/services/db-importer-worker/src/repositories/tasks/TasksDBMongoRepository.ts
around lines 33 to 36, the validation call uses relaxed options { stripUnknown:
true, strict: false } which may allow missing required fields to pass unnoticed.
To fix this, add or update unit tests for RDBTask.validateSync that verify tasks
missing any required fields are rejected and that extra unknown properties are
stripped without affecting required field validation. This ensures data
integrity while allowing legacy data compatibility.

@dudizimber dudizimber merged commit 62ee44d into main Jun 4, 2025
22 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jun 5, 2025
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.

Create RDB import service
2 participants