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

feat(storage): initial version of config search #1560

Merged
merged 5 commits into from
Sep 4, 2024

Conversation

joseivanlopez
Copy link
Contributor

@joseivanlopez joseivanlopez commented Aug 28, 2024

Allow using a search section in the storage JSON config for drives and partitions, according to the auto_storage document. For now, the search only supports:

  • To search by device name (linux name or udev name).
  • To fail or to skip the section if the device is not found.

Examples:

{
  "search": "/dev/disk/by-id/ata-Micron_1100_SATA_512GB_1652155452D8"
}
{
  "search": {
    "condition": { "name": "/dev/vdc1" },
    "ifNotFound": "skip"
  }
}

@coveralls
Copy link

Coverage Status

coverage: 71.68%. remained the same
when pulling d957ad4 on joseivanlopez:storage-search
into 4cabf6c on openSUSE:master.

@joseivanlopez joseivanlopez force-pushed the storage-search branch 3 times, most recently from be32830 to c320ee7 Compare September 2, 2024 15:15
@joseivanlopez joseivanlopez marked this pull request as ready for review September 3, 2024 08:54
}
}
},
"search": {
Copy link
Contributor Author

@joseivanlopez joseivanlopez Sep 3, 2024

Choose a reason for hiding this comment

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

The document auto_storage suggests two possible syntaxes for the search condition:

Option A:

{
  "search": {
    "condition": { "property": "name", "value": "/dev/sda2" }
  }
}

Option B:

{
  "search": {
    "condition": { "name": "/dev/sda2" }
  }
}

The option B was chosen in this PR because the following reasons:

  • It is shorter and more expressive.

{"size": { "greater": "1 GiB" } } vs
{ "property": "size", "value": "1 GiB", "operator": "greater" }

  • It is easier to validate the possible properties and their values in the schema.

  • It is easier to define different sets of searches in the schema. For example, a drive could be searched by name, size and model, but a partition only by name and size.

Copy link
Contributor Author

@joseivanlopez joseivanlopez Sep 3, 2024

Choose a reason for hiding this comment

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

There is a third option to be discussed. It consists on directly use the condition without wrapping with a condition property:

{
  "search": {
    "name": "/dev/vda1",
    "ifNotFound": "skip"
  }
}

{
  "search": {
    "and": [
      { "size": { "greater": "10 GiB"} },
      { "size": { "less": "50 GiB"} }
    ]
  }
}

@joseivanlopez joseivanlopez changed the title feat(storage): initial version of search feat(storage): initial version of config search Sep 3, 2024
Copy link
Contributor

@imobachgs imobachgs left a comment

Choose a reason for hiding this comment

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

LGTM

service/lib/y2storage/proposal/agama_searcher.rb Outdated Show resolved Hide resolved
Co-authored-by: Imobach González Sosa <igonzalezsosa@suse.com>
@joseivanlopez joseivanlopez merged commit 615f22e into agama-project:master Sep 4, 2024
4 checks passed
@imobachgs imobachgs mentioned this pull request Sep 20, 2024
imobachgs added a commit that referenced this pull request Sep 20, 2024
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.

3 participants