Commit Graph

2987 Commits

Author SHA1 Message Date
Takashi Kajinami 835e7f36a5 Remove unused run_sql_cmd
The run_sql_cmd method in functional tests is not used. The method uses
Engine.execute() method which was removed in 2.0.

Change-Id: I6f9ea1dfd852a2d311e17964da0ea56c052b3fda
2024-04-15 11:54:16 +09:00
Michal Arbet 309ca3aec2 Fix glance-api if cache is disabled
This patch fixes glance when cache is disabled.

Change-Id: I3c3560ba9c87c7098d75173a095642bdd1d7c687
2024-03-08 10:36:11 +01:00
Zuul bc2b5326fa Merge "Require more specific exception" 2024-03-07 09:36:31 +00:00
Takashi Kajinami 211fdbab28 Require more specific exception
This is follow-up of 1e683483e7 and
replaces the generic Exception asserted in a unit tests by the specific
castellan exception, according to the 4.4.0 release.

This change does not bump minimum required version of castellan because
the version requirement only affects unit tests.

Depends-on: https://review.opendev.org/c/openstack/requirements/+/911059
Change-Id: Id1ed909f179038713d9da2fd72cf39e7fb7c8dfe
2024-03-06 03:20:39 +00:00
Abhishek Kekane 9b9111f819 Make `centralized_db` cache driver default
Made `centralized_db` cache driver as default driver so that we
can test it using tempest jobs in gate.

Implements blueprint centralized-cache-db
Depends-On: https://review.opendev.org/c/openstack/devstack/+/907110

Change-Id: Id94e93e3ba3fc207b39c7dbff92495805aa0f6f9
2024-03-05 19:35:20 +00:00
Zuul cd881124ca Merge "Prepare for castellan 4.4.0" 2024-03-04 14:23:16 +00:00
Brian Rosmaita 9df586a5fe Set a lock_path for tests
oslo.concurrency 6.0.0 has relocated the lock_path that is required
for external locks from [DEFAULT] to the [oslo_concurrency] config
section.  Instead of messing with configuration, we can use the
lockutils.set_defaults() method to set this for tests.  So add this
to the BaseTestCase so that it's available for all tests.

Change-Id: I2878b4162dddaf935002c168bc544eb1eff71efd
2024-02-29 16:44:40 -05:00
Abhishek Kekane 5bf2f4e7a0 Fix flaky test related to cache migration
In cache migration unit tests, I was using same cache.db file name
in the setup method which was used by all the tests, which was
causing a issue of deleting a file by other test and resulted
in random failure.

Using random filename to fix this issue permenantly.

Related blueprint centralized-cache-db

Change-Id: I321982013bdf571741a8ef2d0575f65288fff53f
2024-02-29 12:35:00 -08:00
Zuul 2190d648e7 Merge "Migrate from SQLite to Centralized db" 2024-02-28 16:33:32 +00:00
Takashi Kajinami 1e683483e7 Prepare for castellan 4.4.0
In castellan 4.4.0, we fixed the wrong exception MockKeyManager.get
raised in case the requested key does not exist. This change interferes
with the way one unit test case ensure a key is gone.

This replaces the asserted exception by generic Exception so that we
can unblock u-c bump now. We can later replace it by the specific and
correct exception (ManagedObjectNotFoundError) once castellan 4.4.0 is
pulled to u-c.

[1] 2cc410f56e7275d982bca95aa65cd11e22fc7c3c

Change-Id: I8cc1420e8b16ce0bc74314fd7b8aabf6e133abd8
2024-02-28 11:28:48 +09:00
Zuul 8651aefa23 Merge "Introduce centralized database driver for image cache" 2024-02-27 21:57:34 +00:00
Abhishek Kekane 781ce28560 Migrate from SQLite to Centralized db
Made provision to migrate existing cache records from
sqlite to centralized db and delete those from sqlite
after successful migration.

Implements blueprint centralized-cache-db

