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(app): Allow app to request buildroot update token #3765

Merged
merged 1 commit into from
Jul 23, 2019

Conversation

mcous
Copy link
Contributor

@mcous mcous commented Jul 22, 2019

overview

This PR is a chunk of implementation work for un-sized tickets #3359 and #3361. It implements the following steps in the migration + update process:

br-update-flow

changelog

  • refactor(app): Allow app to request buildroot update token

review requests

The diff is a little inflated because I had to split apart app/src/shell/buildroot.js as it was getting too large. Sorry about that.

A few decisions I made during implementation that will affect future work:

  • App should only support updating one buildroot robot at a time
    • This can be changed in the future, but for MVP reduces scope of work
  • HTTP requests/responses for buildroot update should live with the buildroot source, not the robot API client source
    • If bullet Error in Documentation #1 changes, this would likely change, too
    • For now keeps logic contained to one place
    • The update flow still uses actions from robotApi module, so really I mean the epics and reducer are in app/src/shell/buildroot rather than app/src/robot-api/resources/update-server or something

Things I'd especially like feedback on:

  • Does the flow above actually work?
  • This is my first time writing unit tests for epics, so (especially @b-cooper) if you have any insight here that would be great
  • In the same vein, how do the epics in update-epics.js look?

real-life testing instructions

make -C app dev OT_APP_DEV_INTERNAL__ENABLE_BUILD_ROOT=1

Dispatch a buildroot:START_UPDATE action to a robot name, e.g.:

store.dispatch({type: 'buildroot:START_UPDATE', payload: 'opentrons-OT2P20180418A06'})

Pro-tip: Use the Chrome console rather than the Redux devtools to dispatch the action so you have up-arrow history as you're testing. Copy-paste in the app's devtools is very broken at least on macOS for some reason

Then, keep an eye on the Redux devtools for the following actions depending on which path in the flow you're following:

  • buildroot:START_PREMIGRATION, buildroot:PREMIGRATION_STARTED, buildroot:PREMIGRATION_DONE
    • Robot was not ready for migration, so the update server was bootstrapped
  • robotApi:START_UPDATE
    • Start update request will be re-dispatched after bootstrap is done and robot is migration capable
  • robotApi:[REQUEST|RESPONSE|ERROR]__POST__/session/update[/migration]/begin
    • Token request, response, or error
    • Request path will change based on migration of BR update
  • robotApi:[REQUEST|RESPONSE|ERROR]__POST__/session/update[/migration]/cancel
    • Token cancel request if initial token request came back 409
    • Request path will change based on migration of BR update

@mcous mcous added app Affects the `app` project large labels Jul 22, 2019
@mcous mcous requested review from sfoster1 and a team July 22, 2019 13:23
@mcous mcous added this to the Migrate Off Of Balena milestone Jul 22, 2019
@codecov
Copy link

codecov bot commented Jul 22, 2019

Codecov Report

Merging #3765 into edge will increase coverage by 0.14%.
The diff coverage is 98.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge    #3765      +/-   ##
==========================================
+ Coverage   57.09%   57.24%   +0.14%     
==========================================
  Files         817      820       +3     
  Lines       22545    22599      +54     
==========================================
+ Hits        12873    12936      +63     
+ Misses       9672     9663       -9
Impacted Files Coverage Δ
app/src/pages/Robots/RobotSettings.js 0% <ø> (ø) ⬆️
app/src/discovery/selectors.js 84.9% <ø> (ø) ⬆️
app/src/robot-api/utils.js 62.85% <ø> (ø) ⬆️
app-shell/src/buildroot/index.js 0% <ø> (ø) ⬆️
...pp/src/components/RobotSettings/InformationCard.js 0% <ø> (ø) ⬆️
app/src/shell/buildroot/selectors.js 100% <100%> (ø)
app/src/shell/buildroot/actions.js 100% <100%> (ø)
app/src/shell/buildroot/update-epics.js 100% <100%> (ø)
app/src/shell/buildroot/reducer.js 92.3% <92.3%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update abab1a2...dabdc79. Read the comment docs.

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Tested as in the PR notes, works for me as long as the update server is from 3.7.0 or previous, or 3.10.1 or subsequent (in the middle the shape of the capabilities field in /server/update/health is wrong)

Copy link
Contributor

@b-cooper b-cooper left a comment

Choose a reason for hiding this comment

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

Tests look great! Awesome to have that epic coverage. :octocat:

error?.payload.status === 409
)
}),
switchMap<RobotApiResponseAction, _, mixed>(action => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sometimes I'll name the action parameter after a filter something that describes it's uniqueness if the flow type doesn't narrow it down enough (e.g. errorAction). Just a suggestion, though this is still pretty clear as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do so in #3771

@mcous mcous merged commit 85fb0d5 into edge Jul 23, 2019
@mcous mcous deleted the app_update-buildroot-bot branch August 21, 2019 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Affects the `app` project large
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants