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: add DB initialization module #556

Merged
merged 25 commits into from
Feb 7, 2024
Merged

feat: add DB initialization module #556

merged 25 commits into from
Feb 7, 2024

Commits on Feb 7, 2024

  1. feat(data-formats): move StoredItem from rendezvous

    The `StoredItem` struct is no longer needed just in the rendezvous server, we
    are making it public and moving it to the data-formats lib so that it can be
    easily included in other modules.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    b18f84a View commit details
    Browse the repository at this point in the history
  2. feat: add DB initialization module

    This provides an interface defining the methods
    that we expect to be used for OV handling operations.
    
    Added an implementation for sqlite and postgress.
    
    Added db creation files and tests.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    0bdb995 View commit details
    Browse the repository at this point in the history
  3. ci: update to handle DB tests

    Adds new dependencies and creates a sqlite database to be used in the tests.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    299592f View commit details
    Browse the repository at this point in the history
  4. feat: add the Manufacturer DB store

    This adds the store interface methods for the SqliteManufacturerStore.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    8f37826 View commit details
    Browse the repository at this point in the history
  5. feat: don't allow db settings in per-device config

    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    ed65dfe View commit details
    Browse the repository at this point in the history
  6. feat: add the Owner DB store configuration

    This adds the store trait for the Sqlite Owner DB.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    55189de View commit details
    Browse the repository at this point in the history
  7. feat: add the Rendezvous DB store configuration

    This implements the store trait for the Sqlite Rendezvous DB.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    e4f9de1 View commit details
    Browse the repository at this point in the history
  8. feat(store): change store initializations based on DB type

    When selecting to use the DB as the store type in the configuration files, this
    requires to select the DB type (sqlite or postgres) and the server type.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    202edc0 View commit details
    Browse the repository at this point in the history
  9. fix(data-formats): error when trying to parse an empty slice

    When we are trying to parse raw data to make an ownership voucher
    we did not check whether the slice was empty or not, causing a
    panic in such case.
    This change explicitly checks if the slice is empty or not, and
    in the former case returns an error.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    4982d09 View commit details
    Browse the repository at this point in the history
  10. feat(owner-tool): add an option to export OVs from the Manufacturer DB

    This adds the `export_manufacturer_vouchers` option to the Owner CLI, which
    allows to export OVs from the Manufacturer Server's DB to a directory. The
    options are to export a single OV by GUID or all of them.
    
    Updated the DB trait to add the `select *` query that yields all the OVs in the
    Manufacturer.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    1eeea64 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    4da0a49 View commit details
    Browse the repository at this point in the history
  12. fix(db): do not bail on non-critical errors

    We are going to propagate the errors unless those are related
    to getting a connection to the DB.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    35369a9 View commit details
    Browse the repository at this point in the history
  13. fix(db): remove dotenv handling

    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    1ddbe3a View commit details
    Browse the repository at this point in the history
  14. feat(store): add query_ovs_db method to store trait

    The `query_data` method makes no sense when using databases since it uses
    different types of lists to query the required data, when that's a single query
    in a database; thereby we are adding the `query_ovs_db` method which explicitly
    queries the required data from the database.
    
    We are also adding a new error type `StoreError::MethodNotAvailable` that will
    be yielded when we call `query_data` from a database store implementation, or
    when we call the new `query_ovs_db` method from a directory store
    implementation.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    1e430f5 View commit details
    Browse the repository at this point in the history
  15. feat(owner-server): add DB handling to report_to_rendezvous

    When the Owner server needs to report OVs to the Rendezvous server, check
    whether we have the old `query_data` method available or the new `query_ovs_db`
    method to choose the most effective one.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    6df89ca View commit details
    Browse the repository at this point in the history
  16. feat(store): add Database error type

    Replace all the `StoreError::Unspecified` errors with the new
    `StoreError::Database` when there is an internal database error.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    1a9d368 View commit details
    Browse the repository at this point in the history
  17. fix(db): change select_ov_to2_performed_and_ov_to0_less_than query

    This changes the filters so that they correctly take into account NULL values.
    In order to set a NULL value we need to use None in rust, but for filtering
    instead of using None we need to filter by `is_null()`.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    e219eea View commit details
    Browse the repository at this point in the history
  18. fix(store): expect StoredItem in rendezvous store

    This changes the `store_data` method so that it expects a Value of type
    `StoredItem` for the serialization and deserialization of data.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    4c9598a View commit details
    Browse the repository at this point in the history
  19. chore(containers): update DB dependencies

    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    8af3381 View commit details
    Browse the repository at this point in the history
  20. feat(store): add postgresql store variant

    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    55d85d3 View commit details
    Browse the repository at this point in the history
  21. docs: add database usage and configuration

    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    48d8abd View commit details
    Browse the repository at this point in the history
  22. test: add postgres db test

    henrywang authored and 7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    3fcef6b View commit details
    Browse the repository at this point in the history
  23. chore: update spec to add sql files and unify migrations

    Since the migrations are unified in a single folder the tests have been updated
    accordingly.
    
    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    442ac2c View commit details
    Browse the repository at this point in the history
  24. fix: adds necessary crates and scripts to dev container

    Adds sqlite and libpq crates to devcontainer creation
    for successful building and testing in dev container.
    Also adds diesel scripts to dev container build to
    enable successful dev container integration testing.
    
    Signed-off-by: djach7 <[email protected]>
    djach7 authored and 7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    8b65567 View commit details
    Browse the repository at this point in the history
  25. chore: bump db to 0.4.13

    Signed-off-by: Irene Diez <[email protected]>
    7flying committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    530fef0 View commit details
    Browse the repository at this point in the history