Skip to content

feat: delete indexer from cluster #1284

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 3 commits into from
Apr 3, 2025

Conversation

nikhilsinhaparseable
Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable commented Apr 2, 2025

DELETE /cluster/{node_url} to handle deletion of all nodes
including ingestor and indexer

Summary by CodeRabbit

  • New Features

    • Unified deletion functionality now supports removal of metadata for varying node types.
    • Standardized metadata file path retrieval enables consistent data management.
  • Refactor

    • Updated endpoint naming, authorization actions, and error messaging to reflect the broader deletion scope.
    • Refined file deletion operations across storage systems for improved efficiency.

Copy link
Contributor

coderabbitai bot commented Apr 2, 2025

Walkthrough

The changes update the naming and functionality for deleting metadata associated with nodes. The previously ingestor-specific interfaces and functions are now made generic to cover both ingestors and indexers. The core removal function has been renamed from remove_ingestor to remove_node and enhanced with a helper to remove metadata. Similar renames occur across various modules including HTTP route handling, Azure Blob, local file system, S3, and object storage traits. Additionally, a file path method was added to the Metadata trait for both ingestor and indexer structures. An enum variant in the RBAC module was also renamed accordingly.

Changes

File(s) Change Summary
src/handlers/http/cluster/mod.rs Renamed remove_ingestor to remove_node; added helper function remove_node_metadata to delete metadata for both ingestors and indexers.
src/handlers/http/modal/mod.rs Added a new method file_path to the Metadata trait and provided implementations in IngestorMetadata and IndexerMetadata.
src/handlers/http/modal/query_server.rs Updated DELETE route to use remove_node instead of remove_ingestor and changed the authorization action from Deleteingestor to DeleteNode.
src/storage/azure_blob.rs, src/storage/localfs.rs, src/storage/object_storage.rs, src/storage/s3.rs Renamed deletion methods from try_delete_ingestor_meta to try_delete_node_meta and updated parameter names and error messages accordingly.
src/rbac/role.rs Renamed enum variant from Deleteingestor to DeleteNode to reflect the updated deletion logic.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant QS as QueryServer
    participant CH as Cluster Handler
    participant OS as Object Storage

    C->>QS: DELETE /{node_url} (request deletion)
    QS->>CH: Forward request to remove_node
    CH->>CH: Validate node liveness and determine metadata type
    CH->>OS: Call remove_node_metadata for node deletion
    OS-->>CH: Return success or error from try_delete_node_meta
    CH-->>QS: Return deletion result
    QS-->>C: Send final response
Loading

Possibly related PRs

Suggested reviewers

  • parmesant

Poem

I'm a rabbit hopping through code's maze,
Skipping from ingestor to node in a swift phase,
Metadata now in tune, paths shining bright,
Each function refined with a touch of delight,
With whimsical hops I celebrate changes in flight! 🐇

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
Contributor

@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: 0

🧹 Nitpick comments (5)
src/storage/s3.rs (1)

730-749: Update parameter name and error message for consistency

The function name has been updated to reflect generalized node handling, but there are still inconsistencies in parameter naming and error messaging.

Consider updating the following for better consistency:

async fn try_delete_node_meta(
-    &self,
-    ingestor_filename: String,
+    &self,
+    node_filename: String,
) -> Result<(), ObjectStorageError> {
-    let file = RelativePathBuf::from(&ingestor_filename);
+    let file = RelativePathBuf::from(&node_filename);
    match self.client.delete(&to_object_store_path(&file)).await {
        Ok(_) => Ok(()),
        Err(err) => {
            // if the object is not found, it is not an error
            // the given url path was incorrect
            if matches!(err, object_store::Error::NotFound { .. }) {
                error!("Node does not exist");
                Err(err.into())
            } else {
-                error!("Error deleting ingestor meta file: {:?}", err);
+                error!("Error deleting node meta file: {:?}", err);
                Err(err.into())
            }
        }
    }
}
src/handlers/http/modal/query_server.rs (1)

336-344: Update route path and comment to match node terminology

The function call has been updated to use remove_node instead of remove_ingestor, but the route path and comment still use "ingestor" terminology.

Consider updating the route path and comment to maintain terminology consistency:

