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

New storage proposal settings #656

Merged
merged 92 commits into from
Aug 29, 2023
Merged

New storage proposal settings #656

merged 92 commits into from
Aug 29, 2023

Conversation

ancorgs
Copy link
Contributor

@ancorgs ancorgs commented Jul 10, 2023

Problem

The information about the products offered for installation is provided to Agama by means of a config file (e.g., /etc/agama.yaml). That config file contains an storage section which indicates the volumes (file systems) to create in the target system. Right now, this storage section is basically the same as the section for the YaST config file. But the storage use cases for Agama are only a subset of all the possibities YaST offers. Because of that, some YaST storage options simply do not make sense for Agama, but the config file still has to indicate them in order to make YaST to work properly.

We need an easier way to specify the storage options for the Agama use cases. The very YaST specific options should not be exposed in the Agama config file.

Solution

The storage settings for Agama config are redefined.

See example
  storage:
    lvm: true
    encryption:
      method: luks2
      pbkd_function: pbkdf2
    space_policy: delete
    volumes:
      - "/"
    volume_templates:
      - mount_path: "/"
        mount_options:
          - default
          - data=ordered
        filesystem: btrfs
        btrfs:
          snapshots: true
          read_only: true
          default_subvolume: "@"
          subvolumes:
            - path: root
            - path: home
            - path: opt
            - path: srv
            - path: var
              copy_on_write: false
        size:
          auto: false
          min: 5 GiB
          max: unlimited
        outline:
          required: true
          filesystems:
            - btrfs
            - ext4
            - xfs
          auto_size:
            base_min: 10 GiB
            base_max: 100 GiB
            snapshots_increment: 200%
            adjust_by_ram: false
            min_fallback_for:
              - "/home"
            max_fallback_for:
              - "/home"
          snapshots_configurable: false

The main changes are in the volumes section. Now, volumes only contains the mount points of the volumes to create:

volumes:
  - "/"
  - "swap"

And there is a new volume_templates section. This new section contains a template for each volume. A template consists on a set of default values and a volume outline. The outline represents some specific information about the volume which cannot be changed, for example, the possible file system types for the volume.

    volume_templates:
      - mount_path: "/"
        filesystem: btrfs
        size:
          auto: false
          min: 5 GiB
          max: unlimited
        outline:
          required: true
          filesystems:
            - btrfs
            - ext4
            - xfs

There is also a generic volume template to be used for a new arbitrary volume. The generic volume template does not indicate a mount path.

    volume_templates:
      - filesystem: xfs
        size:
          auto: false
          min: 1 GiB
          max: unlimited
        outline:
          required: false
          filesystems:
            - btrfs
            - ext4
            - xfs

Volumes and storage proposal

Agama initially calculates the storage proposal trying to create all the volumes indicated in the volumes section of the control file. A new proposal can be triggered from D-Bus calling to #Calculate method from org.opensuse.Agama.Storage1.Proposal.Calculator interface. #Calculate receives the settings to use for the new proposal.

Proposal settings conversions

In Agama a proposal is calculated by calling to Agama::Storage::Proposal#calculate, which receives a Agama::Storage::ProposalSettings object. The proposal settings object needs to be generated from two different sources: the agama config file for the initial proposal and from the information provided from D-Bus for calculating a new proposal:

  • The class Agama::Storage::ProposalSettingsReader generates the proposal settings from the config file.
  • There is a conversion class Agama::DBus::Storage::ProposalSettingsConversion::FromDBus to generate the proposal settings from the D-Bus information.

And then, Agama delegates the real computation of the proposal to Y2Storage. For that, the proposal settings are converted to the Y2Storage format thanks to the class Agama::Storage::ProposalSettingsConversion::ToY2Storage.

There are two more conversions for the proposal settings:

  • Agama::DBus::Storage::ProposalSettingsConversion::ToDBus: generates a D-Bus representation of the proposal settings, useful for the D-Bus interfaces providing information about the proposal.
  • Agama::Storage::ProposalSettingsConversion::FromY2Storage: generates proposal settings from the Y2Storage format. This is useful to rebuild the proposal settings once Y2Storage has finished to calculate the proposal.

Testing

  • New unit tests.
  • Tested manually.

Copy link
Contributor

@jreidinger jreidinger left a comment

Choose a reason for hiding this comment

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

nothing critical, just typos and one possible code improvement

@joseivanlopez joseivanlopez merged commit bd46949 into storage-settings Aug 29, 2023
14 checks passed
@joseivanlopez joseivanlopez deleted the plane branch August 29, 2023 10:12
This was referenced Sep 4, 2023
@imobachgs imobachgs mentioned this pull request Sep 26, 2023
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.

9 participants