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

core: gzip before sending the os image to reduce frequency of timeouts #1120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rcooke-warwick
Copy link
Contributor

balena-os/leviathan-worker#101 - corresponding worker PR with context
Change-type: patch

@@ -135,6 +135,10 @@ module.exports = class Worker {
* @category helper
*/
async flash(imagePath) {

this.logger.log(`Gzipping image...`);
await exec(`gzip ${imagePath}`);
Copy link
Member

@vipulgupta2048 vipulgupta2048 Feb 12, 2024

Choose a reason for hiding this comment

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

Instead of adding another OS dependency I was thinking if the entire problem is gzipping in the request causes a timeout then why not use the same logic to gzip out of the request something like

Create a temp file

pipeline(
  fs.createReadStream(imagePath),
  createGzip({ level: 6 }),
  tempFile
)
                         
await move(tempfile, imagePath) // https://stackoverflow.com/a/34499859 

This should also unlink/overrwite the image on imagePath

Change-type: patch
Signed-off-by: Ryan Cooke <[email protected]>
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.

2 participants