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(GUI): remove the intermediate child writer proxy process #1910

Merged
merged 1 commit into from Jan 4, 2018

Conversation

jviotti
Copy link
Contributor

@jviotti jviotti commented Dec 7, 2017

Etcher currently elevates a child writer proxy that itself spawns the
Etcher CLI in robot mode, parses the output, and proxies those messages
to the GUI application over IPC.

After these set of changes, Etcher elevates a single child writer
process that directly communicates back with the GUI using IPC. The main
purpose behind these changes is to simplify the overall architecture and
fix various issues caused by the current complex child process tree.

Here's a summary of the changes:

  • Stop wrapping the Etcher CLI to perform writing
  • Remove the robot option from the Etcher CLI (along with related
    documentation)
  • Elevate a new child-write.js standalone executable
  • Move the relevant bits of lib/child-writer to the image-writer GUI
    module
  • Remove the lib/child-writer directory
  • Add a new "Child died unexpectedly" Mixpanel event
  • Floor state percentage in the flash state model

The above changes made is possible to tackle all the remaining issues
where the writer process would remain alive even if the parent died.

Change-Type: patch
Changelog-Entry: Ensure the writer process dies when the GUI application is killed.
See: #1873
See: #1843
Signed-off-by: Juan Cruz Viotti jv@jviotti.com

@jviotti
Copy link
Contributor Author

jviotti commented Dec 7, 2017

I tested this on macOS and GNU/Linux, both locally and packaged, and I went through all the flashing/elevation related items in the manual testing document on macOS.

@@ -222,8 +222,7 @@ rules:
- error
- max: 1
multiline-ternary:
- error
- never
- off
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you agree, of course :) Ternary operations are very handy, but the lines can get long very quickly,

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, does this enable the use of multiline ternaries? Hell yes! 👍

@@ -27,7 +27,7 @@
// an older equivalent of `ELECTRON_RUN_AS_NODE` that still gets set when
// using `child_process.fork()`.
if (process.env.ELECTRON_RUN_AS_NODE || process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE) {
require('./cli/etcher')
require('./gui/modules/child-writer')
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we access the CLI now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You call its entry point directly (ie node lib/cli/etcher.js)

log(`Umount on success: ${unmountOnSuccess}`)
log(`Validate on success: ${validateWriteOnSuccess}`)

writer.writeImage(process.env.OPTION_IMAGE, process.env.OPTION_DEVICE, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we pass this over IPC instead of through env vars? If we want to add persistence and stopping it might make more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's next step (otherwise this PR will keep growing). I want to get most of this merged, and will send and follow up PR that elevates on long-living process at startup that does scanning and flashing using IPC commands.

@jviotti
Copy link
Contributor Author

jviotti commented Jan 2, 2018

Ping @jhermsmeier @Shou @lurch

Copy link
Contributor

@jhermsmeier jhermsmeier left a comment

Choose a reason for hiding this comment

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

@jviotti, this is not sadly working for me on Windows. Looks like a combination of an issue with the elevation & the child exiting unexpectedly (prob. due to lack of permissions)

@jviotti
Copy link
Contributor Author

jviotti commented Jan 4, 2018 via email

Etcher currently elevates a child writer proxy that itself spawns the
Etcher CLI in robot mode, parses the output, and proxies those messages
to the GUI application over IPC.

After these set of changes, Etcher elevates a single child writer
process that directly communicates back with the GUI using IPC. The main
purpose behind these changes is to simplify the overall architecture and
fix various issues caused by the current complex child process tree.

Here's a summary of the changes:

- Stop wrapping the Etcher CLI to perform writing
- Remove the robot option from the Etcher CLI (along with related
  documentation)
- Elevate a new `child-write.js` standalone executable
- Move the relevant bits of `lib/child-writer` to the `image-writer` GUI
  module
- Remove the `lib/child-writer` directory
- Add a new "Child died unexpectedly" Mixpanel event
- Floor state percentage in the flash state model

The above changes made is possible to tackle all the remaining issues
where the writer process would remain alive even if the parent died.

Change-Type: patch
Changelog-Entry: Ensure the writer process dies when the GUI application is killed.
See: #1873
See: #1843
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti
Copy link
Contributor Author

jviotti commented Jan 4, 2018

Rebased! It should work fine now.

@jhermsmeier jhermsmeier merged commit 2291321 into master Jan 4, 2018
@jhermsmeier jhermsmeier deleted the remove-child-writer branch January 4, 2018 19:46
This was referenced Jan 4, 2018
if (!flashResults.cancelled && !flashResults.bytesWritten) {
throw errors.createUserError({
title: 'The writer process ended unexpectedly',
description: 'Please try again, and contact the Etcher team if the problem persists',
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry if this is a stupid question, but why does the identical string appear both here and in lib/shared/messages.js ?

@lurch
Copy link
Contributor

lurch commented Jan 8, 2018

I guess docs/ARCHITECTURE.md now needs a small tweak? @jviotti

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.

None yet

4 participants