-            // DELETE "/cluster/{ingestor_domain:port}" ==> Delete an ingestor from the cluster
+            // DELETE "/cluster/{node_url:port}" ==> Delete a node from the cluster
            .service(
-                web::scope("/{ingestor}").service(
+                web::scope("/{node_url}").service(
                    web::resource("").route(
                        web::delete()
                            .to(cluster::remove_node)
                            .authorize(Action::Deleteingestor),
                    ),
                ),
            )

Additionally, consider updating the authorization action name from Action::Deleteingestor to a more generic Action::DeleteNode in a future PR.

src/storage/localfs.rs (1)

328-334: Rename parameter for consistency with function name

The function name has been updated to reflect the generalized node handling, but the parameter name still refers specifically to "ingestor".

Consider updating the parameter name for consistency:

async fn try_delete_node_meta(
    &self,
-    ingestor_filename: String,
+    node_filename: String,
) -> Result<(), ObjectStorageError> {
-    let path = self.root.join(ingestor_filename);
+    let path = self.root.join(node_filename);
    Ok(fs::remove_file(path).await?)
}
src/storage/azure_blob.rs (1)

647-666: Update parameter name and error message for consistency

The function name has been updated to reflect generalized node handling, but there are still inconsistencies in parameter naming and error messaging.

Consider updating the following for better consistency:

async fn try_delete_node_meta(
    &self,
-    ingestor_filename: String,
+    node_filename: String,
) -> Result<(), ObjectStorageError> {
-    let file = RelativePathBuf::from(&ingestor_filename);
+    let file = RelativePathBuf::from(&node_filename);
    match self.client.delete(&to_object_store_path(&file)).await {
        Ok(_) => Ok(()),
        Err(err) => {
            // if the object is not found, it is not an error
            // the given url path was incorrect
            if matches!(err, object_store::Error::NotFound { .. }) {
                error!("Node does not exist");
                Err(err.into())
            } else {
-                error!("Error deleting ingestor meta file: {:?}", err);
+                error!("Error deleting node meta file: {:?}", err);
                Err(err.into())
            }
        }
    }
}
src/storage/object_storage.rs (1)

204-207: Renamed method for consistent node terminology

The method has been renamed from try_delete_ingestor_meta to try_delete_node_meta while maintaining the same signature. This change aligns with the shift to more generic node handling in the codebase, allowing for consistent treatment of both ingestor and indexer nodes.

Note that the parameter name ingestor_filename remains unchanged, which could be confusing since the method now handles both ingestor and indexer metadata.

Consider renaming the parameter from ingestor_filename to node_filename for consistency with the method name:

    async fn try_delete_node_meta(
        &self,
-       ingestor_filename: String,
+       node_filename: String,
    ) -> Result<(), ObjectStorageError>;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 40876cd and 7873f38.

📒 Files selected for processing (7)
  • src/handlers/http/cluster/mod.rs (5 hunks)
  • src/handlers/http/modal/mod.rs (3 hunks)
  • src/handlers/http/modal/query_server.rs (1 hunks)
  • src/storage/azure_blob.rs (1 hunks)
  • src/storage/localfs.rs (1 hunks)
  • src/storage/object_storage.rs (1 hunks)
  • src/storage/s3.rs (1 hunks)
🧰 Additional context used
🧬 Code Definitions (6)
src/handlers/http/modal/query_server.rs (1)
src/handlers/http/cluster/mod.rs (1)
  • remove_node (710-736)
src/storage/s3.rs (3)
src/storage/azure_blob.rs (1)
  • try_delete_node_meta (647-666)
src/storage/object_storage.rs (1)
  • try_delete_node_meta (204-207)
src/storage/localfs.rs (1)
  • try_delete_node_meta (328-334)
src/storage/object_storage.rs (3)
src/storage/localfs.rs (1)
  • try_delete_node_meta (328-334)
src/storage/azure_blob.rs (1)
  • try_delete_node_meta (647-666)
src/storage/s3.rs (1)
  • try_delete_node_meta (730-749)
src/storage/azure_blob.rs (3)
src/storage/s3.rs (1)
  • try_delete_node_meta (730-749)
src/storage/object_storage.rs (1)
  • try_delete_node_meta (204-207)
src/storage/localfs.rs (1)
  • try_delete_node_meta (328-334)
src/handlers/http/cluster/mod.rs (2)
src/handlers/http/cluster/utils.rs (6)
  • to_url_string (197-204)
  • check_liveness (175-195)
  • new (35-47)
  • new (62-80)
  • new (95-113)
  • new (125-132)
src/storage/mod.rs (4)
  • default (205-225)
  • from (157-163)
  • new (182-184)
  • new (195-201)
src/handlers/http/modal/mod.rs (1)
src/option.rs (1)
  • file_path (85-97)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: coverage
🔇 Additional comments (7)
src/handlers/http/modal/mod.rs (3)

556-556: Added new method to Metadata trait for consistent file path access

The addition of the file_path method to the Metadata trait provides a standardized way to retrieve the file path for different node types. This is a good abstraction that will make it easier to handle different node types uniformly when working with node metadata.


570-572: Potential method name confusion but works as expected

The implementation for IngestorMetadata calls the struct's own method with the same name, which could look like recursive calls at first glance. However, Rust can differentiate between trait methods and struct methods with the same name, so this implementation works as expected.


586-588: Consistent implementation across node types

The implementation for IndexerMetadata follows the same pattern as that for IngestorMetadata, ensuring consistency between the two node types. This uniformity is good for code maintainability.

src/handlers/http/cluster/mod.rs (4)

647-649: Added check for empty node lists

This check is a good defensive programming practice that prevents unnecessary processing when the input list is empty. It improves efficiency by avoiding the overhead of setting up parallel processing for an empty collection.


710-736: Refactored function to handle multiple node types

The function has been renamed from remove_ingestor to remove_node and updated to handle both ingestor and indexer node types. This change enables the deletion of any node type from the cluster, enhancing the functionality as described in the PR objective.

The error message has also been updated to be more generic ("node" instead of "ingestor").


739-775: Added a reusable helper function for node metadata removal

The new remove_node_metadata function is a well-designed generic helper that works with any node type implementing the required traits. It:

  1. Gets the node type from the default instance
  2. Fetches relevant metadata objects from storage
  3. Filters for the specific domain name
  4. Attempts to delete the metadata file
  5. Properly handles errors and provides meaningful feedback

Using generics here allows for code reuse and ensures future node types can be handled without duplicating logic.


764-772: Successfully using the new trait method for consistent file path handling

This code demonstrates the benefit of adding the file_path() method to the Metadata trait. By calling node_metadatas[0].file_path().to_string(), the code works with any node type without needing to know its specific implementation details.

Also, the function correctly uses the renamed try_delete_node_meta method from the ObjectStorage trait, showing good consistency across the codebase.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 2, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 2, 2025
Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
.github/workflows/coverage.yaml (1)

39-40: Environment Variable Update for Clippy Check
The updated environment variables (RUSTFLAGS and CMAKE_ARGS) appropriately replace the old CMAKE_FLAGS. Please verify that:

  • The syntax for RUSTFLAGS (including the embedded quotes) is correctly interpreted by downstream Rust tooling.
  • Downstream CI steps or scripts that previously depended on CMAKE_FLAGS are updated accordingly to use CMAKE_ARGS.

Consider adding a brief comment in the YAML file referencing why these variables were updated to aid future maintainers.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c88fe22 and 5f2aff7.

📒 Files selected for processing (1)
  • .github/workflows/coverage.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: coverage

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 2, 2025
DELETE /cluster/{node_url} to handle deletion of all nodes
including ingestor and indexer
Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
src/storage/localfs.rs (1)

328-331: Function renamed to align with node generalization.

The function has been renamed from try_delete_ingestor_meta to try_delete_node_meta as part of the broader refactoring to generalize "ingestor" to "node" across the codebase. This change allows the function to be used for both ingestor and indexer nodes, supporting the new feature to delete all nodes within a cluster.

The implementation now correctly uses fs::remove_file instead of fs::remove_dir_all (according to the AI summary), which suggests a change in how node metadata is stored - from a directory to a file structure. This is a significant behavior change.

Consider adding a function-level documentation comment to clarify the purpose of this function and its role in node deletion.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between caa6eb0 and 0ba22a8.

📒 Files selected for processing (1)
  • src/storage/localfs.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: coverage
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka aarch64-apple-darwin

@nitisht nitisht merged commit eb7bb31 into parseablehq:main Apr 3, 2025
14 checks passed
@nikhilsinhaparseable nikhilsinhaparseable deleted the delete-indexer branch April 3, 2025 12:59
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