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

Jetpack Backup: Update copy site flow to use the getRestoreProgress selector as restore status source of truth #91145

Merged
merged 4 commits into from
May 30, 2024

Conversation

Initsogar
Copy link
Contributor

@Initsogar Initsogar commented May 25, 2024

Related to p1716438389407439-slack-CS8UYNPEE

Proposed Changes

  • Use getRestoreProgress() from calypso/state/selectors/get-restore-progress as the source of truth of the restore progress.

Why are these changes being made?

The clone flow uses two APIs to validate the restore progress:
GET /rewind — to determine if the restore finished (among other things)
GET /rewind/{restoreId}/restore-status — for the progress bar status

There are cases where /restore-status reports as finished, but /rewind does not yet due to cache issues or an error fetching the restore status. This will cause the restore progress page to stop querying the restore status and become stuck.

So the plan is to use /restore-status and its corresponding getRestoreProgress() selector to be the source of truth and prevent the progress from becoming stuck.

Testing Instructions

Unit tests

Ensure unit tests are passing:

yarn run test-client client/my-sites/backup/clone-flow/test/index.jsx

Test Suites: 1 passed, 1 total
Tests:       5 passed, 5 total
Snapshots:   0 total
Time:        4.754 s
Ran all test suites matching /client\/my-sites\/backup\/clone-flow\/test\/index.jsx/i.

You might see some selectors warning that we should optimize in another iteration.

Test copy site flow

  • Spin up a Jetpack Cloud live branch
  • Spin up a Jurassic Ninja site
  • Pick an existing site with Jetpack VaultPress Backup plan and at least one backup
  • Navigate to the Backup page in the sidebar menu
  • Click on Copy site at the top right of the page
  • Now follow the instructions depending on the type of test you want to make:

New staging site

  • Click on Enter credentials for a new destination site +
  • Enter your Jurassic Ninja server credentials and then click on Confirm credentials
  • After validating credentials, click on Continue
  • Select the backup point
  • Click on Confirm configuration
  • Ensure the copy completes successfully

Existing staging site

  • Search for a site that has been previously configured as a staging site
  • Select the backup point
  • Click on Confirm configuration
  • Ensure the copy completes successfully

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

The progress bar is being updated according the getRestoreProgress() selector, so the idea is to consider the `status` value we get from there to validate if the restore is still in progress or it finished, instead of the `getInProgressRewindStatus` that might have some cache issues.
@Initsogar Initsogar self-assigned this May 25, 2024
@matticbot
Copy link
Contributor

matticbot commented May 25, 2024

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~15 bytes added 📈 [gzipped])

name                    parsed_size           gzip_size
backup                       -133 B  (-0.0%)      +15 B  (+0.0%)
a8c-for-agencies-sites       -133 B  (-0.0%)      +15 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@Initsogar Initsogar changed the title Update backup clone flow to use the getRestoreProgress status Jetpack Backup: Update backup clone flow to use the getRestoreProgress status May 25, 2024
@Initsogar Initsogar changed the title Jetpack Backup: Update backup clone flow to use the getRestoreProgress status Jetpack Backup: Update copy site flow to use the getRestoreProgress selector as restore status source of truth May 28, 2024
@Initsogar Initsogar marked this pull request as ready for review May 28, 2024 04:31
@Initsogar Initsogar requested a review from a team May 28, 2024 04:32
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 28, 2024
@Initsogar Initsogar added the [Feature] Backups The Jetpack Backup product label May 28, 2024
Copy link
Contributor

@jwebbdev jwebbdev left a comment

Choose a reason for hiding this comment

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

Looks good, tests looked good 👍

@Initsogar Initsogar merged commit d994a82 into trunk May 30, 2024
16 of 17 checks passed
@Initsogar Initsogar deleted the fix/backup-copy-site-progress branch May 30, 2024 21:20
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Backups The Jetpack Backup product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants