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

refactor(x/upgrade): configure go-getter #18470

Merged
merged 5 commits into from
Nov 15, 2023
Merged

refactor(x/upgrade): configure go-getter #18470

merged 5 commits into from
Nov 15, 2023

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Nov 15, 2023

Description

A-18


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
  • added ! to 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
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • 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.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • New Features

    • Improved settings for file downloading using go-getter.
  • Breaking Changes

    • The upgrade module no longer stores the app version; it's now retrieved and set via ParamStore.
  • Refactor

    • Refactored file download functions to enhance performance and reliability.
    • Introduced a new parameter for better daemon identification during upgrades.

Copy link
Contributor

coderabbitai bot commented Nov 15, 2023

Walkthrough

Walkthrough

The recent updates include enhancements to the go-getter configuration for better handling of settings and security, as well as a significant architectural change where the upgrade module no longer directly stores the app version. Instead, it now interacts with the ParamStore in baseapp to get and set the app version. Additionally, the file downloading process within the upgrade plan has been refined with a new function that allows for more control and customization.

Changes

File(s) Summary
x/upgrade/CHANGELOG.md Added notes about improvements to go-getter settings and a breaking change related to app version handling in the upgrade module.
x/upgrade/.../downloader.go Introduced getFile function for enhanced file downloading using go-getter, replacing getter.GetFile with a more secure and configurable approach.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

@julienrbrt julienrbrt marked this pull request as ready for review November 15, 2023 08:21
@julienrbrt julienrbrt requested review from a team as code owners November 15, 2023 08:21
@julienrbrt julienrbrt added backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release and removed backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release labels Nov 15, 2023
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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4ee4046 and 418852d.
Files ignored due to filter (1)
  • x/upgrade/go.mod
Files selected for processing (2)
  • x/upgrade/CHANGELOG.md (1 hunks)
  • x/upgrade/plan/downloader.go (4 hunks)
Additional comments: 2
x/upgrade/CHANGELOG.md (1)
  • 26-34: The changelog update correctly reflects the changes made in the pull request. It is important to ensure that the links to the pull requests are correct and that the descriptions accurately represent the changes made. The entry for the state machine breaking change is particularly important as it signals a significant alteration that could affect users and developers. It is well-documented and includes a link to the relevant pull request for further details.
x/upgrade/plan/downloader.go (1)
  • 146-165: The getFile function uses a default HTTP client from cleanhttp.DefaultClient(). It's important to ensure that this client is properly configured for the use case, especially regarding timeouts and other relevant settings. If the default settings are not appropriate, consider configuring the client with custom settings.

Comment on lines 26 to 34
// NOTE: This functions does not check the provided url for validity.
func DownloadUpgrade(dstRoot, url, daemonName string) error {
target := filepath.Join(dstRoot, "bin", daemonName)

// First try to download it as a single file. If there's no error, it's okay and we're done.
if err := getter.GetFile(target, url); err != nil {
if err := getFile(url, target); err != nil {
// If it was a checksum error, no need to try as directory.
if _, ok := err.(*getter.ChecksumError); ok {
return err
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 15, 2023

Choose a reason for hiding this comment

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

The comment on line 26 should be updated to reflect the new behavior of the function, which now checks the validity of the URL using the getFile function. This is important for maintainability and clarity of the codebase.

Copy link
Member Author

Choose a reason for hiding this comment

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

that's not what getFile does.

Copy link
Contributor

Choose a reason for hiding this comment

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

@julienrbrt You're correct, my apologies for the confusion. The getFile function indeed does not perform URL validation; it's responsible for downloading the file using a more secure and configured HTTP client. Thank you for pointing that out. I'll ensure to be more accurate in my future comments.

x/upgrade/plan/downloader.go Show resolved Hide resolved
@julienrbrt julienrbrt added this pull request to the merge queue Nov 15, 2023
Merged via the queue into main with commit e64f3bc Nov 15, 2023
53 of 63 checks passed
@julienrbrt julienrbrt deleted the julien/upgrades branch November 15, 2023 11:40
mergify bot pushed a commit that referenced this pull request Nov 15, 2023
(cherry picked from commit e64f3bc)

# Conflicts:
#	x/upgrade/CHANGELOG.md
#	x/upgrade/go.mod
tac0turtle pushed a commit that referenced this pull request Nov 15, 2023
Co-authored-by: Julien Robert <julien@rbrt.fr>
@faddat faddat mentioned this pull request Nov 8, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release C:x/upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants