Skip to content
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

fix(dashmate): invalid platform version in the status command #2249

Merged
merged 5 commits into from
Oct 18, 2024

Conversation

shumkov
Copy link
Member

@shumkov shumkov commented Oct 16, 2024

Issue being fixed or feature implemented

The dashmate status command shows the tenderdash version as "Platform Version" which is confusing.

What was done?

  • Added version command to Drive
  • Display Drive version as Platform Version in the status command

How Has This Been Tested?

Calling the status command locally

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Introduced a new CLI command to display the current software version for RS-Drive-ABCI.
    • Enhanced the platform status functionality with improved error handling and version retrieval for the 'drive_abci' service.
  • Bug Fixes

    • Updated logic for assigning platform version to ensure accurate reporting based on service status.
  • Refactor

    • Simplified method signatures in the PlatformStatusCommand for improved clarity.
    • Adjusted the getDriveInfo function to include a version property in the returned object.
    • Updated the .yarnrc.yml file for better package management and error handling.

@shumkov shumkov linked an issue Oct 16, 2024 that may be closed by this pull request
@shumkov shumkov added this to the 1.4.2 milestone Oct 18, 2024
@shumkov shumkov marked this pull request as ready for review October 18, 2024 11:25
Copy link
Contributor

coderabbitai bot commented Oct 18, 2024

Walkthrough

This pull request introduces several modifications across multiple files in the dashmate and rs-drive-abci packages. Key changes include updates to the runWithDependencies methods in the GroupStatusCommand and StatusCommand classes to adjust how platform version information is assigned. The PlatformStatusCommand class has simplified its method signature. Additionally, enhancements were made to the getPlatformScopeFactory function to include version information for the drive_abci service. A new Version command was added to the RS-Drive-ABCI server CLI.

Changes

File Path Change Summary
packages/dashmate/src/commands/group/status.js Updated runWithDependencies in GroupStatusCommand to assign platform.drive.version.
packages/dashmate/src/commands/status/index.js Updated runWithDependencies in StatusCommand to assign platform.drive.version based on service status.
packages/dashmate/src/commands/status/platform.js Simplified runWithDependencies method signature in PlatformStatusCommand by removing getConnectionHost.
packages/dashmate/src/status/scopes/platform.js Enhanced getDriveInfo function to include a version property in the returned object.
packages/rs-drive-abci/src/main.rs Introduced Version command in CLI, updated run method, added print_version function.
.yarnrc.yml Updated npmAuditExcludePackages to include elliptic, corrected indentation for an entry.

Possibly related PRs

  • fix(dashmate): invalid drive status check #2248: The changes in this PR improve the logic for determining the platform status in the StatusCommand class, which is directly related to the modifications made in the runWithDependencies method of the StatusCommand class in the main PR.
  • chore: update to latest rust dash core with x11 optional #2251: The update to the dashcore-rpc dependency in this PR may indirectly relate to the overall functionality and stability of the platform, which is relevant to the changes made in the main PR regarding platform status checks and service interactions.

Suggested labels

bug

Suggested reviewers

  • QuantumExplorer

🐰 In the land of code, where changes bloom,
A version command now breaks the gloom.
With platforms updated, the logic refined,
A simpler signature, more clarity aligned.
So hop along, let the new features play,
In the world of Dashmate, we code and sway! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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 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
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

🧹 Outside diff range and nitpick comments (1)
packages/dashmate/src/status/scopes/platform.js (1)

195-210: LGTM: Drive version retrieval implementation

The implementation for retrieving the Drive version is well-structured and aligns with the existing codebase. Good practices observed:

  • Using dockerCompose.execCommand for consistency.
  • Proper error handling to distinguish between Drive-specific and other issues.
  • Trimming the retrieved version string.

Suggestions for minor improvements:

  1. Consider adding a timeout to the Docker command execution to prevent potential hanging:
const driveVersionResult = await Promise.race([
  dockerCompose.execCommand(config, 'drive_abci', 'drive-abci version'),
  new Promise((_, reject) => setTimeout(() => reject(new Error('Command timed out')), 5000))
]);
  1. Enhance the error message when catching non-Drive issues for better debugging:
throw new Error(`Unexpected error while retrieving Drive version: ${e.message}`);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 00df5a6 and f088a3c.

📒 Files selected for processing (5)
  • packages/dashmate/src/commands/group/status.js (1 hunks)
  • packages/dashmate/src/commands/status/index.js (1 hunks)
  • packages/dashmate/src/commands/status/platform.js (0 hunks)
  • packages/dashmate/src/status/scopes/platform.js (2 hunks)
  • packages/rs-drive-abci/src/main.rs (4 hunks)
💤 Files with no reviewable changes (1)
  • packages/dashmate/src/commands/status/platform.js
🧰 Additional context used
🔇 Additional comments (8)
packages/dashmate/src/commands/group/status.js (1)

89-89: LGTM! Verify consistency and update documentation.

The change correctly updates the Platform Version to display the Drive version instead of the Tenderdash version, addressing the issue mentioned in the PR objectives. This modification aligns with the goal of reducing confusion about the actual platform version being used.

To ensure consistency across the codebase, please run the following script:

Consider updating any relevant documentation that explains the Platform Version to reflect this change from Tenderdash version to Drive version.

✅ Verification successful

Verification Successful! All references to the Tenderdash version as the Platform Version have been removed and replaced with the Drive version in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all references to Platform Version now use Drive version instead of Tenderdash version

# Test 1: Search for any remaining references to Tenderdash version as Platform Version
echo "Searching for remaining references to Tenderdash version as Platform Version:"
rg --type js "Platform.*Version.*tenderdash\.version"