Change-Id: I2a840915bb6d9d72d6379cae09ebec0e51a4a6dd
2024-02-27 18:16:04 +00:00
Zuul 7b40c33cb6 Merge "Add required database API(s) for cache" 2024-02-27 14:59:26 +00:00
Zuul 02be49c998 Merge "Add new tables for cache operations" 2024-02-19 20:35:01 +00:00
Zuul 2fa64aea03 Merge "Support Stream Optimized VMDKs" 2024-02-16 21:47:31 +00:00
Abhishek Kekane 0bbaec2eeb Introduce centralized database driver for image cache
Added centralized_db driver for image cache which will use
centralized database for storing cache related information.

Related blueprint centralized-cache-db

Change-Id: Iafaaa86666176cc95f77d85a4ab77286f0042bdd
2024-02-16 16:38:06 +00:00
Zuul e31022bf9d Merge "Drop ineffective options from config file" 2024-02-15 15:17:20 +00:00
Abhishek Kekane 10d663d04d Add required database API(s) for cache
Added required database API methods for cache related
operations.

Related blueprint centralized-cache-db

Change-Id: Iae1f1927566f4bda74c5aeccf464df820cfae9d4
2024-02-15 14:35:05 +00:00
Abhishek Kekane b6bd03d4bc Add new tables for cache operations
Added expand script and model to define `cached_images` and
`node_reference` database tables.

Related blueprint centralized-cache-db

Change-Id: I9991a4e945bd4d231e942096445fd5374ff7ff2a
2024-02-09 08:40:46 +00:00
Fabian Wiesel 5e7e6bfb80 Support Stream Optimized VMDKs
Stream optimized VMDKs are also monolithic disks images, and start
with the same sparse extend header as normal monolithic sparse files,
so we can parse the virtual disk size in the same manner.

See "VMware Virtual Disks Virtual Disk Format 1.1" p. 17.
> Header and Footer
> The header and the footer are both described by the same SparseExtentHeader
> structure shown in Hosted Sparse Extent Header on page 8.

Closes-Bug: #2052291
Change-Id: I7d63951ff080dc699b8d11babc0a5998d90621e4
Co-Authored-By: Rajiv Mucheli <rajiv.mucheli@gmail.com>
2024-02-05 12:06:30 +01:00
Takashi Kajinami 1e99767d0e Drop ineffective options from config file
The following options set in functional tests do not exist.
 [DEFAULT] send_identity_credentials
 [DEFAULT] send_identity_headers

Change-Id: Ia739af13e0f88d0861e453a4d54ecc626e32b34b
2024-01-31 01:16:12 +00:00
Takashi Kajinami 9f896ab03d Bump hacking
hacking 3.0.x is too old.

Change-Id: I33875c36dbbdb946841f8c583636ccdf88d3331f
2024-01-27 16:55:11 +00:00
Takashi Kajinami b6b9f043ff Replace usage of deprecated [DATABASE] sql_connection
This option was deprecated in oslo.db a long ago and was removed in
master.

Change-Id: Iba6aa00e4f86fc4b82fa354fddf2fc7d6b47c52f
2024-01-28 01:06:30 +09:00
Takashi Kajinami 5378396b84 Fix test failures with oslo.limit 2.3.0
The oslo.limit 2.3.0 release contains the validation to ensure
the [oslo_limit] endpoint_id option is set[1]. This fixes the test
failures caused by that validation by overriding the option in all
test cases where unified quota implementation is used.

[1] https://review.opendev.org/c/openstack/oslo.limit/+/897509

Closes-Bug: #2049064
Change-Id: I704393892799ee0d5edf45fabe07afe01473e38d
2024-01-12 00:20:42 +09:00
Danylo Vodopianov 66566c3286 Add Packed Virtqueue extra spec and image properties
Virtqueue feature was added to the metadata properties for flavor and
images

- Add the hw:virtio_packed_ring flavor extra spec and corresponding
  hw_virtio_packed_ring image property.

Nova spec: https://review.opendev.org/c/openstack/nova-specs/+/868377

Depends-On: https://review.opendev.org/c/openstack/nova/+/876075

Change-Id: Ia8caf39467a91431ca85b2a56ec93a60c41a8e7d
2023-12-05 10:59:18 +02:00
Zuul 88bb1568fc Merge "db: Remove explicit autocommit" 2023-09-21 22:35:10 +00:00
Zuul 2de1932b97 Merge "db: Don't inherit cache for DeleteFromSelect" 2023-09-15 20:40:07 +00:00
Zuul 7cb1d5e0ae Merge "db: Drop use of implicit auto-commit" 2023-09-14 13:31:46 +00:00
Zuul 269cc2f105 Merge "db: Enable foreign keys for SQLite backend" 2023-09-13 14:09:48 +00:00
Zuul 990621c4f5 Merge "db: Replace dict-style access of Row attributes" 2023-09-13 10:44:06 +00:00
Zuul fc3e21d01b Merge "db: Don't pass strings to Connection.execute()" 2023-09-13 09:34:00 +00:00
Zuul 5a8afa825b Merge "db: Replace use of aliased keyword arguments" 2023-09-12 14:52:51 +00:00
Zuul 4a6bf9ae12 Merge "db: Pass case.whens as positionals, not a list" 2023-09-12 09:38:31 +00:00
Zuul f6cb466793 Merge "db: Replace use of 'Query.values()'" 2023-09-11 08:21:00 +00:00
Zuul d001291007 Merge "db: Don't invoke and_() without arguments" 2023-09-08 13:52:15 +00:00
Zuul 035fbe9fea Merge "db: Remove use of 'bind' arguments" 2023-09-04 08:28:14 +00:00
Zuul 6d62668c32 Merge "db: Replace use of legacy select() calling style" 2023-09-04 08:28:12 +00:00
Zuul 6f5f24623c Merge "tests: Add tests for loading, unloading metadefs" 2023-08-29 15:20:18 +00:00
Zuul b6223f3210 Merge "tests: Enable SQLAlchemy 2.0 deprecation warnings" 2023-08-28 18:12:50 +00:00
Zuul d4dffa1714 Merge "tests: Use WarningsFixture in all tests" 2023-08-09 07:55:57 +00:00
Zuul 2c7f735551 Merge "tests: Restore - don't reset - warning filters" 2023-08-08 10:41:18 +00:00
Abhishek Kekane fd222f3128 Sort locations based on store weight
Related to blueprint store-weight

Change-Id: I2383a476cb7e79c7efecdf33203cff0b50ef3bbb
2023-08-01 14:16:08 +00:00
Stephen Finucane d1368745c5 db: Remove explicit autocommit
We already got rid of implicit autocommit. Now get rid of explicit
autocommit. This is far more involved than the prior patch but the basic
strategy here is that no public method should take a 'session' argument
and instead should call 'get_session'. In addition, all private methods
should take both a 'context' and 'session' argument and they should be
the first and second arguments, respectively. Finally, public methods
should only call private methods. Combined, this ensures we only ever
have one session in play and the transactions are correctly started and
ended as expected.

Change-Id: I5245c402699e179c219039514b626a52fa0028d8
2023-07-25 10:08:52 +01:00
Stephen Finucane ede0f9c1b4 db: Don't inherit cache for DeleteFromSelect
Resolve the following SAWarning warning:

  Class DeleteFromSelect will not make use of SQL compilation caching as
  it does not set the 'inherit_cache' attribute to ``True``.  This can
  have significant performance implications including some performance
  degradations in comparison to prior SQLAlchemy versions.  Set this
  attribute to True if this object can make use of the cache key
  generated by the superclass.  Alternatively, this attribute may be set
  to False which will disable this warning.

This uses different arguments so the cache presumably does not make
sense.

Change-Id: I958ba79ca7ac6709e8c16eceb212f329c807aea8
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-07-25 09:05:44 +00:00
Stephen Finucane 8c5091cd48 db: Drop use of implicit auto-commit
Resolve the following RemovedIn20Warning warning:

  The current statement is being autocommitted using implicit
  autocommit, which will be removed in SQLAlchemy 2.0. Use the .begin()
  method of Engine or Connection in order to use an explicit transaction
  for DML and DDL statements.

This is the trickiest one hence it's left to last. We really need to get
off of the legacy EngineFacade pattern since it's harder to track
transactions when they're not local (the request context-based binding
of sessions allows us to decorate individual methods) but that's a
larger work item that we're not going to tackle here.

Change-Id: Ie16965a8e3e2f316b807068a868cee6fbb2f33ba
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-07-25 10:03:11 +01:00
Stephen Finucane 2e716b53f3 db: Enable foreign keys for SQLite backend
We were doing this adhoc in tests, which doesn't seem to be possible in
SQLAlchemy 2.0. Do it everywhere instead.

This highlights a small issue that we have to workaround in the tests.

Change-Id: I9dd70c9976f83a00a8cb270422e545ff2c77f12f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-07-25 09:56:29 +01:00
Stephen Finucane ce5056ad3a db: Replace dict-style access of Row attributes
Resolve the following RemovedIn20Warning:

  Using non-integer/slice indices on Row is deprecated and will be
  removed in version 2.0; please use row._mapping[<key>], or the
  mappings() accessor on the Result object.

Change-Id: Ife8bdf766eb6d6fe9748565c9c61aa971d1af6f8
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-07-24 21:34:11 +00:00
Stephen Finucane 25dcacea7c db: Don't pass strings to Connection.execute()
Resolve the following RemovedIn20Warning warning:

  Passing a string to Connection.execute() is deprecated and will be
  removed in version 2.0.  Use the text() construct, or the
  Connection.exec_driver_sql() method to invoke a driver-level SQL
  string.

We also resolve two additional RemovedIn20Warning warnings along the
way, since we're already touching this code:

  The Engine.execute() method is considered legacy as of the 1.x series
  of SQLAlchemy and will be removed in 2.0. All statement execution in
  SQLAlchemy 2.0 is performed by the Connection.execute() method of
  Connection, or in the ORM by the Session.execute() method of Session.

  The Executable.execute() method is considered legacy as of the 1.x
  series of SQLAlchemy and will be removed in 2.0. All statement
  execution in SQLAlchemy 2.0 is performed by the Connection.execute()
  method of Connection, or in the ORM by the Session.execute() method of
  Session.

Change-Id: I547bd2f441085fcdc5dc4a0e58d27d11e8a8b223
2023-07-24 21:34:03 +00:00
Stephen Finucane 44050a2f75 db: Replace use of aliased keyword arguments
Resolve the following RemovedIn20Warning warning:

  The ``aliased`` and ``from_joinpoint`` keyword arguments to
  Query.join() are deprecated and will be removed in SQLAlchemy 2.0.

This one is a little trickier to grok, but the SQLAlchemy docs explain
it rather well [1] (Look for "Legacy Features of Query.join()" and
"Joins to a Target with an ON Clause"). Essentially, because we are
joining e.g. the ImageTag table multiple times, we need to create an
alias and use it for both the join and resulting queries.

[1] https://docs.sqlalchemy.org/en/14/orm/query.html#sqlalchemy.orm.Query.join

Change-Id: Ifb818df8ca8500adcf1354eff0671f5762473110
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-07-24 21:33:58 +00:00
Stephen Finucane e5a8918e87 db: Pass case.whens as positionals, not a list
Resolve the following RemovedIn20Warning warnings:

  The "whens" argument to case(), when referring to a sequence of items,
  is now passed as a series of positional elements, rather than as a
  list.

Change-Id: I4df3a52333d71809d6ff305a786ba6ae03a230ca
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-07-24 17:08:56 +00:00