Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Refactor elemental #404

Merged
merged 4 commits into from
Jan 17, 2023
Merged

Conversation

davidcassany
Copy link
Contributor

@davidcassany davidcassany commented Jan 11, 2023

This commit refactors elemental image deploy procedure to always create and prepare the root tree in a temporary folder before synching it to a filesystem image most likely as a mounted loop device.

This change has a couple of immediate benefits:

  1. We can pre-compute the root tree size before creating the filesystem image. Hence image sizes can be adjusted to root-tree size. Currently in this PR the default size of the images is set to 0 which means it will use as much as the image requires plus and arbitrary overhead of 256MB (we could consider making it configurable if needed). The use of an static size is still possible by setting the partition size to any value greater than 0.

  2. There is no path differentiation between filesystems. The root tree is prepared following the same logic independently of the target filesystem. Squashfs is no longer an exception, building the image follows the same logic as it was any other writable filesystem.

We also can argue this is a simple, robust and flexible logic compared with the previous code.

The counter part is having to prepare the root-tree to later on copy it to the final image, this causes the root-tree to be written twice, one to prepare it and another one to sync it to the target location.

Fixes #172

davidcassany added a commit to davidcassany/elemental-toolkit that referenced this pull request Jan 11, 2023
The elemental-cli used within this commit is an experimental
one including the image deployment refactor from:

rancher/elemental-cli#404

Signed-off-by: David Cassany <dcassany@suse.com>
davidcassany added a commit to davidcassany/elemental-toolkit that referenced this pull request Jan 11, 2023
The elemental-cli used within this commit is an experimental
one including the image deployment refactor from:

rancher/elemental-cli#404

Signed-off-by: David Cassany <dcassany@suse.com>
@davidcassany davidcassany requested a review from a team January 11, 2023 17:39
Copy link
Contributor

@kkaempf kkaempf left a comment

Choose a reason for hiding this comment

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

I'd recommend to put the copyright year changes in a separate PR

Signed-off-by: David Cassany <dcassany@suse.com>
This commit refactors elemental image deploy procedure to always create
and prepare the root tree in a temporary folder before synching it to
a filesystem image most likely as a mounted loop device.

This change has a couple of immediate benefits:

1. We can precompute the root tree size before creating the filesystem
   image. Hence image sizes can be adjusted to root-tree size.

2. There is no path differentiation between filesystems. The root tree
   is prepared following the same logic independently of the target
   filesystem. Squashfs is no longer an exception, building the image
   follows the same logic as it was any other writable filesystem.

We also can argue this is a simple, robust and flexible logic compared
with the previous code.

The counter part is having to prepare the root-tree to later on copy it
to the final image, this causes the root-tree to be written twice, one
to prepare it and another one to sync it to the target location.

Signed-off-by: David Cassany <dcassany@suse.com>
Signed-off-by: David Cassany <dcassany@suse.com>
@codecov
Copy link

codecov bot commented Jan 12, 2023

Codecov Report

Base: 75.94% // Head: 75.76% // Decreases project coverage by -0.17% ⚠️

Coverage data is based on head (142932c) compared to base (be54c07).
Patch coverage: 82.71% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #404      +/-   ##
==========================================
- Coverage   75.94%   75.76%   -0.18%     
==========================================
  Files          61       61              
  Lines        6189     6284      +95     
==========================================
+ Hits         4700     4761      +61     
- Misses       1160     1187      +27     
- Partials      329      336       +7     
Impacted Files Coverage Δ
pkg/constants/constants.go 95.31% <ø> (ø)
pkg/config/config.go 89.70% <33.33%> (-0.72%) ⬇️
pkg/utils/fs.go 59.62% <63.63%> (-1.71%) ⬇️
pkg/action/upgrade.go 61.80% <69.23%> (+0.33%) ⬆️
pkg/utils/common.go 80.34% <77.77%> (-0.16%) ⬇️
pkg/action/reset.go 68.02% <84.00%> (+1.74%) ⬆️
pkg/elemental/elemental.go 85.97% <84.15%> (-2.24%) ⬇️
pkg/action/install.go 80.64% <91.17%> (-0.95%) ⬇️
pkg/http/client.go 85.29% <0.00%> (-14.71%) ⬇️
... and 7 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

davidcassany added a commit to davidcassany/elemental-toolkit that referenced this pull request Jan 12, 2023
The elemental-cli used within this commit is an experimental
one including the image deployment refactor from:

rancher/elemental-cli#404

Signed-off-by: David Cassany <dcassany@suse.com>
Signed-off-by: David Cassany <dcassany@suse.com>
Copy link
Contributor

@kkaempf kkaempf left a comment

Choose a reason for hiding this comment

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

lgtm 🤞🏻

Copy link
Contributor

@frelon frelon left a comment

Choose a reason for hiding this comment

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

Works like a charm!

@davidcassany davidcassany merged commit 7b348b5 into rancher:main Jan 17, 2023
ldevulder added a commit to rancher/elemental that referenced this pull request Jan 17, 2023
The checked text has been slightly modified due to refactoring in
elemental-cli. See rancher/elemental-cli#404.

Signed-off-by: Loic Devulder <ldevulder@suse.com>
ldevulder added a commit to rancher/elemental that referenced this pull request Jan 17, 2023
The checked text has been slightly modified due to refactoring in
elemental-cli. See rancher/elemental-cli#404.

Signed-off-by: Loic Devulder <ldevulder@suse.com>
ldevulder added a commit to rancher/elemental that referenced this pull request Jan 17, 2023
The checked text has been slightly modified due to refactoring in
elemental-cli. See rancher/elemental-cli#404.

Signed-off-by: Loic Devulder <ldevulder@suse.com>
davidcassany added a commit to davidcassany/elemental-toolkit that referenced this pull request Jan 17, 2023
The elemental-cli used within this commit is an experimental
one including the image deployment refactor from:

rancher/elemental-cli#404

Signed-off-by: David Cassany <dcassany@suse.com>
davidcassany added a commit to rancher/elemental-toolkit that referenced this pull request Jan 23, 2023
The elemental-cli used within this commit is an experimental
one including the image deployment refactor from:

rancher/elemental-cli#404

Signed-off-by: David Cassany <dcassany@suse.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Guess image size from source
4 participants