# Test 2: Confirm that Drive version is now used for Platform Version
echo "Confirming Drive version is used for Platform Version:"
rg --type js "Platform.*Version.*drive\.version"

Length of output: 634

packages/dashmate/src/commands/status/index.js (1)

119-119: LGTM! The change correctly implements the PR objective.

The modification to use platform.drive.version instead of platform.tenderdash.version for the Platform Version is consistent with the PR objective. This change resolves the issue of displaying the incorrect platform version in the status command output.

To ensure consistency across the codebase, let's verify that platform.drive.version is correctly set elsewhere:

This script will help us confirm that the Drive version is consistently retrieved and used throughout the codebase.

✅ Verification successful

Verified! The usage of platform.drive.version for Platform Version is consistent across the codebase. No issues found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of platform.drive.version

# Test 1: Search for assignments to platform.drive.version
echo "Searching for assignments to platform.drive.version:"
rg --type js 'platform\.drive\.version\s*=' -g '!**/node_modules/**'

# Test 2: Search for the retrieval of Drive version
echo "Searching for Drive version retrieval:"
rg --type js 'getDriveVersion|drive.*version' -g '!**/node_modules/**'

Length of output: 1661

packages/dashmate/src/status/scopes/platform.js (2)

162-162: LGTM: Addition of version property

The addition of the version property to the info object is in line with the PR objective to display the Drive version as the Platform Version. Initializing it as null is a good practice for optional properties.


Line range hint 1-324: Summary: Changes successfully implement PR objectives

The modifications to packages/dashmate/src/status/scopes/platform.js successfully address the PR objective of displaying the Drive version as the Platform Version. Key points:

  1. The implementation is consistent with the existing codebase and follows good practices.
  2. Proper error handling is in place, distinguishing between Drive-specific and other issues.
  3. The changes are non-breaking, as the new version property is optional and initialized as null.

The code changes align well with the stated PR objectives and maintain the overall integrity of the file.

To ensure the changes are correctly implemented across the codebase, please run the following verification script:

packages/rs-drive-abci/src/main.rs (4)

62-65: LGTM: Version command added

The addition of the Version command to the Commands enum is a valuable feature. It provides users with an easy way to check the current software version, which is essential for troubleshooting and ensuring compatibility.


155-155: LGTM: Version command handling added

The run method has been correctly updated to handle the new Version command. The implementation is simple and consistent with the other command handlers.


390-393: LGTM: Version printing function added

The print_version function is implemented correctly. It uses the CARGO_PKG_VERSION environment variable to print the current package version, which is the standard way to access this information in Rust projects.


228-232: LGTM: Improved error handling in main function

The error handling in the main function has been improved. The new implementation using map_err is more idiomatic Rust and provides better error logging. The use of tracing::error! ensures consistency with the project's logging approach.

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

🧹 Outside diff range and nitpick comments (2)
.yarnrc.yml (2)

19-19: Approve: Addition of elliptic to npmAuditExcludePackages

The addition of elliptic to the npmAuditExcludePackages list is a good temporary measure to address a security vulnerability. The TODO comment clearly indicates that this should be removed when a version greater than 6.5.7 is released.

To ensure this temporary fix is not forgotten, would you like me to create a GitHub issue to track the removal of this exclusion when the new version of elliptic is released?


Line range hint 1-46: Consider separating unrelated changes

The changes made to this file, while beneficial for project maintenance, appear to be unrelated to the main objective of this PR (fixing the dashmate status command). Consider separating these changes into a different PR to maintain focus and ease the review process.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f088a3c and ca0c223.

📒 Files selected for processing (1)
  • .yarnrc.yml (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
.yarnrc.yml (1)

Line range hint 7-7: Approve: Indentation correction for @humanwhocodes/object-schema

The indentation for the @humanwhocodes/object-schema entry has been corrected, improving readability and consistency with other entries in the list.

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: 2

🧹 Outside diff range and nitpick comments (2)
packages/dashmate/test/unit/status/scopes/platform.spec.js (2)

126-126: Use a constant for the drive version to avoid hardcoding

The version: '1.4.1' is hardcoded in multiple places within the expectedScope objects. Consider defining a constant or using a variable to represent the version number. This will make future updates easier and reduce the likelihood of inconsistencies.

Example:

+ const driveVersion = '1.4.1';
...
expectedScope = {
  // ...
  drive: {
    dockerStatus: DockerStatusEnum.running,
    serviceStatus: ServiceStatusEnum.up,
-   version: '1.4.1',
+   version: driveVersion,
  },
};

Also applies to: 201-201, 306-306, 363-363, 501-501


389-392: Include an error message when simulating DockerComposeError

Adding an error message to the DockerComposeError will provide more context during test failures and make debugging easier.

Apply this diff:

const error = new DockerComposeError({
  exitCode: 1,
+ message: 'Simulated error for testing drive_abci version command failure',
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ca0c223 and bd518c9.

📒 Files selected for processing (2)
  • packages/dashmate/src/status/scopes/platform.js (2 hunks)
  • packages/dashmate/test/unit/status/scopes/platform.spec.js (13 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/dashmate/src/status/scopes/platform.js
🧰 Additional context used
🔇 Additional comments (2)
packages/dashmate/test/unit/status/scopes/platform.spec.js (2)

3-3: Importing DockerComposeError is appropriate

The added import statement for DockerComposeError is necessary for handling Docker Compose errors in the tests.


274-274: Verify isServiceRunning checks for both services

Ensure that mockDockerCompose.isServiceRunning is being correctly stubbed for both 'drive_tenderdash' and 'drive_abci'. This will ensure that the test accurately reflects the service statuses.

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.

Platform version in status command takes from tenderdash
2 participants