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(tools/cosmovisor): fix wrong dir prepare-upgrade when non archive #23652

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Feb 10, 2025

Description

Fixes the wrong upgrade directory when using cosmovisor prepare-upgrade with non archives.
It actually worked for archives by luck as DownloadUpgrade[1] is opinionated, the way to get the upgrade directory was simply wrong:

[1]:

// This is an opinionated directory structure that corresponds with Cosmovisor requirements.
// If the url is not an archive, it is downloaded and saved to {dstRoot}/bin/{daemonName}.
// If the url is an archive, it is downloaded and unpacked to {dstRoot}.

cc @johnletey


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • Bug Fixes
    • Improved the upgrade process to ensure that binaries are placed in the correct location during non-archive upgrades. This improvement enhances the reliability of the upgrade preparation, reducing potential errors.
    • Released as part of the new version update (v1.7.1), offering users a more streamlined upgrade experience.

@julienrbrt julienrbrt requested a review from a team as a code owner February 10, 2025 16:40
Copy link
Contributor

coderabbitai bot commented Feb 10, 2025

📝 Walkthrough

Walkthrough

The changes update the cosmovisor tool by introducing a new version entry (v1.7.1) in the changelog that documents a bug fix for incorrect directory placement in the prepare-upgrade command. In the code, the prepareUpgradeHandler function has been modified to determine the upgrade binary’s directory by using the UpgradeDir method rather than constructing the path manually. No public API declarations have been modified.

Changes

File Change Summary
tools/cosmovisor/CHANGELOG.md Added new version entry v1.7.1 with a bug fix for wrong directory placement during non-archive upgrades (#23652).
tools/cosmovisor/.../prepare_upgrade.go Updated prepareUpgradeHandler to compute the upgrade binary’s path using UpgradeDir(upgradeInfo.Name) instead of concatenating path components.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant C as Cosmovisor CLI
    participant CFG as Config
    participant L as Logger

    U->>C: Initiate prepare-upgrade command
    C->>CFG: Retrieve upgrade directory (using UpgradeDir)
    CFG-->>C: Return directory path
    C->>C: Execute upgrade binary using computed path
    C->>L: Log errors if encountered
Loading

Suggested labels

C:Confix, C:server/v2

Suggested reviewers

  • akhilkumarpilli
  • facundomedica
  • sontrinh16
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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.

@github-actions github-actions bot added the C:Cosmovisor Issues and PR related to Cosmovisor label Feb 10, 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)
tools/cosmovisor/CHANGELOG.md (1)

43-43: Clear Bug Fix Description with Minor Suggestion
The bug fix entry "* #23652 Fix issue with wrong directory placement when using prepare-upgrade for non archive." clearly references the issue and describes the correction. Consider inserting a hyphen to read "non-archive" for improved clarity and consistency.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7f101e and 93ddbf6.

📒 Files selected for processing (2)
  • tools/cosmovisor/CHANGELOG.md (1 hunks)
  • tools/cosmovisor/cmd/cosmovisor/prepare_upgrade.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.md`: "Assess the documentation for misspellings, gramm...

**/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

  • tools/cosmovisor/CHANGELOG.md
`**/*.go`: Review the Golang code for conformity with the Ub...

**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

  • tools/cosmovisor/cmd/cosmovisor/prepare_upgrade.go
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: tests (00)
  • GitHub Check: test-system-v2
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (3)
tools/cosmovisor/cmd/cosmovisor/prepare_upgrade.go (1)

75-75: LGTM! The directory path construction fix looks correct.

The change from manually constructing the path to using cfg.UpgradeDir method is a good improvement that:

  1. Fixes the incorrect directory placement issue for non-archive upgrades
  2. Makes the code more maintainable by centralizing the directory path logic
  3. Reduces the chance of path construction errors
tools/cosmovisor/CHANGELOG.md (2)

39-39: Version Entry Added Correctly
The addition of the ## v1.7.1 - 2025-01-12 version entry adheres to the changelog guidelines, clearly indicating the new version and its release date.


41-41: Proper Definition of Bug Fixes Section
The "### Bug Fixes" header is appropriately defined and maintains consistency with previous entries, ensuring that users can quickly identify the nature of the fixes included in this release.

@aljo242
Copy link
Collaborator

aljo242 commented Feb 10, 2025

Can you walk us though the flow of this and what the actual error is?

It's unclear wha the error was. What does non-archive mean here?

@gartnera
Copy link
Contributor

I was just going to open a PR to fix this but it looks like someone else already ran into it.

Given our linux/amd64 URL of https://github.com/zeta-chain/node/releases/download/v27.0.1/zetacored-linux-amd64?checksum=sha256:7793f7fed92de036dc3fb3ebc55e5a084b6e032985a29598f989676b46edc2db, cosmovisor prepare-upgrade was downloading with this file structure which is incorrect:

.zetacored/cosmovisor/upgrades/
.zetacored/cosmovisor/upgrades/v27
.zetacored/cosmovisor/upgrades/v27/bin
.zetacored/cosmovisor/upgrades/v27/bin/zetacored
.zetacored/cosmovisor/upgrades/v27/bin/zetacored/bin
.zetacored/cosmovisor/upgrades/v27/bin/zetacored/bin/zetacored

the correct structure is

.zetacored/cosmovisor/upgrades/
.zetacored/cosmovisor/upgrades/v27
.zetacored/cosmovisor/upgrades/v27/bin
.zetacored/cosmovisor/upgrades/v27/bin/zetacored

Full proposal

@julienrbrt
Copy link
Member Author

julienrbrt commented Feb 10, 2025

@aljo242 the message above did a great job at describing the issue :) By non archive I meant non compressed binary, as by luck it would work fine when compressed.
@gartnera Yes, Noble ran into it.

@julienrbrt julienrbrt enabled auto-merge February 10, 2025 23:03
@julienrbrt julienrbrt disabled auto-merge February 11, 2025 10:12
@aljo242 aljo242 merged commit bb03cd1 into main Feb 11, 2025
71 of 74 checks passed
@aljo242 aljo242 deleted the julien/fix-wrong-dir branch February 11, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:Cosmovisor Issues and PR related to Cosmovisor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants