-
Notifications
You must be signed in to change notification settings - Fork 74
feat(storage): allow selecting space policy #1791
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
Merged
joseivanlopez
merged 21 commits into
agama-project:storage-config-ui
from
joseivanlopez:storage-set-config-model
Dec 19, 2024
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
56c5960
chore(storage): small improvements in conversion classes
joseivanlopez b9a6ab4
feat(storage): add methods for getting specific configs
joseivanlopez a55a65e
chore(storage): add missing test
joseivanlopez bb85ecc
feat(storage): config from model
joseivanlopez 2dff0f6
feat(storage): add #SetConfigModel to D-Bus API
joseivanlopez 3e4c684
feat(storage): add HTTP API to set the config model
joseivanlopez f402245
feat(web): add hooks for working with storage config model
joseivanlopez 12acc3b
feat(web): allow changing drive and space policy
joseivanlopez 8c075f8
fix(web): storage #setConfig
joseivanlopez 2f6a533
feat(web): allow setCustomSpacePolicy
teclator 42acb78
Small fixes
teclator d3b915a
Some typescript fixes in order to be able to run the tests
teclator b0f61f0
Correct typescript fix
teclator 1309fbb
Fix SpaceActionsTable test
teclator 9920e80
Remove unused vars
teclator 4c0e887
Fix some unit tests
teclator 97dc174
web: small improvements
joseivanlopez e64913e
feat(doc): document process for solving storage config
joseivanlopez ceed757
storage: add links to documentation
joseivanlopez 5d35ded
Improve doc about solving config
joseivanlopez 767cc3f
Add TODO
joseivanlopez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,267 @@ | ||
| # Calculating a proposal from a profile | ||
|
|
||
| The Agama proposal can be calculated either from a very detailed JSON profile or from a "sparse | ||
| profile". The information not provided by the profile is automatically inferred (solved) by Agama. | ||
| Several layers are involved in the process of obtaining the final storage config used by the Agama | ||
| proposal, as shown in the following diagram: | ||
|
|
||
| ``` | ||
| JSON profile ------------> JSON profile (solved) ------------> Storage::Config ------------> Storage::Config (solved) | ||
| | | | | ||
| (JSON solver) (config conversion) (config solver) | ||
| ``` | ||
|
|
||
| ## JSON solver | ||
|
|
||
| The JSON profile provides the *generator* concept. A *generator* allows indicating what volumes to | ||
| create without explicitly defining them. The JSON solver (`Agama::Storage::JSONConfigSolver` class) | ||
| takes care of replacing the volume generator by the corresponding JSON volumes according to the | ||
| product. | ||
|
|
||
| For example, a JSON profile like this: | ||
|
|
||
| ~~~json | ||
| { | ||
| "drives": [ | ||
| { | ||
| "partitions": [ { "generate": "default" } ] | ||
| } | ||
| ] | ||
| } | ||
| ~~~ | ||
|
|
||
| would be solved to something like: | ||
|
|
||
| ~~~json | ||
| { | ||
| "drives": [ | ||
| { | ||
| "partitions": [ | ||
| { "filesystem": { "path": "/" } }, | ||
| { "filesystem": { "path": "swap" } } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ~~~ | ||
|
|
||
| The volumes are solved with their very minimum information (i.e., a mount path). The resulting | ||
| solved JSON is used for getting the storage config object. | ||
|
|
||
| ## Config conversion | ||
|
|
||
| The class `Agama::Storage::ConfigConversions::FromJSON` takes a solved JSON profile and generates a | ||
| `Agama::Storage::Config` object. The resulting config only contains the information provided by the | ||
| profile. For example, if the profile does not specify a file system type for a partition, then the | ||
| config would not have any information about the file system to use for such a partition. | ||
|
|
||
| If something is not provided by the profile (e.g., "boot", "size", "filesystem"), then the config | ||
| marks that values as default ones. For example: | ||
|
|
||
| ```json | ||
| { | ||
| "drives": [ | ||
| { | ||
| "partitions": [ | ||
| { "filesystem": { "path": "/" } } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| generates a config with these default values: | ||
|
|
||
| ```ruby | ||
| config.boot.device.default? #=> true | ||
|
|
||
| partition = config.drives.first.partitions.first | ||
| partition.size.default? #=> true | ||
| partition.filesystem.type.default? #=> true | ||
| ``` | ||
|
|
||
| The configs set as default and any other missing value have to be solved to a value provided by the | ||
| product definition. | ||
|
|
||
| ## Config solver | ||
|
|
||
| The config solver (`Agama::Storage::ConfigSolver` class) assigns a value to all the unknown | ||
| properties of a config object. As result, the config object is totally complete and ready to be used | ||
| by the agama proposal. | ||
|
|
||
| ### How sizes are solved | ||
|
|
||
| A volume size in the profile: | ||
|
|
||
| * Can be totally omitted. | ||
| * Can omit the max size. | ||
| * Can use "current" as value for min and/or max. | ||
|
|
||
| Let's see each case. | ||
|
|
||
| #### Omitting size completely | ||
|
|
||
| ```json | ||
| "partitions": [ | ||
| { "filesystem": { "path": "/" } } | ||
| ] | ||
| ``` | ||
|
|
||
| In this case, the config conversion would generate something like: | ||
|
|
||
| ```ruby | ||
| partition.size.default? #=> true | ||
| partition.size.min #=> nil | ||
| partition.size.max #=> nil | ||
| ``` | ||
|
|
||
| If the size is default, then the config solver always assigns a value for `#min` and `#max` | ||
| according to the product definition and ignoring the current values assigned to `#min` and `#max`. | ||
| The solver takes into account the mount path, the fallback devices and swap config in order to set | ||
| the proper sizes. | ||
|
|
||
| If the size is default and the volume already exists, then the solver sets the current size of the | ||
| volume to both `#min` and `#max` sizes. | ||
|
|
||
| #### Omitting the max size | ||
|
|
||
| ```json | ||
| "partitions": [ | ||
| { | ||
| "size": { "min": "10 GiB" }, | ||
| "filesystem": { "path": "/" } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| The config conversion generates: | ||
|
|
||
| ```ruby | ||
| partition.size.default? #=> false | ||
| partition.size.min #=> Y2Storage::DiskSize.GiB(10) | ||
| partition.size.max #=> Y2Storage::DiskSize.Unlimited | ||
| ``` | ||
|
|
||
| Note that `#max` is set to unlimited when it does not appear in the profile. In this case, nothing | ||
| has to be solved because both `#min` and `#max` have a value. | ||
|
|
||
| #### Using "current" | ||
|
|
||
| Both *min* and *max* sizes admit "current" as a valid size value in the JSON profile. The "current" | ||
| value stands for the current size of the volume. Using "current" is useful for growing or shrinking | ||
| a device. | ||
|
|
||
| The config conversion knows nothing about the current size of a volume, so it simply replaces | ||
| "current" values by `nil`. | ||
|
|
||
| For example, in this case: | ||
|
|
||
| ```json | ||
| "partitions": [ | ||
| { | ||
| "search": "/dev/vda1", | ||
| "size": { "min": "current" }, | ||
| "filesystem": { "path": "/" } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| the config conversion generates a size with `nil` for `#min`: | ||
|
|
||
| ```ruby | ||
| partition.size.default? #=> false | ||
| partition.size.min #=> nil | ||
| partition.size.max #=> Y2Storage::DiskSize.Unlimited | ||
| ``` | ||
|
|
||
| The config solver replaces the `nil` sizes by the device size. In the example before, let's say that | ||
| /dev/vda1 has 10 GiB, so the resulting config would be: | ||
|
|
||
| ```ruby | ||
| partition.size.default? #=> false | ||
| partition.size.min #=> Y2Storage::DiskSize.GiB(10) | ||
| partition.size.max #=> Y2Storage::DiskSize.Unlimited | ||
| ``` | ||
|
|
||
| ##### Use case: growing a device | ||
|
|
||
| ```json | ||
| "partitions": [ | ||
| { | ||
| "search": "/dev/vda1", | ||
| "size": { "min": "current" }, | ||
| "filesystem": { "path": "/" } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| ```ruby | ||
| partition.size.default? #=> false | ||
| partition.size.min #=> Y2Storage::DiskSize.GiB(10) | ||
| partition.size.max #=> Y2Storage::DiskSize.Unlimited | ||
| ``` | ||
|
|
||
| ##### Use case: shrinking a device | ||
|
|
||
| ```json | ||
| "partitions": [ | ||
| { | ||
| "search": "/dev/vda1", | ||
| "size": { "min": 0, "max": "current" }, | ||
| "filesystem": { "path": "/" } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| ```ruby | ||
| partition.size.default? #=> false | ||
| partition.size.min #=> 0 | ||
| partition.size.max #=> Y2Storage::DiskSize.GiB(10) | ||
| ``` | ||
|
|
||
| ##### Use case: keeping a device size | ||
|
|
||
| Note that this is equivalent to omitting the size. | ||
|
|
||
| ```json | ||
| "partitions": [ | ||
| { | ||
| "search": "/dev/vda1", | ||
| "size": { "min": "current", "max": "current" }, | ||
| "filesystem": { "path": "/" } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| ```ruby | ||
| partition.size.default? #=> false | ||
| partition.size.min #=> Y2Storage::DiskSize.GiB(10) | ||
| partition.size.max #=> Y2Storage::DiskSize.GiB(10) | ||
| ``` | ||
|
|
||
| ##### Use case: fallback for not found devices | ||
|
|
||
| A profile can specify an "advanced search" to indicate that a volume has to be created if it is not | ||
| found in the system. | ||
|
|
||
| ```json | ||
| "partitions": [ | ||
| { | ||
| "search": { | ||
| "condition": { "name": "/dev/vda1" }, | ||
| "ifNotFound": "create" | ||
| }, | ||
| "size": { "min": "current" }, | ||
| "filesystem": { "path": "/" } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| If the device does not exist, then "current" cannot be replaced by any device size. In this case, | ||
| the config solver uses the default size defined by the product as fallback for "current". | ||
|
|
||
| ```ruby | ||
| partition.size.default? #=> false | ||
| partition.size.min #=> Y2Storage::DiskSize.GiB(15) | ||
| partition.size.max #=> Y2Storage::DiskSize.Unlimited | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.