Add KeyDB and Valkey datastore support
This patch introduces support for KeyDB and Valkey datastores. To achieve this without code duplication, the new Redis common implementation was created from a scratch. KeyDB and Valkey now inherit from this base. Existing legacy experimental Redis is untouched. Depends-On: https://review.opendev.org/c/openstack/trove-tempest-plugin/+/989855 Blueprint: redis-based-valkey-and-keydb-datastores Change-Id: Ia99918ff3df2078fed8636d46a9c4309f402eaba Signed-off-by: Erkin Mussurmankulov <erkin.mussurmankulov@ps.kz>
This commit is contained in:
1 parent
e4be1a947b
commit
217db27fd1
51 files changed
+3165
-43
No files matched your search
@@ -0,0 +1,19 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from backup.drivers.redis_base import RedisBaseBackup
|
||||
|
||||
|
||||
class KeyDBBackup(RedisBaseBackup):
|
||||
DATASTORE_NAME = 'keydb'
|
||||
@@ -0,0 +1,45 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from backup.drivers import base
|
||||
from oslo_log import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RedisBaseBackup(base.BaseRunner):
|
||||
DATASTORE_NAME = 'redis'
|
||||
"""Backup/restore for Redis-based datastores.
|
||||
|
||||
Backuping Redis-based datastores is a very simple process.
|
||||
We need to run SAVE or BGSAVE command and copy dump.rdb and config files.
|
||||
"""
|
||||
|
||||
"""Implementation of Backup and Restore using tar command."""
|
||||
cmd = 'tar -cO %(restore_location)s'
|
||||
restore_cmd = 'tar xf - -C /'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.datadir = kwargs.pop(
|
||||
'db_datadir', f'/var/lib/{self.DATASTORE_NAME}')
|
||||
LOG.info("Datadir: %s", self.datadir)
|
||||
self.backup_log = '%s/backup.log' % (self.datadir)
|
||||
super(RedisBaseBackup, self).__init__(*args, **kwargs)
|
||||
|
||||
def pre_backup(self):
|
||||
self._gzip = True
|
||||
|
||||
def run_restore(self):
|
||||
self._gzip = True
|
||||
return self.unpack(self.location, self.checksum, self.restore_command)
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from backup.drivers.redis_base import RedisBaseBackup
|
||||
|
||||
|
||||
class ValkeyBackup(RedisBaseBackup):
|
||||
DATASTORE_NAME = 'valkey'
|
||||
+1
-1
@@ -13,7 +13,7 @@ usage() {
|
||||
echo "Usage : $(basename $0) [--datastore datastore] [--datastore-version datastore-version]"
|
||||
echo ""
|
||||
echo " Command parameters:"
|
||||
echo " 'datastore' is the datastore. The options are: 'mariadb', 'mysql', 'postgresql'"
|
||||
echo " 'datastore' is the datastore. The options are: 'mariadb', 'mysql', 'postgresql', 'keydb', 'valkey'"
|
||||
echo " 'datastore-version' is the datastore version of the datastore."
|
||||
echo ""
|
||||
exit 1
|
||||
|
||||
+5
-2
@@ -37,7 +37,8 @@ cli_opts = [
|
||||
cfg.StrOpt(
|
||||
'driver',
|
||||
default='innobackupex',
|
||||
choices=['innobackupex', 'mariabackup', 'pg_basebackup', 'xtrabackup']
|
||||
choices=['innobackupex', 'mariabackup', 'pg_basebackup', 'xtrabackup',
|
||||
'keydbbackup', 'valkeybackup']
|
||||
),
|
||||
cfg.BoolOpt('backup'),
|
||||
cfg.StrOpt('swift-url'),
|
||||
@@ -90,7 +91,9 @@ driver_mapping = {
|
||||
'pg_basebackup': 'backup.drivers.postgres.PgBasebackup',
|
||||
'pg_basebackup_inc': 'backup.drivers.postgres.PgBasebackupIncremental',
|
||||
'xtrabackup': 'backup.drivers.xtrabackup.XtraBackup',
|
||||
'xtrabackup_inc': 'backup.drivers.xtrabackup.XtraBackupIncremental'
|
||||
'xtrabackup_inc': 'backup.drivers.xtrabackup.XtraBackupIncremental',
|
||||
'keydbbackup': 'backup.drivers.keydb.KeyDBBackup',
|
||||
'valkeybackup': 'backup.drivers.valkey.ValkeyBackup',
|
||||
}
|
||||
storage_mapping = {
|
||||
'swift': 'backup.storage.swift.SwiftStorage',
|
||||
|
||||
+12
-2
@@ -167,6 +167,10 @@ function configure_docker_images {
|
||||
iniset $TROVE_GUESTAGENT_CONF mariadb backup_docker_image ${TROVE_DATABASE_BACKUP_IMAGE_MARIADB}
|
||||
iniset $TROVE_GUESTAGENT_CONF postgresql docker_image ${TROVE_DATABASE_IMAGE_POSTGRESQL}
|
||||
iniset $TROVE_GUESTAGENT_CONF postgresql backup_docker_image ${TROVE_DATABASE_BACKUP_IMAGE_POSTGRESQL}
|
||||
iniset $TROVE_GUESTAGENT_CONF keydb docker_image ${TROVE_DATABASE_IMAGE_KEYDB}
|
||||
iniset $TROVE_GUESTAGENT_CONF keydb backup_docker_image ${TROVE_DATABASE_BACKUP_IMAGE_KEYDB}
|
||||
iniset $TROVE_GUESTAGENT_CONF valkey docker_image ${TROVE_DATABASE_IMAGE_VALKEY}
|
||||
iniset $TROVE_GUESTAGENT_CONF valkey backup_docker_image ${TROVE_DATABASE_BACKUP_IMAGE_VALKEY}
|
||||
}
|
||||
|
||||
function configure_cloudinit {
|
||||
@@ -209,7 +213,7 @@ ${ETC_HOSTS_APPEND}
|
||||
EOF
|
||||
|
||||
# NOTE(lxkong): Remove this when we support common cloud-init file for all datastores.
|
||||
for datastore in "mysql" "mariadb" "postgresql"
|
||||
for datastore in "mysql" "mariadb" "postgresql" "keydb" "valkey"
|
||||
do
|
||||
sudo cp ${common_cloudinit} /etc/trove/cloudinit/${datastore}.cloudinit
|
||||
done
|
||||
@@ -281,6 +285,8 @@ function configure_trove {
|
||||
iniset $TROVE_CONF postgresql tcp_ports 5432
|
||||
iniset $TROVE_CONF pxc tcp_ports 3306,4444,4567,4568
|
||||
iniset $TROVE_CONF redis tcp_ports 6379,16379
|
||||
iniset $TROVE_CONF keydb tcp_ports 6379,6380
|
||||
iniset $TROVE_CONF valkey tcp_ports 6379,6380
|
||||
iniset $TROVE_CONF vertica tcp_ports 5433,5434,5444,5450,4803
|
||||
|
||||
write_uwsgi_config "$TROVE_UWSGI_CONF" "$TROVE_UWSGI" "/database" "" "trove"
|
||||
@@ -452,7 +458,7 @@ function configure_tempest_for_trove {
|
||||
if [[ -n "$TROVE_DATASTORE_TYPE" ]]; then
|
||||
iniset $TEMPEST_CONFIG database enabled_datastores $TROVE_DATASTORE_TYPE
|
||||
else
|
||||
iniset $TEMPEST_CONFIG database enabled_datastores mysql,mariadb,postgresql
|
||||
iniset $TEMPEST_CONFIG database enabled_datastores mysql,mariadb,postgresql,keydb,valkey
|
||||
fi
|
||||
if [[ -n "$TROVE_DATASTORE_TYPE" && -n "$TROVE_DATASTORE_VERSION" ]]; then
|
||||
iniset $TEMPEST_CONFIG database default_datastore_versions $TROVE_DATASTORE_TYPE:$TROVE_DATASTORE_VERSION
|
||||
@@ -701,9 +707,13 @@ function config_network_isolation {
|
||||
TROVE_DATABASE_IMAGE_MYSQL="$LOCAL_HOSTNAME:$REGISTRY_PORT/trove-datastores/mysql"
|
||||
TROVE_DATABASE_IMAGE_MARIADB="$LOCAL_HOSTNAME:$REGISTRY_PORT/trove-datastores/mariadb"
|
||||
TROVE_DATABASE_IMAGE_POSTGRESQL="$LOCAL_HOSTNAME:$REGISTRY_PORT/trove-datastores/postgresql"
|
||||
TROVE_DATABASE_IMAGE_KEYDB="$LOCAL_HOSTNAME:$REGISTRY_PORT/trove-datastores/keydb"
|
||||
TROVE_DATABASE_IMAGE_VALKEY="$LOCAL_HOSTNAME:$REGISTRY_PORT/trove-datastores/valkey"
|
||||
TROVE_DATABASE_BACKUP_IMAGE_MYSQL="$LOCAL_HOSTNAME:$REGISTRY_PORT/trove-datastores/db-backup-mysql"
|
||||
TROVE_DATABASE_BACKUP_IMAGE_MARIADB="$LOCAL_HOSTNAME:$REGISTRY_PORT/trove-datastores/db-backup-mariadb"
|
||||
TROVE_DATABASE_BACKUP_IMAGE_POSTGRESQL="$LOCAL_HOSTNAME:$REGISTRY_PORT/trove-datastores/db-backup-postgresql"
|
||||
TROVE_DATABASE_BACKUP_IMAGE_KEYDB="$LOCAL_HOSTNAME:$REGISTRY_PORT/trove-datastores/db-backup-keydb"
|
||||
TROVE_DATABASE_BACKUP_IMAGE_VALKEY="$LOCAL_HOSTNAME:$REGISTRY_PORT/trove-datastores/db-backup-valkey"
|
||||
|
||||
configure_docker_images
|
||||
fi
|
||||
|
||||
+9
-1
@@ -31,7 +31,7 @@ TROVE_LOCAL_POLICY_JSON=${TROVE_LOCAL_POLICY_JSON:-${TROVE_LOCAL_CONF_DIR}/polic
|
||||
|
||||
TROVE_IMAGE_OS=${TROVE_IMAGE_OS:-"ubuntu"}
|
||||
TROVE_IMAGE_OS_RELEASE=${TROVE_IMAGE_OS_RELEASE:-"noble"}
|
||||
TROVE_DATASTORES=${TROVE_DATASTORES:-"mysql:8.4 mariadb:11.4 postgresql:18"}
|
||||
TROVE_DATASTORES=${TROVE_DATASTORES:-"mysql:8.4 mariadb:11.4 postgresql:18 keydb:6.3.3 valkey:9"}
|
||||
|
||||
# Configuration values listed here for reference
|
||||
TROVE_MAX_ACCEPTED_VOLUME_SIZE=${TROVE_MAX_ACCEPTED_VOLUME_SIZE}
|
||||
@@ -102,16 +102,24 @@ if [ "$TROVE_ENABLE_LOCAL_REGISTRY" == "True" ] ; then
|
||||
TROVE_DATABASE_IMAGE_MYSQL=${TROVE_DATABASE_IMAGE_MYSQL:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/mysql"}
|
||||
TROVE_DATABASE_IMAGE_MARIADB=${TROVE_DATABASE_IMAGE_MARIAD:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/mariadb"}
|
||||
TROVE_DATABASE_IMAGE_POSTGRESQL=${TROVE_DATABASE_IMAGE_POSTGRESQL:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/postgres"}
|
||||
TROVE_DATABASE_IMAGE_KEYDB=${TROVE_DATABASE_IMAGE_KEYDB:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/keydb"}
|
||||
TROVE_DATABASE_IMAGE_VALKEY=${TROVE_DATABASE_IMAGE_VALKEY:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/valkey"}
|
||||
TROVE_DATABASE_BACKUP_IMAGE_MYSQL=${TROVE_DATABASE_BACKUP_IMAGE_MYSQL:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/db-backup-mysql"}
|
||||
TROVE_DATABASE_BACKUP_IMAGE_MARIADB=${TROVE_DATABASE_BACKUP_IMAGE_MARIADB:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/db-backup-mariadb"}
|
||||
TROVE_DATABASE_BACKUP_IMAGE_POSTGRESQL=${TROVE_DATABASE_BACKUP_IMAGE_POSTGRESQL:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/db-backup-postgresql"}
|
||||
TROVE_DATABASE_BACKUP_IMAGE_KEYDB=${TROVE_DATABASE_BACKUP_IMAGE_KEYDB:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/db-backup-keydb"}
|
||||
TROVE_DATABASE_BACKUP_IMAGE_VALKEY=${TROVE_DATABASE_BACKUP_IMAGE_VALKEY:-"$TROVE_HOST_GATEWAY:4000/trove-datastores/db-backup-valkey"}
|
||||
else
|
||||
TROVE_DATABASE_IMAGE_MYSQL=${TROVE_DATABASE_IMAGE_MYSQL:-"quay.io/openstack.trove/mysql"}
|
||||
TROVE_DATABASE_IMAGE_MARIADB=${TROVE_DATABASE_IMAGE_MARIAD:-"quay.io/openstack.trove/mariadb"}
|
||||
TROVE_DATABASE_IMAGE_POSTGRESQL=${TROVE_DATABASE_IMAGE_POSTGRESQL:-"quay.io/openstack.trove/postgres"}
|
||||
TROVE_DATABASE_IMAGE_KEYDB=${TROVE_DATABASE_IMAGE_KEYDB:-"quay.io/openstack.trove/keydb"}
|
||||
TROVE_DATABASE_IMAGE_VALKEY=${TROVE_DATABASE_IMAGE_VALKEY:-"quay.io/openstack.trove/valkey"}
|
||||
TROVE_DATABASE_BACKUP_IMAGE_MYSQL=${TROVE_DATABASE_BACKUP_IMAGE_MYSQL:-"quay.io/openstack.trove/db-backup-mysql"}
|
||||
TROVE_DATABASE_BACKUP_IMAGE_MARIADB=${TROVE_DATABASE_BACKUP_IMAGE_MARIADB:-"quay.io/openstack.trove/db-backup-mariadb"}
|
||||
TROVE_DATABASE_BACKUP_IMAGE_POSTGRESQL=${TROVE_DATABASE_BACKUP_IMAGE_POSTGRESQL:-"quay.io/openstack.trove/db-backup-postgresql"}
|
||||
TROVE_DATABASE_BACKUP_IMAGE_KEYDB=${TROVE_DATABASE_BACKUP_IMAGE_KEYDB:-"quay.io/openstack.trove/db-backup-keydb"}
|
||||
TROVE_DATABASE_BACKUP_IMAGE_VALKEY=${TROVE_DATABASE_BACKUP_IMAGE_VALKEY:-"quay.io/openstack.trove/db-backup-valkey"}
|
||||
fi
|
||||
|
||||
AMQP_PORT=${AMQP_PORT:-5672}
|
||||
|
||||
@@ -36,7 +36,7 @@ reliable options. Other datastores not included in the matrix may still function
|
||||
but they haven't undergone full testing.
|
||||
|
||||
.. list-table:: Supported Databases by OpenStack Release
|
||||
:widths: 20 4 4 4 4 4 4 4 4 4 4
|
||||
:widths: 20 4 4 4 4 4 4 4 4 4 4 4 4
|
||||
:header-rows: 2
|
||||
|
||||
* - OpenStack Release
|
||||
@@ -50,6 +50,8 @@ but they haven't undergone full testing.
|
||||
-
|
||||
- MariaDB
|
||||
-
|
||||
- KeyDB
|
||||
- Valkey
|
||||
* -
|
||||
- 12
|
||||
- 16
|
||||
@@ -61,6 +63,8 @@ but they haven't undergone full testing.
|
||||
- 10.4
|
||||
- 11.4
|
||||
- 11.8
|
||||
- 6.3.3
|
||||
- 9
|
||||
* - 2026.2 Hibiscus
|
||||
- ✘
|
||||
- ✔
|
||||
@@ -72,6 +76,8 @@ but they haven't undergone full testing.
|
||||
- ✘
|
||||
- ✔
|
||||
- ✔
|
||||
- ✔
|
||||
- ✔
|
||||
* - 2026.1 Gazpacho
|
||||
- ✘
|
||||
- ✔
|
||||
@@ -83,6 +89,8 @@ but they haven't undergone full testing.
|
||||
- ✘
|
||||
- ✔
|
||||
- ✔
|
||||
- ✘
|
||||
- ✘
|
||||
* - 2025.2 Flamingo
|
||||
- ✘
|
||||
- ✔
|
||||
@@ -94,6 +102,8 @@ but they haven't undergone full testing.
|
||||
- ✘
|
||||
- ✔
|
||||
- ✔
|
||||
- ✘
|
||||
- ✘
|
||||
* - 2025.1 Epoxy
|
||||
- ✔
|
||||
- ✘
|
||||
@@ -105,6 +115,8 @@ but they haven't undergone full testing.
|
||||
- ✔
|
||||
- ✘
|
||||
- ✘
|
||||
- ✘
|
||||
- ✘
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ handling complex administrative tasks.
|
||||
instance-status.rst
|
||||
create-db.rst
|
||||
manage-db-and-users.rst
|
||||
manage-db-and-users-in-valkey-and-keydb.rst
|
||||
backup-db.rst
|
||||
manage-db-config.rst
|
||||
set-up-replication.rst
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
.. _manage_db_and_users_in_valkey_and_keydb:
|
||||
|
||||
==========================================
|
||||
Manage users on KeyDB and Valkey instances
|
||||
==========================================
|
||||
|
||||
KeyDB and Valkey use Redis ACLs for access control. Unlike relational
|
||||
datastores such as MySQL, Trove databases in KeyDB and Valkey do not represent
|
||||
separate logical databases created by users.
|
||||
|
||||
Instead, Trove exposes the available Redis ACL command categories through the
|
||||
Database and User API. These categories can be assigned to users to control
|
||||
which categories of Redis commands they are allowed to execute.
|
||||
|
||||
Manage users
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Users can be created using the same Trove CLI commands as for other supported
|
||||
datastores. The ``--databases`` option specifies the ACL categories that should
|
||||
be granted to the user.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ openstack database user create keydb-instance newuser userpass \
|
||||
--databases read write
|
||||
|
||||
$ openstack database user list keydb-instance
|
||||
+---------+------+---------------+
|
||||
| Name | Host | Databases |
|
||||
+---------+------+---------------+
|
||||
| newuser | | read, write |
|
||||
+---------+------+---------------+
|
||||
|
||||
The ``Host`` field is not applicable to KeyDB or Valkey because Redis ACLs are
|
||||
not associated with a client hostname.
|
||||
|
||||
Users can authenticate directly against the datastore using their username and
|
||||
password.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ redis-cli --user newuser --pass userpass
|
||||
127.0.0.1:6379> SET mykey value
|
||||
OK
|
||||
127.0.0.1:6379> GET mykey
|
||||
"value"
|
||||
|
||||
Available access categories
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The available categories can be listed using the Trove Database API.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ openstack database db list keydb-instance
|
||||
+-------------+
|
||||
| Name |
|
||||
+-------------+
|
||||
| read |
|
||||
| write |
|
||||
| keyspace |
|
||||
| connection |
|
||||
| ... |
|
||||
+-------------+
|
||||
|
||||
The exact list of available categories depends on the datastore implementation
|
||||
and version.
|
||||
|
||||
These entries do not represent actual KeyDB or Valkey databases. They represent
|
||||
Redis ACL command categories.
|
||||
|
||||
Manage user access
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Access to additional command categories can be granted to an existing user.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ openstack database user grant access keydb-instance newuser keyspace
|
||||
|
||||
$ openstack database user show access keydb-instance newuser
|
||||
+-------------+
|
||||
| Name |
|
||||
+-------------+
|
||||
| read |
|
||||
| write |
|
||||
| keyspace |
|
||||
+-------------+
|
||||
|
||||
Access can also be revoked.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ openstack database user revoke access keydb-instance newuser keyspace
|
||||
|
||||
$ openstack database user show access keydb-instance newuser
|
||||
+--------+
|
||||
| Name |
|
||||
+--------+
|
||||
| read |
|
||||
| write |
|
||||
+--------+
|
||||
|
||||
Database management
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
KeyDB and Valkey do not support creating or deleting databases through the
|
||||
Trove Database API.
|
||||
|
||||
The ``database create`` and ``database delete`` operations are therefore not
|
||||
applicable to these datastores. The database list is provided only to expose
|
||||
the available Redis ACL categories that can be assigned to users.
|
||||
|
||||
Manage root user
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
The root user can be enabled and disabled using the standard Trove commands.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ openstack database root enable keydb-instance
|
||||
+----------+--------------------------------------+
|
||||
| Field | Value |
|
||||
+----------+--------------------------------------+
|
||||
| name | root |
|
||||
| password | I5nPpBj1qf1eGR1idQorj1szppXGpYyYNj4h |
|
||||
+----------+--------------------------------------+
|
||||
|
||||
The root user has unrestricted access to the datastore.
|
||||
|
||||
If needed, the root user can be disabled.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ openstack database root disable keydb-instance
|
||||
@@ -124,3 +124,31 @@ The following guidance may help users operating production DBaaS:
|
||||
|
||||
These recommendations are based on common production practices and may
|
||||
vary depending on organizational security policies.
|
||||
|
||||
|
||||
Valkey and KeyDB
|
||||
----------------
|
||||
|
||||
Valkey and KeyDB support the same SSL modes as other datastores, but the
|
||||
listening ports depend on the selected mode:
|
||||
|
||||
* ``basic``: plain connections are accepted on port ``6379``, while TLS
|
||||
connections are accepted on port ``6380``.
|
||||
* ``enforced``: only TLS connections are accepted on port ``6379``. The
|
||||
plain TCP listener is disabled.
|
||||
* ``mtls``: only TLS connections are accepted on port ``6379``, and clients
|
||||
are required to provide a valid TLS certificate.
|
||||
|
||||
The following table summarizes the port configuration:
|
||||
|
||||
+------------+------------+----------+
|
||||
| SSL mode | Plain port | TLS port |
|
||||
+============+============+==========+
|
||||
| ``basic`` | ``6379`` | ``6380`` |
|
||||
+------------+------------+----------+
|
||||
|``enforced``| Disabled | ``6379`` |
|
||||
+------------+------------+----------+
|
||||
| ``mtls`` | Disabled | ``6379`` |
|
||||
+------------+------------+----------+
|
||||
|
||||
When SSL is disabled, plain connections are accepted on port ``6379``.
|
||||
@@ -42,6 +42,8 @@
|
||||
- { source: "mysql", dest: "mysql", tag: "8.4" }
|
||||
- { source: "postgres", dest: "postgres", tag: "17" }
|
||||
- { source: "postgres", dest: "postgres", tag: "18" }
|
||||
- { source: "eqalpha/keydb", dest: "keydb", tag: "6.3.3" }
|
||||
- { source: "valkey/valkey", dest: "valkey", tag: "9" }
|
||||
|
||||
- name: build and push trove backup images
|
||||
become: true
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
New KeyDB and Valkey, Redis-based datastores.
|
||||
Original legacy "experimental" Redis implementation is untouched.
|
||||
@@ -47,6 +47,7 @@ docker>=4.2.0 # Apache-2.0
|
||||
psycopg2-binary>=2.6.2 # LGPL/ZPL
|
||||
semantic-version>=2.7.0 # BSD
|
||||
oslo.cache>=1.26.0 # Apache-2.0
|
||||
valkey>=6.1.1 # MIT
|
||||
|
||||
# for trove network driver
|
||||
Flask>=2.2.3 # BSD
|
||||
|
||||
@@ -420,6 +420,8 @@ common_opts = [
|
||||
'percona': 'fd1723f5-68d2-409c-994f-a4a197892a17',
|
||||
'pxc': '75a628c3-f81b-4ffb-b10a-4087c26bc854',
|
||||
'redis': 'b216ffc5-1947-456c-a4cf-70f94c05f7d0',
|
||||
'keydb': '660f837d-ae0b-4eae-aa78-8ab80a64b0b8',
|
||||
'valkey': '6108c745-b3bf-4d70-bdbb-4c31128da66a',
|
||||
'cassandra': '459a230d-4e97-4344-9067-2a54a310b0ed',
|
||||
'couchbase': 'fa62fe68-74d9-4779-a24e-36f19602c415',
|
||||
'mongodb': 'c8c907af-7375-456f-b929-b637ff9209ee',
|
||||
@@ -862,6 +864,153 @@ redis_opts = [
|
||||
]
|
||||
|
||||
|
||||
# KeyDB / Valkey
|
||||
def _build_redis_family_datastore_opts(
|
||||
datastore_name,
|
||||
backup_strategy,
|
||||
replication_strategy,
|
||||
replication_namespace,
|
||||
docker_image,
|
||||
):
|
||||
group = cfg.OptGroup(
|
||||
datastore_name,
|
||||
title=f'{datastore_name.capitalize()} options',
|
||||
help=f"Oslo option group designed for "
|
||||
f"{datastore_name.capitalize()} datastore",
|
||||
)
|
||||
|
||||
opts = [
|
||||
cfg.StrOpt(
|
||||
'database_service_uname',
|
||||
default='database',
|
||||
help='The name of database service user.',
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'database_service_uid',
|
||||
help='The UID of database service user.',
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'database_service_gid',
|
||||
help='The GID of database service user.',
|
||||
),
|
||||
cfg.BoolOpt(
|
||||
'icmp',
|
||||
default=False,
|
||||
help='Whether to permit ICMP.',
|
||||
deprecated_for_removal=True,
|
||||
),
|
||||
cfg.ListOpt(
|
||||
'tcp_ports',
|
||||
default=["6379", "6380"],
|
||||
item_type=ListOfPortsType,
|
||||
help='List of TCP ports and/or port ranges to open '
|
||||
'in the security group (only applicable '
|
||||
'if trove_security_groups_support is True).',
|
||||
),
|
||||
cfg.ListOpt(
|
||||
'udp_ports',
|
||||
default=[],
|
||||
item_type=ListOfPortsType,
|
||||
help='List of UDP ports and/or port ranges to open '
|
||||
'in the security group (only applicable '
|
||||
'if trove_security_groups_support is True).',
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'backup_strategy',
|
||||
default=backup_strategy,
|
||||
help='Default strategy to perform backups.',
|
||||
deprecated_name='backup_strategy',
|
||||
deprecated_group='DEFAULT',
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'replication_strategy',
|
||||
default=replication_strategy,
|
||||
help='Default strategy for replication.',
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'replication_namespace',
|
||||
default=replication_namespace,
|
||||
help='Namespace to load replication strategies from.',
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'mount_point',
|
||||
default=('/var/lib/%s' % datastore_name),
|
||||
help='Filesystem path for mounting '
|
||||
'volumes if volume support is enabled.',
|
||||
),
|
||||
cfg.BoolOpt(
|
||||
'volume_support',
|
||||
default=True,
|
||||
help='Whether to provision a Cinder volume for datadir.',
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'device_path',
|
||||
default='/dev/vdb',
|
||||
help='Device path for volume if volume support is enabled.',
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'root_controller',
|
||||
default='trove.extensions.common.service.DefaultRootController',
|
||||
help='Root controller implementation for redis.'
|
||||
),
|
||||
cfg.ListOpt(
|
||||
'ignore_users',
|
||||
default=['os_admin', 'default', 'replicator']
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'guest_log_exposed_logs',
|
||||
default='',
|
||||
help='List of Guest Logs to expose for publishing.',
|
||||
),
|
||||
cfg.IntOpt(
|
||||
'default_password_length',
|
||||
default=36,
|
||||
help='Character length of generated passwords.',
|
||||
),
|
||||
cfg.ListOpt(
|
||||
'user_acl_categories',
|
||||
default=["+@read", "+@write", "+@keyspace", "+@connection"],
|
||||
help='ACL groups list applied for non-root users'
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'docker_image',
|
||||
default=docker_image,
|
||||
help='Database docker image.',
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'backup_docker_image',
|
||||
sample_default=(
|
||||
'your-registry/your-repo/db-backup-'
|
||||
f'{datastore_name}'
|
||||
),
|
||||
help='The docker image used for backup and restore.',
|
||||
),
|
||||
]
|
||||
|
||||
return group, opts
|
||||
|
||||
|
||||
keydb_group, keydb_opts = _build_redis_family_datastore_opts(
|
||||
datastore_name='keydb',
|
||||
backup_strategy='keydbbackup',
|
||||
replication_strategy='KeyDBSyncReplication',
|
||||
replication_namespace=(
|
||||
'trove.guestagent.strategies.replication.keydb'
|
||||
),
|
||||
docker_image='eqalpha/keydb',
|
||||
)
|
||||
|
||||
|
||||
valkey_group, valkey_opts = _build_redis_family_datastore_opts(
|
||||
datastore_name='valkey',
|
||||
backup_strategy='valkeybackup',
|
||||
replication_strategy='ValKeySyncReplication',
|
||||
replication_namespace=(
|
||||
'trove.guestagent.strategies.replication.valkey'
|
||||
),
|
||||
docker_image='valkey/valkey',
|
||||
)
|
||||
|
||||
# Cassandra
|
||||
cassandra_group = cfg.OptGroup(
|
||||
'cassandra', title='Cassandra options',
|
||||
@@ -1623,6 +1772,8 @@ CONF.register_group(mysql_group)
|
||||
CONF.register_group(percona_group)
|
||||
CONF.register_group(pxc_group)
|
||||
CONF.register_group(redis_group)
|
||||
CONF.register_group(keydb_group)
|
||||
CONF.register_group(valkey_group)
|
||||
CONF.register_group(cassandra_group)
|
||||
CONF.register_group(couchbase_group)
|
||||
CONF.register_group(mongodb_group)
|
||||
@@ -1639,6 +1790,8 @@ CONF.register_opts(mysql_opts, mysql_group)
|
||||
CONF.register_opts(percona_opts, percona_group)
|
||||
CONF.register_opts(pxc_opts, pxc_group)
|
||||
CONF.register_opts(redis_opts, redis_group)
|
||||
CONF.register_opts(keydb_opts, keydb_group)
|
||||
CONF.register_opts(valkey_opts, valkey_group)
|
||||
CONF.register_opts(cassandra_opts, cassandra_group)
|
||||
CONF.register_opts(couchbase_opts, couchbase_group)
|
||||
CONF.register_opts(mongodb_opts, mongodb_group)
|
||||
|
||||
@@ -30,5 +30,9 @@ REGISTRY_EXT_DEFAULTS = {
|
||||
'mariadb':
|
||||
'trove.guestagent.datastore.mariadb.manager.Manager',
|
||||
'postgresql':
|
||||
'trove.guestagent.datastore.postgres.manager.PostgresManager'
|
||||
'trove.guestagent.datastore.postgres.manager.PostgresManager',
|
||||
'keydb':
|
||||
'trove.guestagent.datastore.keydb.manager.Manager',
|
||||
'valkey':
|
||||
'trove.guestagent.datastore.valkey.manager.Manager',
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,45 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
import re
|
||||
|
||||
from trove.common import cfg
|
||||
from trove.common.db import models
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class RedisCommonUser(models.DatastoreUser):
|
||||
"""Represents a Redis-family ACL user."""
|
||||
|
||||
not_supported_chars = re.compile(r"""\s|'|\"|;|`|,|/|\\""")
|
||||
|
||||
def _is_valid_string(self, value):
|
||||
if (not value or
|
||||
self.not_supported_chars.search(value) or
|
||||
("%r" % value).find("\\") != -1):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def _is_valid_user_name(self, value):
|
||||
return self._is_valid_string(value)
|
||||
|
||||
def _is_valid_password(self, value):
|
||||
return self._is_valid_string(value)
|
||||
|
||||
|
||||
class RedisCommonSchema(models.DatastoreSchema):
|
||||
pass
|
||||
@@ -38,6 +38,8 @@ SERVICE_PARSERS = {
|
||||
'postgresql': configurations.PostgresqlConfParser,
|
||||
'cassandra': configurations.CassandraConfParser,
|
||||
'redis': configurations.RedisConfParser,
|
||||
'keydb': configurations.RedisConfParser,
|
||||
'valkey': configurations.RedisConfParser,
|
||||
'vertica': configurations.VerticaConfParser,
|
||||
'db2': configurations.DB2ConfParser,
|
||||
}
|
||||
|
||||
@@ -30,9 +30,16 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
EXTENSIONS_SUPPORTED_DATASTORES = ['mysql', 'mariadb', 'postgresql',
|
||||
'keydb', 'valkey']
|
||||
|
||||
# List of datastores supporting CRUD operations for databases
|
||||
SCHEMA_MANAGEMENT_SUPPORTED_DATASTORES = ['mysql', 'mariadb', 'postgresql']
|
||||
SCHEMA_VIEW_SUPPORTED_DATASTORES = EXTENSIONS_SUPPORTED_DATASTORES
|
||||
|
||||
|
||||
def load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql']):
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES):
|
||||
"""Check instance datastore.
|
||||
|
||||
Some API operations are only supported for some specific datastores.
|
||||
@@ -59,7 +66,7 @@ class Root(object):
|
||||
@classmethod
|
||||
def load(cls, context, instance_id):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
# TODO(pdmars): remove the is_root_enabled call from the guest agent,
|
||||
# just check the database for this information.
|
||||
# If the root history returns null or raises an exception, the root
|
||||
@@ -79,7 +86,7 @@ class Root(object):
|
||||
def create(cls, context, instance_id, root_password,
|
||||
cluster_instances_list=None):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
if root_password:
|
||||
root = create_guest_client(context,
|
||||
instance_id).enable_root_with_password(
|
||||
@@ -101,7 +108,7 @@ class Root(object):
|
||||
@classmethod
|
||||
def delete(cls, context, instance_id):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
create_guest_client(context, instance_id).disable_root()
|
||||
|
||||
root_history = RootHistory.load(context, instance_id)
|
||||
@@ -164,7 +171,7 @@ class RootHistory(object):
|
||||
def load_via_context(cls, context, instance_id):
|
||||
"""Creates guest and fetches pagination arguments from the context."""
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
limit = utils.pagination_limit(context.limit, cls.DEFAULT_LIMIT)
|
||||
client = create_guest_client(context, instance_id)
|
||||
# The REST API standard dictates that we *NEVER* include the marker.
|
||||
@@ -190,7 +197,7 @@ class User(object):
|
||||
def load(cls, context, instance_id, username, hostname, root_user=False):
|
||||
instance = load_and_verify(
|
||||
context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
validate = guest_models.DatastoreUser(
|
||||
name=username, host=hostname,
|
||||
datastore_manager=instance.datastore_version.manager)
|
||||
@@ -212,7 +219,7 @@ class User(object):
|
||||
def create(cls, context, instance_id, users, datastore_manager=None):
|
||||
# Load InstanceServiceStatus to verify if it's running
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
client = create_guest_client(context, instance_id)
|
||||
for user in users:
|
||||
user_name = user['_name']
|
||||
@@ -234,7 +241,7 @@ class User(object):
|
||||
@classmethod
|
||||
def delete(cls, context, instance_id, user):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
|
||||
with StartNotification(context, instance_id=instance_id,
|
||||
username=user):
|
||||
@@ -243,7 +250,7 @@ class User(object):
|
||||
@classmethod
|
||||
def access(cls, context, instance_id, username, hostname):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
client = create_guest_client(context, instance_id)
|
||||
databases = client.list_access(username, hostname)
|
||||
dbs = []
|
||||
@@ -256,21 +263,21 @@ class User(object):
|
||||
@classmethod
|
||||
def grant(cls, context, instance_id, username, hostname, databases):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
client = create_guest_client(context, instance_id)
|
||||
client.grant_access(username, hostname, databases)
|
||||
|
||||
@classmethod
|
||||
def revoke(cls, context, instance_id, username, hostname, database):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
client = create_guest_client(context, instance_id)
|
||||
client.revoke_access(username, hostname, database)
|
||||
|
||||
@classmethod
|
||||
def change_password(cls, context, instance_id, users):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=EXTENSIONS_SUPPORTED_DATASTORES)
|
||||
client = create_guest_client(context, instance_id)
|
||||
change_users = []
|
||||
for user in users:
|
||||
@@ -366,8 +373,9 @@ class Schema(object):
|
||||
|
||||
@classmethod
|
||||
def create(cls, context, instance_id, schemas, datastore_manager=None):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
load_and_verify(
|
||||
context, instance_id,
|
||||
enabled_datastore=SCHEMA_MANAGEMENT_SUPPORTED_DATASTORES)
|
||||
client = create_guest_client(context, instance_id)
|
||||
for schema in schemas:
|
||||
schema_name = schema['_name']
|
||||
@@ -384,8 +392,9 @@ class Schema(object):
|
||||
|
||||
@classmethod
|
||||
def delete(cls, context, instance_id, schema):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
load_and_verify(
|
||||
context, instance_id,
|
||||
enabled_datastore=SCHEMA_MANAGEMENT_SUPPORTED_DATASTORES)
|
||||
create_guest_client(context, instance_id).delete_database(schema)
|
||||
|
||||
|
||||
@@ -420,7 +429,7 @@ class Schemas(object):
|
||||
@classmethod
|
||||
def find(cls, context, instance_id, schema_id, datastore_manager=None):
|
||||
load_and_verify(context, instance_id,
|
||||
enabled_datastore=['mysql', 'mariadb', 'postgresql'])
|
||||
enabled_datastore=SCHEMA_VIEW_SUPPORTED_DATASTORES)
|
||||
client = create_guest_client(context, instance_id)
|
||||
model_schemas, _ = cls.load_with_client(
|
||||
client, 1, schema_id, True,
|
||||
|
||||
@@ -560,3 +560,130 @@ class OneFileOverrideStrategy(ConfigurationOverrideStrategy):
|
||||
operating_system.write_file(
|
||||
self._base_config_path, updated_revision, codec=self._codec,
|
||||
as_root=self._requires_root)
|
||||
|
||||
|
||||
class IndexOverrideStrategy(ImportOverrideStrategy):
|
||||
"""Index strategy keeps overrides in separate files and maintains
|
||||
an index file listing all active override files.
|
||||
|
||||
This strategy is used for configuration formats that allow including
|
||||
other files only by explicit path and do not support wildcard
|
||||
patterns (e.g. '*.conf').
|
||||
|
||||
Override files are stored in a dedicated directory and referenced
|
||||
from 'index.conf'. When a new override file is created its path is
|
||||
added to the index file, and removed when the override is deleted.
|
||||
"""
|
||||
INDEX_FILE_NAME = "index.conf"
|
||||
|
||||
def __init__(self, revision_dir, revision_ext, index_keyword="include "):
|
||||
super().__init__(revision_dir, revision_ext)
|
||||
self._index_keyword = index_keyword
|
||||
self._index_file = guestagent_utils.build_file_path(
|
||||
revision_dir, self.INDEX_FILE_NAME)
|
||||
|
||||
def configure(self, base_config_path, owner, group, codec, requires_root):
|
||||
super().configure(base_config_path, owner, group, codec, requires_root)
|
||||
|
||||
if not operating_system.exists(self._index_file,
|
||||
as_root=self._requires_root):
|
||||
operating_system.write_file(
|
||||
self._index_file, "", as_root=self._requires_root)
|
||||
operating_system.chown(
|
||||
self._index_file, self._owner, self._group,
|
||||
as_root=self._requires_root)
|
||||
operating_system.chmod(
|
||||
self._index_file, FileMode.ADD_READ_ALL,
|
||||
as_root=self._requires_root)
|
||||
|
||||
def apply(self, group_name, change_id, options):
|
||||
self._initialize_import_directory()
|
||||
|
||||
revision_file = self._find_revision_file(group_name, change_id)
|
||||
created = False
|
||||
|
||||
if revision_file is None:
|
||||
last_revision_index = self._get_last_file_index(group_name)
|
||||
revision_file = guestagent_utils.build_file_path(
|
||||
self._revision_dir,
|
||||
'%s-%03d-%s' % (group_name, last_revision_index + 1,
|
||||
change_id),
|
||||
self._revision_ext)
|
||||
created = True
|
||||
else:
|
||||
current = operating_system.read_file(
|
||||
revision_file, codec=self._codec,
|
||||
as_root=self._requires_root)
|
||||
for key, value in options.items():
|
||||
if value is None:
|
||||
if key in current:
|
||||
del current[key]
|
||||
else:
|
||||
current[key] = value
|
||||
options = current
|
||||
|
||||
operating_system.write_file(
|
||||
revision_file, options, codec=self._codec,
|
||||
as_root=self._requires_root)
|
||||
|
||||
operating_system.chown(
|
||||
revision_file, self._owner, self._group,
|
||||
as_root=self._requires_root)
|
||||
|
||||
operating_system.chmod(
|
||||
revision_file, FileMode.ADD_READ_ALL,
|
||||
as_root=self._requires_root)
|
||||
|
||||
if created:
|
||||
self._add_to_index(revision_file)
|
||||
|
||||
def remove(self, group_name, change_id=None):
|
||||
removed = set()
|
||||
|
||||
if change_id:
|
||||
revision_file = self._find_revision_file(group_name, change_id)
|
||||
if revision_file:
|
||||
removed.add(revision_file)
|
||||
else:
|
||||
removed = set(self._collect_revision_files(group_name))
|
||||
|
||||
for path in removed:
|
||||
self._remove_from_index(path)
|
||||
operating_system.remove(path, force=True,
|
||||
as_root=self._requires_root)
|
||||
|
||||
def _read_index(self):
|
||||
if not operating_system.exists(self._index_file,
|
||||
as_root=self._requires_root):
|
||||
return []
|
||||
|
||||
content = operating_system.read_file(
|
||||
self._index_file,
|
||||
as_root=self._requires_root)
|
||||
|
||||
return [line.strip() for line in content.splitlines() if line.strip()]
|
||||
|
||||
def _write_index(self, lines):
|
||||
new_content = "\n".join(lines) + "\n" if lines else ""
|
||||
|
||||
operating_system.write_file(
|
||||
self._index_file,
|
||||
new_content,
|
||||
as_root=self._requires_root)
|
||||
|
||||
def _add_to_index(self, path):
|
||||
lines = self._read_index()
|
||||
record = self._index_keyword + path
|
||||
|
||||
if record not in lines:
|
||||
lines.append(record)
|
||||
|
||||
self._write_index(lines)
|
||||
|
||||
def _remove_from_index(self, path):
|
||||
lines = self._read_index()
|
||||
record = self._index_keyword + path
|
||||
|
||||
lines = [line for line in lines if line != record]
|
||||
|
||||
self._write_index(lines)
|
||||
Whitespace-only changes.
@@ -0,0 +1,21 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from trove.guestagent.datastore.keydb import service
|
||||
from trove.guestagent.datastore.redis_common.manager import RedisManager
|
||||
|
||||
|
||||
class Manager(RedisManager):
|
||||
DATASTORE_NAME = 'keydb'
|
||||
APP_CLASS = service.KeyDBApp
|
||||
@@ -0,0 +1,37 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from trove.guestagent.datastore.redis_common import service
|
||||
|
||||
|
||||
class KeyDBApp(service.RedisApp):
|
||||
DATASTORE_NAME = 'keydb'
|
||||
CLI_BINARY = 'keydb-cli'
|
||||
CONFIG_FILE = "/etc/keydb/keydb.conf"
|
||||
CNF_INCLUDE_DIR = '/etc/keydb/conf.d'
|
||||
SOCKET_PATH = '/var/lib/keydb-socket'
|
||||
CONTAINER_SOCKET = '/var/run/keydb/keydb.sock'
|
||||
ACL_FILE = '/var/lib/keydb/conf.d/users.acl'
|
||||
SERVER_BINARY = 'keydb-server'
|
||||
DATA_ENV_NAME = 'KEYDB_DATA'
|
||||
|
||||
HEALTHCHECK = {
|
||||
"test": [
|
||||
"CMD-SHELL",
|
||||
f"keydb-cli -s {CONTAINER_SOCKET} ping | grep -qx PONG"],
|
||||
"start_period": 10 * 1000000000, # 10 seconds in nanoseconds
|
||||
"interval": 10 * 1000000000,
|
||||
"timeout": 5 * 1000000000,
|
||||
"retries": 3
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,278 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from oslo_log import log as logging
|
||||
from trove.common import cfg
|
||||
from trove.common import exception
|
||||
from trove.common.notification import EndNotification
|
||||
from trove.common import ssl
|
||||
from trove.guestagent.common import operating_system
|
||||
from trove.guestagent.datastore import manager
|
||||
from trove.guestagent.datastore import service as base_service
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
OSADMIN_USER = 'os_admin'
|
||||
REPLICATION_USER = 'replicator'
|
||||
|
||||
|
||||
class RedisManager(manager.Manager):
|
||||
DATASTORE_NAME = None
|
||||
APP_CLASS = None
|
||||
|
||||
def __init__(self):
|
||||
if self.DATASTORE_NAME is None:
|
||||
raise NotImplementedError(
|
||||
"DATASTORE_NAME must be defined by the datastore manager")
|
||||
|
||||
if self.APP_CLASS is None:
|
||||
raise exception.TroveError(
|
||||
f"{self.__class__.__name__} must define APP_CLASS"
|
||||
)
|
||||
|
||||
super().__init__(self.DATASTORE_NAME)
|
||||
self.status = base_service.BaseDbStatus(self.docker_client)
|
||||
self.app = self.APP_CLASS(self.status, self.docker_client)
|
||||
self.adm = self.app.adm
|
||||
|
||||
@property
|
||||
def configuration_manager(self):
|
||||
return self.app.configuration_manager
|
||||
|
||||
def do_prepare(self, context, packages, databases, memory_mb, users,
|
||||
device_path, mount_point, backup_info,
|
||||
config_contents, root_password, overrides,
|
||||
cluster_config, snapshot, ds_version=None):
|
||||
operating_system.ensure_directory(self.app.datadir,
|
||||
user=self.app.database_service_uid,
|
||||
group=self.app.database_service_gid,
|
||||
force=True, as_root=True)
|
||||
|
||||
LOG.info("Preparing database config files")
|
||||
self.configuration_manager.reset_configuration(config_contents)
|
||||
self.update_overrides(context, overrides)
|
||||
|
||||
# Restore data from backup
|
||||
if backup_info:
|
||||
self.perform_restore(context, self.app.datadir, backup_info)
|
||||
|
||||
if not operating_system.exists(self.app.ACL_FILE, as_root=True):
|
||||
|
||||
osadmin_password = self.app.get_osadmin_password()
|
||||
|
||||
# Enable ping without auth for docker health checks
|
||||
# And also full access account for admin purposes.
|
||||
acl_rules = (
|
||||
"user default on nopass ~* &* -@all +ping\n"
|
||||
f"user {OSADMIN_USER} on >{osadmin_password} ~* &* +@all\n"
|
||||
)
|
||||
|
||||
operating_system.write_file(
|
||||
self.app.ACL_FILE,
|
||||
acl_rules,
|
||||
as_root=True
|
||||
)
|
||||
operating_system.chown(self.app.ACL_FILE,
|
||||
self.app.database_service_uid,
|
||||
self.app.database_service_gid,
|
||||
force=True, as_root=True)
|
||||
|
||||
self.app.enable_aclfile()
|
||||
|
||||
if snapshot:
|
||||
# This instance is a replica
|
||||
self.attach_replica(context, snapshot, snapshot['config'])
|
||||
|
||||
self.app.start_db(ds_version=ds_version, memory_mb=memory_mb)
|
||||
|
||||
def enable_root(self, context):
|
||||
root_password = self.app.set_password()
|
||||
root = self.adm.enable_root(root_password)
|
||||
return root
|
||||
|
||||
def enable_root_with_password(self, context, root_password=None):
|
||||
self.app.set_password(root_password)
|
||||
root = self.adm.enable_root(root_password)
|
||||
return root
|
||||
|
||||
def apply_overrides(self, context, overrides):
|
||||
"""Reload config."""
|
||||
LOG.info("Reloading database config.")
|
||||
self.app.apply_overrides(overrides)
|
||||
LOG.info("Finished reloading database config.")
|
||||
|
||||
def create_backup(self, context, backup_info):
|
||||
"""Create backup for the database.
|
||||
|
||||
:param context: User context object.
|
||||
:param backup_info: a dictionary containing the db instance id of the
|
||||
backup task, location, type, and other data.
|
||||
"""
|
||||
LOG.info("Creating backup %s", backup_info['id'])
|
||||
with EndNotification(context):
|
||||
volumes_mapping = {}
|
||||
volumes_mapping[self.app.datadir] = {
|
||||
'bind': ('/var/lib/%s' % self.DATASTORE_NAME),
|
||||
'mode': 'rw'
|
||||
}
|
||||
extra_params = ""
|
||||
|
||||
self.adm.database_sync()
|
||||
|
||||
self.app.create_backup(context, backup_info,
|
||||
volumes_mapping=volumes_mapping,
|
||||
need_dbuser=False,
|
||||
extra_params=extra_params)
|
||||
|
||||
def attach_replica(self, context, replica_info, slave_config,
|
||||
restart=False):
|
||||
LOG.debug("attach_replica")
|
||||
self.replication.enable_as_slave(
|
||||
self.app,
|
||||
replica_info, None) # type: ignore
|
||||
|
||||
if "cert_container" in replica_info:
|
||||
self.enable_ssl_certificate(
|
||||
replica_info["ssl_mode"], replica_info["cert_container"],
|
||||
apply_overrides=True, is_startup=True)
|
||||
|
||||
if restart:
|
||||
self.app.restart()
|
||||
|
||||
def make_read_only(self, context, read_only):
|
||||
# there is no way to mark redis instance
|
||||
# readonly except making it slave
|
||||
pass
|
||||
|
||||
def get_latest_txn_id(self, context):
|
||||
# No transactions support in Redis
|
||||
pass
|
||||
|
||||
def wait_for_txn(self, context, txn):
|
||||
# No transactions support in Redis
|
||||
pass
|
||||
|
||||
def upgrade(self, context, upgrade_info):
|
||||
"""Upgrade the database."""
|
||||
LOG.info("Starting to upgrade database, upgrade_info: %s",
|
||||
upgrade_info)
|
||||
self.app.upgrade(upgrade_info)
|
||||
|
||||
def rebuild(self, context, ds_version, config_contents=None,
|
||||
config_overrides=None):
|
||||
"""Restore datastore service after instance rebuild."""
|
||||
LOG.info("Starting to restore database service")
|
||||
self.status.begin_install()
|
||||
|
||||
operating_system.ensure_directory(self.app.datadir,
|
||||
user=self.app.database_service_uid,
|
||||
group=self.app.database_service_gid,
|
||||
force=True, as_root=True)
|
||||
try:
|
||||
# Prepare configuration
|
||||
LOG.debug("Preparing database configuration")
|
||||
self.app.configuration_manager.reset_configuration(config_contents)
|
||||
|
||||
self.app.update_overrides(config_overrides)
|
||||
|
||||
# Enable SSL, if necessary
|
||||
if self.ssl_mode_at_least(CONF.ssl_mode, ssl.MODE_BASIC):
|
||||
cert_container = self._read_ssl_files()
|
||||
self.enable_ssl_certificate(
|
||||
CONF.ssl_mode, cert_container,
|
||||
apply_overrides=True, is_startup=True)
|
||||
|
||||
self.app.enable_aclfile()
|
||||
|
||||
# Start database service.
|
||||
self.app.start_db(ds_version=ds_version)
|
||||
except Exception as e:
|
||||
LOG.error("Failed to restore database service after rebuild, "
|
||||
"error: %s", e)
|
||||
self.prepare_error = True
|
||||
raise
|
||||
finally:
|
||||
self.status.end_install(error_occurred=self.prepare_error)
|
||||
|
||||
def pre_create_backup(self, context, **kwargs):
|
||||
LOG.info("Running pre_create_backup")
|
||||
status = {}
|
||||
try:
|
||||
self.adm.database_sync()
|
||||
mount_point = CONF.get(CONF.datastore_manager).mount_point
|
||||
# Sync Disk
|
||||
operating_system.sync(mount_point)
|
||||
# Freeze FS
|
||||
operating_system.fsfreeze(mount_point)
|
||||
except Exception as e:
|
||||
LOG.error("Run pre_create_backup failed, error: %s", e)
|
||||
raise exception.BackupCreationError(str(e))
|
||||
|
||||
return status
|
||||
|
||||
def _get_ssl_files(self):
|
||||
return {
|
||||
"private_key": f"{self.app.datadir}/server.key",
|
||||
"certificate": f"{self.app.datadir}/server.crt",
|
||||
"ca": f"{self.app.datadir}/ca.crt"
|
||||
}
|
||||
|
||||
def _enable_ssl_certificate_impl(self, mode, apply_overrides=True):
|
||||
LOG.debug("Enable SSL mode: %s", mode)
|
||||
|
||||
overrides = {
|
||||
"tls-ca-cert-file": "ca.crt",
|
||||
"tls-cert-file": "server.crt",
|
||||
"tls-key-file": "server.key"
|
||||
}
|
||||
if self.ssl_mode_at_least(mode, ssl.MODE_MTLS):
|
||||
overrides["port"] = 0
|
||||
overrides["tls-port"] = 6379
|
||||
overrides["tls-auth-clients"] = "yes"
|
||||
overrides["tls-replication"] = "yes"
|
||||
elif self.ssl_mode_at_least(mode, ssl.MODE_ENFORCED):
|
||||
overrides["port"] = 0
|
||||
overrides["tls-port"] = 6379
|
||||
overrides["tls-auth-clients"] = "no"
|
||||
overrides["tls-replication"] = "yes"
|
||||
elif self.ssl_mode_at_least(mode, ssl.MODE_BASIC):
|
||||
overrides["port"] = 6379
|
||||
overrides["tls-port"] = 6380
|
||||
overrides["tls-auth-clients"] = "no"
|
||||
|
||||
if apply_overrides:
|
||||
self.app.update_overrides(overrides)
|
||||
return True
|
||||
|
||||
def _disable_ssl_certificate_impl(self, apply_overrides=True):
|
||||
LOG.debug("Disable SSL")
|
||||
|
||||
overrides = {
|
||||
"port": 6379,
|
||||
"tls-port": 0,
|
||||
"tls-auth-clients": "no"
|
||||
}
|
||||
|
||||
if apply_overrides:
|
||||
self.app.update_overrides(overrides)
|
||||
return True
|
||||
|
||||
def show_ssl_status(self):
|
||||
tls_port = self.configuration_manager.get_value("tls-port")
|
||||
if tls_port and tls_port[0] and tls_port[0][0] > 0:
|
||||
certificate = operating_system.read_file(
|
||||
f"{self.app.datadir}/server.crt", as_root=True)
|
||||
return {"certificate": certificate, "status": "on"}
|
||||
else:
|
||||
return {"status": "off"}
|
||||
@@ -0,0 +1,703 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import docker
|
||||
import os
|
||||
from oslo_log import log as logging
|
||||
from valkey.exceptions import ConnectionError
|
||||
from valkey import Valkey
|
||||
from trove.common import cfg, constants, exception, stream_codecs, utils
|
||||
from trove.common.db.redis_common import models
|
||||
from trove.guestagent.common import configuration, guestagent_utils, \
|
||||
operating_system
|
||||
from trove.guestagent.datastore.redis_common import manager
|
||||
from trove.guestagent.datastore import service
|
||||
from trove.guestagent.utils import docker as docker_util
|
||||
from trove.instance import service_status
|
||||
from typing import Union, List
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
CNF_EXT = 'conf'
|
||||
|
||||
|
||||
class RedisApp(service.BaseDbApp):
|
||||
DATASTORE_NAME = 'redis'
|
||||
CLI_BINARY = 'redis-cli'
|
||||
CONFIG_FILE = '/etc/redis/redis.conf'
|
||||
CNF_INCLUDE_DIR = '/etc/redis/conf.d'
|
||||
SOCKET_PATH = '/var/lib/redis-socket'
|
||||
CONTAINER_SOCKET = '/var/run/redis/redis.sock'
|
||||
# ACL file should persist after rebuilds.
|
||||
# Store it in the data config directory.
|
||||
ACL_FILE = '/var/lib/redis/conf.d/users.acl'
|
||||
SERVER_BINARY = 'redis-server'
|
||||
DATA_ENV_NAME = 'REDIS_DATA'
|
||||
_configuration_manager = None
|
||||
|
||||
HEALTHCHECK = {
|
||||
"test": [
|
||||
"CMD-SHELL",
|
||||
f"redis-cli -s {CONTAINER_SOCKET} ping | grep -qx PONG"],
|
||||
"start_period": 10 * 1000000000, # 10 seconds in nanoseconds
|
||||
"interval": 10 * 1000000000,
|
||||
"timeout": 5 * 1000000000,
|
||||
"retries": 3
|
||||
}
|
||||
|
||||
@property
|
||||
def configuration_manager(self):
|
||||
if self._configuration_manager:
|
||||
return self._configuration_manager
|
||||
|
||||
config_manager = configuration.ConfigurationManager
|
||||
config_value_mappings = {'yes': True, 'no': False, "''": None}
|
||||
self._value_converter = stream_codecs.StringConverter(
|
||||
config_value_mappings)
|
||||
self._configuration_manager = config_manager(
|
||||
self.CONFIG_FILE,
|
||||
self.database_service_uid,
|
||||
self.database_service_gid,
|
||||
stream_codecs.PropertiesCodec(
|
||||
unpack_singletons=False,
|
||||
string_mappings=config_value_mappings),
|
||||
requires_root=True,
|
||||
override_strategy=configuration.IndexOverrideStrategy(
|
||||
self.CNF_INCLUDE_DIR, CNF_EXT),
|
||||
)
|
||||
return self._configuration_manager
|
||||
|
||||
def __init__(self, status, docker_client):
|
||||
super(RedisApp, self).__init__(status, docker_client)
|
||||
|
||||
mount_point = cfg.get_configuration_property('mount_point')
|
||||
self.datadir = mount_point
|
||||
self.adm = self.build_admin_client()
|
||||
|
||||
def set_password(self, password=None):
|
||||
if password is None:
|
||||
password = utils.generate_random_password()
|
||||
self.save_password('root', password)
|
||||
return password
|
||||
|
||||
@classmethod
|
||||
def get_password(cls):
|
||||
try:
|
||||
return cls.get_auth_password(file="default.cnf")
|
||||
except (exception.UnprocessableEntity, KeyError):
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def get_osadmin_password(cls):
|
||||
try:
|
||||
return cls.get_auth_password(file="osadmin.cnf")
|
||||
except (exception.UnprocessableEntity, KeyError) as e:
|
||||
LOG.info("creating new osadmin password: %s", e)
|
||||
return cls.create_osadmin_password()
|
||||
|
||||
@classmethod
|
||||
def create_osadmin_password(cls, password=None):
|
||||
if password is None:
|
||||
password = utils.generate_random_password()
|
||||
cls.save_password('osadmin', password)
|
||||
return password
|
||||
|
||||
# Returns replication password
|
||||
def get_masterauth(self):
|
||||
try:
|
||||
return self.get_auth_password(file="masterauth.cnf")
|
||||
except exception.UnprocessableEntity:
|
||||
return self.set_masterauth(None)
|
||||
|
||||
def reload(self):
|
||||
docker_util.restart_container(self.docker_client)
|
||||
|
||||
def update_overrides(self, overrides):
|
||||
"""Update config options in the include directory."""
|
||||
if overrides:
|
||||
self.configuration_manager.apply_user_override(overrides)
|
||||
|
||||
def apply_overrides(self, overrides):
|
||||
"""Reload config."""
|
||||
docker_util.restart_container(self.docker_client)
|
||||
|
||||
def get_port(self):
|
||||
try:
|
||||
port = self.get_configuration_property('port')
|
||||
except Exception:
|
||||
port = 6379
|
||||
return port
|
||||
|
||||
def build_admin_client(self):
|
||||
socket = f"{self.SOCKET_PATH}/{self.DATASTORE_NAME}.sock"
|
||||
password = self.get_osadmin_password()
|
||||
LOG.info('Create build_admin_client %s', socket)
|
||||
return RedisAdmin(
|
||||
unix_socket_path=socket,
|
||||
username=manager.OSADMIN_USER,
|
||||
password=password)
|
||||
|
||||
def get_configuration_property(self, name, default=None):
|
||||
"""Return the value of a Redis configuration property.
|
||||
Returns a single value for single-argument properties or
|
||||
a list otherwise.
|
||||
"""
|
||||
return utils.unpack_singleton(
|
||||
self.configuration_manager.get_value(name, default))
|
||||
|
||||
def get_config_command_name(self):
|
||||
"""Get current name of the 'CONFIG' command.
|
||||
"""
|
||||
renamed_cmds = self.configuration_manager.get_value('rename-command')
|
||||
if renamed_cmds:
|
||||
for name_pair in renamed_cmds:
|
||||
if name_pair[0] == 'CONFIG':
|
||||
return name_pair[1]
|
||||
|
||||
return None
|
||||
|
||||
def start_db(self, update_db=False, ds_version=None, command=None,
|
||||
extra_volumes=None, memory_mb=None):
|
||||
"""Start and wait for database service."""
|
||||
docker_image = CONF.get(CONF.datastore_manager).docker_image
|
||||
image = (f'{docker_image}:latest' if not ds_version else
|
||||
f'{docker_image}:{ds_version}')
|
||||
|
||||
if not command:
|
||||
command = f'{self.SERVER_BINARY} {self.CONFIG_FILE}'
|
||||
|
||||
for folder in [f"/etc/{self.DATASTORE_NAME}",
|
||||
self.SOCKET_PATH]:
|
||||
operating_system.ensure_directory(
|
||||
folder, user=self.database_service_uid,
|
||||
group=self.database_service_gid, force=True,
|
||||
as_root=True)
|
||||
|
||||
volumes = {
|
||||
f'/etc/{self.DATASTORE_NAME}': {
|
||||
'bind': f'/etc/{self.DATASTORE_NAME}', 'mode': 'rw'},
|
||||
self.datadir: {'bind': self.datadir, 'mode': 'rw'},
|
||||
self.SOCKET_PATH: {
|
||||
'bind': f'/var/run/{self.DATASTORE_NAME}', 'mode': 'rw'}
|
||||
}
|
||||
|
||||
if extra_volumes:
|
||||
volumes.update(extra_volumes)
|
||||
|
||||
ports = {}
|
||||
cfg_ports = cfg.get_configuration_property('tcp_ports')
|
||||
tcp_ports: List[List[Union[int, str]]] = cfg_ports # type: ignore
|
||||
for port_range in tcp_ports:
|
||||
for port in port_range:
|
||||
ports[f'{port}/tcp'] = port
|
||||
|
||||
if CONF.network_isolation and \
|
||||
os.path.exists(constants.ETH1_CONFIG_PATH):
|
||||
network_mode = constants.DOCKER_HOST_NIC_MODE
|
||||
else:
|
||||
network_mode = constants.DOCKER_BRIDGE_MODE
|
||||
|
||||
user = "%s:%s" % (self.database_service_uid, self.database_service_gid)
|
||||
try:
|
||||
environment = {}
|
||||
environment[self.DATA_ENV_NAME] = self.datadir
|
||||
|
||||
docker_util.start_container(
|
||||
self.docker_client,
|
||||
image,
|
||||
volumes=volumes,
|
||||
network_mode=network_mode,
|
||||
ports=ports,
|
||||
user=user,
|
||||
environment=environment,
|
||||
healthcheck=self.HEALTHCHECK,
|
||||
command=command
|
||||
)
|
||||
except Exception:
|
||||
LOG.exception("Failed to start database service")
|
||||
raise exception.TroveError("Failed to start database service")
|
||||
|
||||
if not self.status.wait_for_status(
|
||||
service_status.ServiceStatuses.HEALTHY,
|
||||
CONF.state_change_wait_time, update_db
|
||||
):
|
||||
raise exception.TroveError("Failed to start database service")
|
||||
|
||||
def restart(self):
|
||||
LOG.info("Restarting database")
|
||||
|
||||
try:
|
||||
docker_util.restart_container(self.docker_client)
|
||||
except Exception:
|
||||
LOG.exception("Failed to restart database")
|
||||
raise exception.TroveError("Failed to restart database")
|
||||
|
||||
if not self.status.wait_for_status(
|
||||
service_status.ServiceStatuses.HEALTHY,
|
||||
CONF.state_change_wait_time, update_db=True
|
||||
):
|
||||
raise exception.TroveError("Failed to start database")
|
||||
|
||||
LOG.info("Finished restarting database")
|
||||
|
||||
def restore_backup(self, context, backup_info, restore_location):
|
||||
backup_id = backup_info['id']
|
||||
storage_driver = CONF.storage_strategy
|
||||
backup_driver = self.get_backup_strategy()
|
||||
user_token = context.auth_token
|
||||
swift_url = backup_info.get('swift_url')
|
||||
if not swift_url:
|
||||
raise exception.TroveError(
|
||||
"Missing swift_url in backup metadata.")
|
||||
image = self.get_backup_image()
|
||||
name = 'db_restore'
|
||||
volumes = {
|
||||
self.datadir: {
|
||||
'bind': self.datadir,
|
||||
'mode': 'rw'
|
||||
}
|
||||
}
|
||||
|
||||
command = (
|
||||
f'python3 main.py --nobackup '
|
||||
f'--storage-driver={storage_driver} --driver={backup_driver} '
|
||||
f'--os-token={user_token} --swift-url={swift_url} '
|
||||
f'--restore-from={backup_info["location"]} '
|
||||
f'--restore-checksum={backup_info["checksum"]} '
|
||||
)
|
||||
if CONF.swift_api_insecure:
|
||||
command = (f"{command} --swift-api-insecure")
|
||||
if CONF.backup_aes_cbc_key:
|
||||
command = (f"{command} "
|
||||
f"--backup-encryption-key={CONF.backup_aes_cbc_key}")
|
||||
|
||||
LOG.debug('Stop the database and clean up the data before restore '
|
||||
'from %s', backup_id)
|
||||
self.stop_db()
|
||||
operating_system.remove_dir_contents(self.datadir)
|
||||
|
||||
# Start to run restore inside a separate docker container
|
||||
LOG.info('Starting to restore backup %s, command: %s', backup_id,
|
||||
command)
|
||||
output, ret = docker_util.run_container(
|
||||
self.docker_client, image, name,
|
||||
volumes=volumes, command=command)
|
||||
result = output[-1]
|
||||
if not ret:
|
||||
msg = f'Failed to run restore container, error: {result}'
|
||||
LOG.error(msg)
|
||||
raise Exception(msg)
|
||||
|
||||
operating_system.chown(self.datadir, self.database_service_uid,
|
||||
self.database_service_gid, force=True,
|
||||
as_root=True)
|
||||
|
||||
# Use osadmin password from restored backup
|
||||
self.adm.set_osadmin_password(self.get_osadmin_password())
|
||||
|
||||
def enable_aclfile(self):
|
||||
self.configuration_manager.apply_system_override({
|
||||
'aclfile': self.ACL_FILE})
|
||||
|
||||
# Enables replication password (mastearauth conf)
|
||||
def set_masterauth(self, password=None):
|
||||
if password is None:
|
||||
password = utils.generate_random_password()
|
||||
self.save_password('masterauth', password)
|
||||
self.configuration_manager.apply_system_override(
|
||||
{'masterauth': password})
|
||||
self.adm.create_replication_user(
|
||||
models.RedisCommonUser(
|
||||
name=manager.REPLICATION_USER, password=password))
|
||||
return password
|
||||
|
||||
def upgrade(self, upgrade_info):
|
||||
"""Upgrade the database."""
|
||||
new_version = upgrade_info.get('datastore_version')
|
||||
|
||||
LOG.info('Stopping db container for upgrade')
|
||||
self.stop_db()
|
||||
|
||||
LOG.info('Deleting db container for upgrade')
|
||||
docker_util.remove_container(self.docker_client)
|
||||
|
||||
LOG.info('Remove unused images before starting new db container')
|
||||
docker_util.prune_images(self.docker_client)
|
||||
|
||||
LOG.info('Starting new db container with version %s for upgrade',
|
||||
new_version)
|
||||
self.start_db(update_db=True, ds_version=new_version)
|
||||
|
||||
def is_replica(self):
|
||||
try:
|
||||
role = self.adm.connection.info('replication').get('role')
|
||||
return role == 'slave' or role == 'replica'
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def stop_db(self, update_db=False):
|
||||
LOG.info("Stopping database gracefully.")
|
||||
try:
|
||||
container = self.docker_client.containers.get("database")
|
||||
except docker.errors.NotFound:
|
||||
return
|
||||
original_rp = container.attrs["HostConfig"]["RestartPolicy"]
|
||||
try:
|
||||
# Prevent Docker from restarting the container after Redis exits.
|
||||
LOG.debug("Restart policy: %r", original_rp)
|
||||
container.update(
|
||||
restart_policy={"Name": "no", "MaximumRetryCount": 0})
|
||||
|
||||
try:
|
||||
self.adm.connection.shutdown(save=True)
|
||||
except ConnectionError:
|
||||
# Expected: SHUTDOWN closes the client connection because
|
||||
# the Redis server exits.
|
||||
pass
|
||||
|
||||
if not self.status.wait_for_status(
|
||||
service_status.ServiceStatuses.SHUTDOWN,
|
||||
CONF.state_change_wait_time,
|
||||
update_db
|
||||
):
|
||||
raise exception.TroveError("Failed to stop database")
|
||||
|
||||
finally:
|
||||
# Restore the normal policy for future Docker/host restarts.
|
||||
container.update(restart_policy=original_rp)
|
||||
|
||||
os.sync()
|
||||
|
||||
|
||||
class RedisAdmin(object):
|
||||
ROOT_USERNAME = 'root'
|
||||
|
||||
def __init__(self, unix_socket_path=None, username=None, password=None):
|
||||
self._connection = None
|
||||
self._unix_socket_path = unix_socket_path
|
||||
self._username = username
|
||||
self._password = password
|
||||
|
||||
def connect(self):
|
||||
self._connection = Valkey(
|
||||
unix_socket_path=self._unix_socket_path,
|
||||
username=self._username,
|
||||
password=self._password)
|
||||
|
||||
def set_osadmin_password(self, password):
|
||||
self._password = password
|
||||
self.connect()
|
||||
|
||||
@property
|
||||
def connection(self):
|
||||
if not self._connection:
|
||||
self.connect()
|
||||
return self._connection
|
||||
|
||||
def build_root_user(self, password=None):
|
||||
return models.RedisCommonUser.root(
|
||||
name=self.ROOT_USERNAME, password=password)
|
||||
|
||||
def enable_root(self, root_password=None):
|
||||
"""Create a superuser user or reset the superuser password."""
|
||||
root = self.build_root_user(root_password)
|
||||
self.create_root_user(root, reset_passwords=True)
|
||||
|
||||
return root.serialize()
|
||||
|
||||
def disable_root(self):
|
||||
self.connection.acl_setuser(
|
||||
username=self.ROOT_USERNAME,
|
||||
enabled=False,
|
||||
)
|
||||
self.connection.acl_save()
|
||||
|
||||
def is_root_enabled(self):
|
||||
user_acl = self.connection.acl_getuser(self.ROOT_USERNAME)
|
||||
|
||||
if not user_acl:
|
||||
# Root user doesn't exists
|
||||
return False
|
||||
|
||||
flags = user_acl.get("flags", [])
|
||||
|
||||
if isinstance(flags, str):
|
||||
flags = flags.split()
|
||||
|
||||
# Check that root user is enabled
|
||||
return "on" in flags
|
||||
|
||||
def _validate_categories(self, requested_categories):
|
||||
requested_categories = set(requested_categories)
|
||||
available_categories = set(self.connection.acl_cat() + ['all'])
|
||||
|
||||
valid_categories = requested_categories & available_categories
|
||||
invalid_categories = requested_categories - available_categories
|
||||
|
||||
if invalid_categories:
|
||||
raise exception.TroveError(
|
||||
"ACL category doesn't exists: %s\n"
|
||||
"Available categories: %s" %
|
||||
(
|
||||
", ".join(sorted(invalid_categories)),
|
||||
", ".join(sorted(available_categories))
|
||||
)
|
||||
)
|
||||
|
||||
return valid_categories
|
||||
|
||||
def grant_access(self, username, hostname, databases):
|
||||
# hostname is not applicable to Redis ACLs
|
||||
requested_categories = set(databases)
|
||||
valid_categories = self._validate_categories(requested_categories)
|
||||
LOG.debug(
|
||||
'Grant access, requested_categories = %s, valid categories = %s',
|
||||
requested_categories, valid_categories)
|
||||
|
||||
if valid_categories:
|
||||
self.connection.acl_setuser(
|
||||
username=username,
|
||||
enabled=True,
|
||||
categories=[
|
||||
f"+@{category}"
|
||||
for category in sorted(valid_categories)
|
||||
],
|
||||
)
|
||||
self.connection.acl_save()
|
||||
|
||||
def revoke_access(self, username, hostname, database):
|
||||
# hostname is not applicable to Redis ACLs
|
||||
available_categories = set(self.connection.acl_cat())
|
||||
|
||||
if database not in available_categories:
|
||||
LOG.warning(
|
||||
("ACL category %s is not available, "
|
||||
"skipping revoke for user %s"),
|
||||
database,
|
||||
username,
|
||||
)
|
||||
return
|
||||
self.connection.acl_setuser(
|
||||
username=username,
|
||||
enabled=True,
|
||||
categories=[f"-@{database}"],
|
||||
)
|
||||
self.connection.acl_save()
|
||||
|
||||
def list_access(self, username, hostname):
|
||||
# hostname is not applicable to Redis ACLs
|
||||
access = [
|
||||
{'_name': db[2:], '_collate': '', '_character_set': ''}
|
||||
for db in self._get_user_categories(username)
|
||||
if db.startswith("+@")]
|
||||
return access
|
||||
|
||||
def create_databases(self, *args, **kwargs):
|
||||
raise exception.TroveError("Creating databases is not supported")
|
||||
|
||||
def create_database(self, *args, **kwargs):
|
||||
raise exception.TroveError("Creating database is not supported")
|
||||
|
||||
def delete_database(self, database):
|
||||
raise exception.TroveError("Deleting database is not supported")
|
||||
|
||||
def list_databases(self, limit=None, marker=None, include_marker=False):
|
||||
dbs = [
|
||||
models.RedisCommonSchema(name=db)
|
||||
for db in self.connection.acl_cat()
|
||||
]
|
||||
return guestagent_utils.serialize_list(
|
||||
dbs,
|
||||
limit=limit, marker=marker, include_marker=include_marker)
|
||||
|
||||
def create_users(self, users):
|
||||
for user in users:
|
||||
self.create_non_root_user(
|
||||
models.RedisCommonUser.deserialize(user, False)
|
||||
)
|
||||
|
||||
def create_user(self, user, enabled=True, **kwargs):
|
||||
LOG.info(f"Create user {user.name}")
|
||||
if not user.password:
|
||||
kwargs["nopass"] = True
|
||||
else:
|
||||
kwargs["passwords"] = [f"+{user.password}"]
|
||||
if "categories" in kwargs:
|
||||
kwargs["categories"] = kwargs["categories"]
|
||||
if user.databases:
|
||||
requested_categories = [db["_name"] for db in user.databases]
|
||||
valid_categories = self._validate_categories(requested_categories)
|
||||
LOG.debug(
|
||||
'Grant access on creation, requested_categories = %s',
|
||||
requested_categories)
|
||||
|
||||
categories = [f"+@{db}" for db in valid_categories]
|
||||
if categories:
|
||||
if "categories" not in kwargs:
|
||||
kwargs["categories"] = []
|
||||
kwargs["categories"].extend(categories)
|
||||
# Remove duplicates
|
||||
kwargs["categories"] = list(
|
||||
dict.fromkeys(kwargs["categories"]))
|
||||
|
||||
self.connection.acl_setuser(user.name,
|
||||
enabled=enabled, **kwargs)
|
||||
self.connection.acl_save()
|
||||
|
||||
def create_root_user(self, user, **kwargs):
|
||||
self.create_user(user, categories=["+@all"], channels=["*"],
|
||||
keys=["~*"], **kwargs)
|
||||
|
||||
def create_replication_user(self, user, **kwargs):
|
||||
self.create_user(user, commands=["+psync", "+replconf", "+ping"],
|
||||
channels=["*"], keys=["~*"], **kwargs)
|
||||
|
||||
def create_non_root_user(self, user, **kwargs):
|
||||
if user.name in self.ignore_users:
|
||||
raise exception.TroveError("%s username is reserved" % user.name)
|
||||
|
||||
self.create_user(
|
||||
user,
|
||||
categories=CONF.get(CONF.datastore_manager).user_acl_categories,
|
||||
keys=["~*"], channels=["*"], **kwargs)
|
||||
|
||||
def list_users(self, limit=None, marker=None, include_marker=False):
|
||||
"""List all users on the instance along with their access permissions.
|
||||
Return a paginated list of serialized Redis users.
|
||||
"""
|
||||
return guestagent_utils.serialize_list(
|
||||
self._get_users(),
|
||||
limit=limit, marker=marker, include_marker=include_marker)
|
||||
|
||||
def _get_users(self):
|
||||
"""Return all non-system Redis users on the instance."""
|
||||
results = self.connection.acl_list()
|
||||
|
||||
names = {acl_info.split(" ")[1] for acl_info in results}
|
||||
return [
|
||||
self._build_user(name, show_full_acl=True)
|
||||
for name in sorted(names)
|
||||
if name not in self.ignore_users
|
||||
]
|
||||
|
||||
def _build_user(self, username, show_full_acl=False):
|
||||
"""Build a model representation of a Redis user."""
|
||||
if username == self.ROOT_USERNAME:
|
||||
return self.build_root_user()
|
||||
if show_full_acl:
|
||||
databases = self._get_user_categories(username)
|
||||
else:
|
||||
databases = [
|
||||
db[2:]
|
||||
for db in self._get_user_categories(username)
|
||||
if db[:1] != '-'
|
||||
]
|
||||
return models.RedisCommonUser(username, databases=databases)
|
||||
|
||||
def delete_user(self, user):
|
||||
"""Delete the specified user."""
|
||||
if not isinstance(user, models.RedisCommonUser):
|
||||
user = models.RedisCommonUser.deserialize(user, False)
|
||||
user.check_delete()
|
||||
if user.name:
|
||||
self.connection.acl_deluser(user.name)
|
||||
self.connection.acl_save()
|
||||
|
||||
def get_user(self, username, hostname):
|
||||
"""Return a serialized representation of a user with a given name."""
|
||||
user = self._find_user(username)
|
||||
return user.serialize() if user is not None else None
|
||||
|
||||
def _find_user(self, username):
|
||||
"""Lookup a user with a given username.
|
||||
|
||||
Return a new Redis user instance or None if no match is found.
|
||||
"""
|
||||
for acl_info in self.connection.acl_list(): # type: ignore
|
||||
name = acl_info.split(" ")[1]
|
||||
if name == username:
|
||||
return self._build_user(username)
|
||||
return None
|
||||
|
||||
# Return ACL categories as databases
|
||||
def _get_user_categories(self, username):
|
||||
user_acl = self.connection.acl_getuser(username)
|
||||
if not user_acl or 'categories' not in user_acl:
|
||||
return []
|
||||
|
||||
return user_acl["categories"]
|
||||
|
||||
def user_exists(self, username):
|
||||
"""Return whether a given user exists on the instance."""
|
||||
results = self._find_user(username)
|
||||
|
||||
return bool(results)
|
||||
|
||||
def update_attributes(self, username, hostname, user_attrs):
|
||||
"""Change the attributes of an existing user."""
|
||||
LOG.debug("Changing user attributes for user %s.", username)
|
||||
|
||||
user = self._find_user(username)
|
||||
if not user:
|
||||
return
|
||||
|
||||
is_changed = False
|
||||
|
||||
new_password = user_attrs.get('password')
|
||||
if new_password:
|
||||
LOG.debug("Password changed for user %s.", username)
|
||||
user.password = new_password
|
||||
is_changed = True
|
||||
|
||||
if 'name' in user_attrs and user_attrs['name'] != username:
|
||||
new_name = user_attrs.get('name')
|
||||
if new_name in self.ignore_users:
|
||||
raise exception.TroveError(
|
||||
"%s username is reserved" % new_name)
|
||||
LOG.debug(
|
||||
"Name changed for user %s, new name: %s.", username, new_name)
|
||||
self.delete_user(user)
|
||||
user.name = new_name
|
||||
is_changed = True
|
||||
|
||||
if is_changed:
|
||||
self.create_non_root_user(user, reset_passwords=True)
|
||||
|
||||
def change_passwords(self, users):
|
||||
"""Change the passwords of one or more existing users.
|
||||
|
||||
The users parameter is a list of serialized Redis users.
|
||||
"""
|
||||
for user in users:
|
||||
user_dict = {
|
||||
'_name': user['name'],
|
||||
'_host': user['host'],
|
||||
'_password': user['password']}
|
||||
self.create_non_root_user(
|
||||
models.RedisCommonUser.deserialize(user_dict, False),
|
||||
reset_passwords=True)
|
||||
|
||||
def set_masterauth(self, password):
|
||||
self.connection.config_set("masterauth", password)
|
||||
|
||||
def database_sync(self):
|
||||
self.connection.save()
|
||||
|
||||
@property
|
||||
def ignore_users(self):
|
||||
return cfg.get_ignored_users()
|
||||
|
||||
@property
|
||||
def ignore_dbs(self):
|
||||
return []
|
||||
Whitespace-only changes.
@@ -0,0 +1,21 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from trove.guestagent.datastore.redis_common.manager import RedisManager
|
||||
from trove.guestagent.datastore.valkey import service
|
||||
|
||||
|
||||
class Manager(RedisManager):
|
||||
DATASTORE_NAME = 'valkey'
|
||||
APP_CLASS = service.ValkeyApp
|
||||
@@ -0,0 +1,37 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from trove.guestagent.datastore.redis_common import service
|
||||
|
||||
|
||||
class ValkeyApp(service.RedisApp):
|
||||
DATASTORE_NAME = 'valkey'
|
||||
CLI_BINARY = 'valkey-cli'
|
||||
CONFIG_FILE = "/etc/valkey/valkey.conf"
|
||||
CNF_INCLUDE_DIR = '/etc/valkey/conf.d'
|
||||
SOCKET_PATH = '/var/lib/valkey-socket'
|
||||
CONTAINER_SOCKET = '/var/run/valkey/valkey.sock'
|
||||
ACL_FILE = '/var/lib/valkey/conf.d/users.acl'
|
||||
SERVER_BINARY = 'valkey-server'
|
||||
DATA_ENV_NAME = 'VALKEY_DATA'
|
||||
|
||||
HEALTHCHECK = {
|
||||
"test": [
|
||||
"CMD-SHELL",
|
||||
f"valkey-cli -s {CONTAINER_SOCKET} ping | grep -qx PONG"],
|
||||
"start_period": 10 * 1000000000, # 10 seconds in nanoseconds
|
||||
"interval": 10 * 1000000000,
|
||||
"timeout": 5 * 1000000000,
|
||||
"retries": 3
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from trove.guestagent.strategies.replication import redis_base
|
||||
|
||||
|
||||
class KeyDBSyncReplication(redis_base.RedisReplicationBase):
|
||||
DATASTORE_NAME = 'keydb'
|
||||
@@ -0,0 +1,145 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import netutils
|
||||
|
||||
from trove.common import cfg
|
||||
from trove.common import constants
|
||||
from trove.guestagent.datastore.redis_common import manager
|
||||
from trove.guestagent.strategies.replication import base
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class RedisReplicationBase(base.Replication):
|
||||
DATASTORE_NAME = 'redis'
|
||||
|
||||
def _get_default_user_credentials(self, service):
|
||||
default_user_info = {
|
||||
'name': manager.REPLICATION_USER,
|
||||
'password': service.get_masterauth()
|
||||
}
|
||||
|
||||
return default_user_info
|
||||
|
||||
def enable_as_master(self, service, master_config):
|
||||
self._get_default_user_credentials(service)
|
||||
|
||||
def snapshot_for_replication(self, context, service, adm, location,
|
||||
snapshot_info):
|
||||
LOG.info("Creating snapshot for replication")
|
||||
|
||||
volumes_mapping = {
|
||||
f'/var/lib/{self.DATASTORE_NAME}': {
|
||||
'bind': f'/var/lib/{self.DATASTORE_NAME}', 'mode': 'rw'
|
||||
}
|
||||
}
|
||||
if snapshot_info.get('storage_driver') not in ["cinder"]:
|
||||
service.create_backup(context, snapshot_info,
|
||||
volumes_mapping=volumes_mapping,
|
||||
need_dbuser=False)
|
||||
|
||||
replication_user = self._get_default_user_credentials(service)
|
||||
|
||||
replica_conf = {
|
||||
'replication_user': replication_user
|
||||
}
|
||||
|
||||
return snapshot_info['id'], replica_conf
|
||||
|
||||
def get_master_ref(self, service, snapshot_info):
|
||||
ip_address = None
|
||||
if CONF.network_isolation and \
|
||||
os.path.exists(constants.ETH1_CONFIG_PATH):
|
||||
# Get IP_address from eth1.json, ipv4 address was preferred.
|
||||
with open(constants.ETH1_CONFIG_PATH) as fd:
|
||||
eth1_config = json.load(fd)
|
||||
ip_address = eth1_config.get("ipv4_address", None) or \
|
||||
eth1_config.get("ipv6_address", None)
|
||||
if not ip_address:
|
||||
ip_address = netutils.get_my_ipv4()
|
||||
master_ref = {
|
||||
'host': ip_address,
|
||||
'port': cfg.get_configuration_property('tcp_ports')[0]
|
||||
}
|
||||
return master_ref
|
||||
|
||||
def enable_as_slave(self, service, snapshot, slave_config):
|
||||
LOG.debug("enable_as_slave")
|
||||
|
||||
"""Set up the replica server."""
|
||||
host = snapshot['master']['host']
|
||||
port = snapshot['master']['port'][0]
|
||||
password = snapshot['replica_conf']['replication_user']['password']
|
||||
name = snapshot['replica_conf']['replication_user']['name']
|
||||
conf = {
|
||||
'replicaof': [host, port],
|
||||
'masterauth': password,
|
||||
'masteruser': name,
|
||||
}
|
||||
service.configuration_manager.apply_system_override(conf)
|
||||
LOG.debug("replicaof is set in the config file: %s:%s",
|
||||
snapshot['master']['host'],
|
||||
snapshot['master']['port'])
|
||||
|
||||
if service.status.is_running:
|
||||
service.adm.connection.config_set(
|
||||
"masteruser",
|
||||
snapshot['replica_conf']['replication_user']['name'])
|
||||
service.adm.connection.config_set(
|
||||
"masterauth",
|
||||
snapshot['replica_conf']['replication_user']['password'])
|
||||
service.adm.connection.slaveof(
|
||||
host=snapshot['master']['host'],
|
||||
port=snapshot['master']['port'][0])
|
||||
|
||||
def detach_slave(self, service, for_failover):
|
||||
LOG.debug('detach_slave')
|
||||
service.adm.connection.slaveof(host=None, port=None)
|
||||
conf = {
|
||||
'replicaof': ['NO', 'ONE'],
|
||||
'masterauth': None,
|
||||
'masteruser': None,
|
||||
}
|
||||
service.configuration_manager.apply_system_override(conf)
|
||||
|
||||
def get_replica_context(self, service, adm):
|
||||
"""Running on primary."""
|
||||
default_user_info = self._get_default_user_credentials(service)
|
||||
|
||||
return {
|
||||
'master': self.get_master_ref(None, None),
|
||||
'replica_conf': {'replication_user': default_user_info}
|
||||
}
|
||||
|
||||
def cleanup_source_on_replica_detach(self, admin_service, replica_info):
|
||||
# No need to take any action here
|
||||
pass
|
||||
|
||||
def demote_master(self, service):
|
||||
# No need to take any action here
|
||||
pass
|
||||
|
||||
def backup_required_for_replication(self):
|
||||
"""
|
||||
Indicates whether a backup is required for replication.
|
||||
Redis master will pass conf.d, ACL and SSL certificates to replicas
|
||||
within the volume backup data.
|
||||
"""
|
||||
return True
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from trove.guestagent.strategies.replication import redis_base
|
||||
|
||||
|
||||
class ValKeySyncReplication(redis_base.RedisReplicationBase):
|
||||
DATASTORE_NAME = 'valkey'
|
||||
@@ -0,0 +1,9 @@
|
||||
port 6379
|
||||
protected-mode no
|
||||
unixsocket /var/run/keydb/keydb.sock
|
||||
unixsocketperm 777
|
||||
dir /var/lib/keydb
|
||||
|
||||
{% set server_threads = (1 if flavor['vcpus'] < 2 else flavor['vcpus'] - 1) %}
|
||||
server-threads {{ server_threads|int }}
|
||||
include /etc/keydb/conf.d/index.conf
|
||||
@@ -0,0 +1 @@
|
||||
slave-read-only yes
|
||||
@@ -0,0 +1,2 @@
|
||||
repl-diskless-sync yes
|
||||
repl-diskless-sync-delay 10
|
||||
@@ -0,0 +1,299 @@
|
||||
{
|
||||
"configuration-parameters": [
|
||||
{
|
||||
"name": "tcp-backlog",
|
||||
"restart_required": true,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "timeout",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "tcp-keepalive",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "loglevel",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "databases",
|
||||
"restart_required": true,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "save",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "stop-writes-on-bgsave-error",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "rdbcompression",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "rdbchecksum",
|
||||
"restart_required": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "slave-serve-stale-data",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "slave-read-only",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "repl-diskless-sync",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "repl-diskless-sync-delay",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "repl-ping-slave-period",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "repl-timeout",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "repl-disable-tcp-nodelay",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "repl-backlog-size",
|
||||
"restart_required": false,
|
||||
"min": 16384,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "repl-backlog-ttl",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "slave-priority",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "min-slaves-to-write",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "min-slaves-max-lag",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "requirepass",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "maxclients",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "maxmemory",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "maxmemory-policy",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "maxmemory-samples",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "appendonly",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "appendfsync",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "no-appendfsync-on-rewrite",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "auto-aof-rewrite-percentage",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "auto-aof-rewrite-min-size",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "aof-load-truncated",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "lua-time-limit",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "cluster-node-timeout",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "cluster-slave-validity-factor",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "cluster-migration-barrier",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "cluster-require-full-coverage",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "slowlog-log-slower-than",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "slowlog-max-len",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "latency-monitor-threshold",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "notify-keyspace-events",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "hash-max-ziplist-entries",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "hash-max-ziplist-value",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "list-max-ziplist-entries",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "list-max-ziplist-value",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "set-max-intset-entries",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "zset-max-ziplist-entries",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "zset-max-ziplist-value",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "hll-sparse-max-bytes",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"max": 16000,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "activerehashing",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "hz",
|
||||
"restart_required": false,
|
||||
"min": 1,
|
||||
"max": 500,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "aof-rewrite-incremental-fsync",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
port 6379
|
||||
protected-mode no
|
||||
unixsocket /var/run/valkey/valkey.sock
|
||||
unixsocketperm 777
|
||||
dir /var/lib/valkey
|
||||
|
||||
include /etc/valkey/conf.d/index.conf
|
||||
@@ -0,0 +1 @@
|
||||
slave-read-only yes
|
||||
@@ -0,0 +1,2 @@
|
||||
repl-diskless-sync yes
|
||||
repl-diskless-sync-delay 10
|
||||
@@ -0,0 +1,299 @@
|
||||
{
|
||||
"configuration-parameters": [
|
||||
{
|
||||
"name": "tcp-backlog",
|
||||
"restart_required": true,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "timeout",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "tcp-keepalive",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "loglevel",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "databases",
|
||||
"restart_required": true,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "save",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "stop-writes-on-bgsave-error",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "rdbcompression",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "rdbchecksum",
|
||||
"restart_required": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "slave-serve-stale-data",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "slave-read-only",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "repl-diskless-sync",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "repl-diskless-sync-delay",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "repl-ping-slave-period",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "repl-timeout",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "repl-disable-tcp-nodelay",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "repl-backlog-size",
|
||||
"restart_required": false,
|
||||
"min": 16384,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "repl-backlog-ttl",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "slave-priority",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "min-slaves-to-write",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "min-slaves-max-lag",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "requirepass",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "maxclients",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "maxmemory",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "maxmemory-policy",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "maxmemory-samples",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "appendonly",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "appendfsync",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "no-appendfsync-on-rewrite",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "auto-aof-rewrite-percentage",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "auto-aof-rewrite-min-size",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "aof-load-truncated",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "lua-time-limit",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "cluster-node-timeout",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "cluster-slave-validity-factor",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "cluster-migration-barrier",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "cluster-require-full-coverage",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "slowlog-log-slower-than",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "slowlog-max-len",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "latency-monitor-threshold",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "notify-keyspace-events",
|
||||
"restart_required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "hash-max-ziplist-entries",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "hash-max-ziplist-value",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "list-max-ziplist-entries",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "list-max-ziplist-value",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "set-max-intset-entries",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "zset-max-ziplist-entries",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "zset-max-ziplist-value",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "hll-sparse-max-bytes",
|
||||
"restart_required": false,
|
||||
"min": 0,
|
||||
"max": 16000,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "activerehashing",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "hz",
|
||||
"restart_required": false,
|
||||
"min": 1,
|
||||
"max": 500,
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"name": "aof-rewrite-incremental-fsync",
|
||||
"restart_required": false,
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,369 @@
|
||||
# Copyright 2026 PS Cloud Services
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import testtools
|
||||
from trove.guestagent.common.configuration import IndexOverrideStrategy
|
||||
from unittest import mock
|
||||
|
||||
|
||||
class IndexOverrideStrategyTest(testtools.TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.revision_dir = "/etc/test/conf.d"
|
||||
self.revision_ext = "conf"
|
||||
self.index_file = "/etc/test/conf.d/index.conf"
|
||||
|
||||
self.strategy = IndexOverrideStrategy(
|
||||
self.revision_dir,
|
||||
self.revision_ext,
|
||||
)
|
||||
|
||||
self.strategy._owner = "test-user"
|
||||
self.strategy._group = "test-group"
|
||||
self.strategy._codec = mock.Mock()
|
||||
self.strategy._requires_root = False
|
||||
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.chmod")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.chown")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.write_file")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.exists")
|
||||
@mock.patch.object(
|
||||
IndexOverrideStrategy.__bases__[0], "configure")
|
||||
def test_configure_creates_index_file(
|
||||
self, configure, exists, write_file, chown, chmod):
|
||||
|
||||
exists.return_value = False
|
||||
|
||||
self.strategy.configure(
|
||||
"/etc/test/test.conf",
|
||||
"test-user",
|
||||
"test-group",
|
||||
mock.Mock(),
|
||||
False,
|
||||
)
|
||||
|
||||
configure.assert_called_once_with(
|
||||
"/etc/test/test.conf",
|
||||
"test-user",
|
||||
"test-group",
|
||||
mock.ANY,
|
||||
False,
|
||||
)
|
||||
|
||||
exists.assert_called_once_with(
|
||||
self.index_file,
|
||||
as_root=False,
|
||||
)
|
||||
|
||||
write_file.assert_called_once_with(
|
||||
self.index_file,
|
||||
"",
|
||||
as_root=False,
|
||||
)
|
||||
|
||||
chown.assert_called_once_with(
|
||||
self.index_file,
|
||||
"test-user",
|
||||
"test-group",
|
||||
as_root=False,
|
||||
)
|
||||
|
||||
chmod.assert_called_once()
|
||||
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.chmod")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.chown")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.write_file")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.exists")
|
||||
@mock.patch.object(
|
||||
IndexOverrideStrategy.__bases__[0], "configure")
|
||||
def test_configure_does_not_recreate_existing_index(
|
||||
self, configure, exists, write_file, chown, chmod):
|
||||
|
||||
exists.return_value = True
|
||||
|
||||
self.strategy.configure(
|
||||
"/etc/test/test.conf",
|
||||
"test-user",
|
||||
"test-group",
|
||||
mock.Mock(),
|
||||
False,
|
||||
)
|
||||
|
||||
write_file.assert_not_called()
|
||||
chown.assert_not_called()
|
||||
chmod.assert_not_called()
|
||||
|
||||
@mock.patch.object(IndexOverrideStrategy, "_add_to_index")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_get_last_file_index")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_find_revision_file")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_initialize_import_directory")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.chmod")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.chown")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.write_file")
|
||||
def test_apply_creates_revision_and_adds_to_index(
|
||||
self, write_file, chown, chmod, initialize,
|
||||
find_revision_file, get_last_file_index, add_to_index):
|
||||
|
||||
find_revision_file.return_value = None
|
||||
get_last_file_index.return_value = 0
|
||||
|
||||
options = {"foo": "bar"}
|
||||
|
||||
revision_file = ("/etc/test/conf.d/group-001-change-id.conf")
|
||||
|
||||
self.strategy.apply("group", "change-id", options)
|
||||
initialize.assert_called_once_with()
|
||||
get_last_file_index.assert_called_once_with("group")
|
||||
|
||||
write_file.assert_called_once_with(
|
||||
revision_file,
|
||||
options,
|
||||
codec=self.strategy._codec,
|
||||
as_root=False,
|
||||
)
|
||||
|
||||
chown.assert_called_once_with(
|
||||
revision_file,
|
||||
"test-user",
|
||||
"test-group",
|
||||
as_root=False,
|
||||
)
|
||||
|
||||
chmod.assert_called_once()
|
||||
|
||||
add_to_index.assert_called_once_with(revision_file)
|
||||
|
||||
@mock.patch.object(IndexOverrideStrategy, "_add_to_index")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_find_revision_file")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_initialize_import_directory")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.chmod")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.chown")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.write_file")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.read_file")
|
||||
def test_apply_updates_existing_revision(
|
||||
self, read_file, write_file, chown, chmod, initialize,
|
||||
find_revision_file, add_to_index):
|
||||
|
||||
revision_file = (
|
||||
"/etc/test/conf.d/group-001-change-id.conf"
|
||||
)
|
||||
|
||||
find_revision_file.return_value = revision_file
|
||||
read_file.return_value = {"existing": "value", "remove": "value"}
|
||||
options = {"new": "value", "remove": None}
|
||||
|
||||
self.strategy.apply("group", "change-id", options)
|
||||
|
||||
write_file.assert_called_once_with(
|
||||
revision_file,
|
||||
{
|
||||
"existing": "value",
|
||||
"new": "value",
|
||||
},
|
||||
codec=self.strategy._codec,
|
||||
as_root=False,
|
||||
)
|
||||
|
||||
add_to_index.assert_not_called()
|
||||
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.read_file")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.exists")
|
||||
def test_read_index(self, exists, read_file):
|
||||
|
||||
exists.return_value = True
|
||||
read_file.return_value = (
|
||||
"include /etc/test/conf.d/a.conf\n"
|
||||
"\n"
|
||||
" include /etc/test/conf.d/b.conf \n"
|
||||
)
|
||||
|
||||
result = self.strategy._read_index()
|
||||
|
||||
self.assertEqual([
|
||||
"include /etc/test/conf.d/a.conf",
|
||||
"include /etc/test/conf.d/b.conf",
|
||||
], result)
|
||||
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.read_file")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.exists")
|
||||
def test_read_index_returns_empty_list_when_index_does_not_exist(
|
||||
self, exists, read_file):
|
||||
exists.return_value = False
|
||||
result = self.strategy._read_index()
|
||||
self.assertEqual([], result)
|
||||
read_file.assert_not_called()
|
||||
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.write_file")
|
||||
def test_write_index(self, write_file):
|
||||
self.strategy._write_index([
|
||||
"include /etc/test/conf.d/a.conf",
|
||||
"include /etc/test/conf.d/b.conf",
|
||||
])
|
||||
|
||||
write_file.assert_called_once_with(
|
||||
self.index_file,
|
||||
"include /etc/test/conf.d/a.conf\n"
|
||||
"include /etc/test/conf.d/b.conf\n",
|
||||
as_root=False,
|
||||
)
|
||||
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.write_file")
|
||||
def test_write_empty_index(self, write_file):
|
||||
self.strategy._write_index([])
|
||||
write_file.assert_called_once_with(
|
||||
self.index_file,
|
||||
"",
|
||||
as_root=False,
|
||||
)
|
||||
|
||||
@mock.patch.object(IndexOverrideStrategy, "_write_index")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_read_index")
|
||||
def test_add_to_index(self, read_index, write_index):
|
||||
|
||||
read_index.return_value = [
|
||||
"include /etc/test/conf.d/old.conf",
|
||||
]
|
||||
|
||||
self.strategy._add_to_index(
|
||||
"/etc/test/conf.d/new.conf"
|
||||
)
|
||||
|
||||
write_index.assert_called_once_with([
|
||||
"include /etc/test/conf.d/old.conf",
|
||||
"include /etc/test/conf.d/new.conf",
|
||||
])
|
||||
|
||||
@mock.patch.object(IndexOverrideStrategy, "_write_index")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_read_index")
|
||||
def test_add_to_index_does_not_duplicate_record(
|
||||
self, read_index, write_index):
|
||||
|
||||
record = "include /etc/test/conf.d/file.conf"
|
||||
|
||||
read_index.return_value = [record]
|
||||
|
||||
self.strategy._add_to_index(
|
||||
"/etc/test/conf.d/file.conf"
|
||||
)
|
||||
|
||||
write_index.assert_called_once_with([record])
|
||||
|
||||
@mock.patch.object(IndexOverrideStrategy, "_write_index")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_read_index")
|
||||
def test_remove_from_index(self, read_index, write_index):
|
||||
|
||||
read_index.return_value = [
|
||||
"include /etc/test/conf.d/a.conf",
|
||||
"include /etc/test/conf.d/b.conf",
|
||||
]
|
||||
self.strategy._remove_from_index("/etc/test/conf.d/a.conf")
|
||||
write_index.assert_called_once_with([
|
||||
"include /etc/test/conf.d/b.conf",
|
||||
])
|
||||
|
||||
@mock.patch.object(IndexOverrideStrategy, "_remove_from_index")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_find_revision_file")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.remove")
|
||||
def test_remove_specific_revision(
|
||||
self, remove, find_revision_file, remove_from_index):
|
||||
|
||||
revision_file = (
|
||||
"/etc/test/conf.d/group-001-change-id.conf"
|
||||
)
|
||||
find_revision_file.return_value = revision_file
|
||||
|
||||
self.strategy.remove(
|
||||
"group",
|
||||
"change-id",
|
||||
)
|
||||
|
||||
remove_from_index.assert_called_once_with(
|
||||
revision_file,
|
||||
)
|
||||
|
||||
remove.assert_called_once_with(
|
||||
revision_file,
|
||||
force=True,
|
||||
as_root=False,
|
||||
)
|
||||
|
||||
@mock.patch.object(IndexOverrideStrategy, "_remove_from_index")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_find_revision_file")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.remove")
|
||||
def test_remove_specific_revision_does_nothing_if_not_found(
|
||||
self, remove, find_revision_file, remove_from_index):
|
||||
|
||||
find_revision_file.return_value = None
|
||||
|
||||
self.strategy.remove(
|
||||
"group",
|
||||
"change-id",
|
||||
)
|
||||
|
||||
remove_from_index.assert_not_called()
|
||||
remove.assert_not_called()
|
||||
|
||||
@mock.patch.object(IndexOverrideStrategy, "_remove_from_index")
|
||||
@mock.patch.object(IndexOverrideStrategy, "_collect_revision_files")
|
||||
@mock.patch(
|
||||
"trove.guestagent.common.configuration.operating_system.remove")
|
||||
def test_remove_all_group_revisions(
|
||||
self, remove, collect_revision_files, remove_from_index):
|
||||
|
||||
revision_files = [
|
||||
"/etc/test/conf.d/group-001-first.conf",
|
||||
"/etc/test/conf.d/group-002-second.conf",
|
||||
]
|
||||
collect_revision_files.return_value = revision_files
|
||||
|
||||
self.strategy.remove("group")
|
||||
self.assertEqual(
|
||||
2,
|
||||
remove_from_index.call_count,
|
||||
)
|
||||
self.assertEqual(
|
||||
2,
|
||||
remove.call_count,
|
||||
)
|
||||
for path in revision_files:
|
||||
remove_from_index.assert_any_call(path)
|
||||
remove.assert_any_call(
|
||||
path,
|
||||
force=True,
|
||||
as_root=False,
|
||||
)
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,102 @@
|
||||
# keydb jobs
|
||||
- job:
|
||||
name: trove-tempest-ubuntu-base-keydb
|
||||
parent: trove-tempest-ubuntu-base
|
||||
irrelevant-files: !inherit
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres|mariadb|valkey)/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: keydb
|
||||
TROVE_DATASTORE_VERSION: 6.3.3
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
enabled_datastores: "keydb"
|
||||
default_datastore_versions: keydb:6.3.3
|
||||
|
||||
- job:
|
||||
name: trove-tempest-ubuntu-backup-keydb
|
||||
parent: trove-tempest-ubuntu-backup
|
||||
irrelevant-files: !inherit
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres|mariadb|valkey)/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: keydb
|
||||
TROVE_DATASTORE_VERSION: 6.3.3
|
||||
TROVE_STATE_CHANGE_WAIT_TIME: 900
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
backup_wait_timeout: 1200
|
||||
default_datastore_versions: keydb:6.3.3
|
||||
|
||||
- job:
|
||||
name: trove-tempest-ubuntu-replication-keydb
|
||||
parent: trove-tempest-ubuntu-replication
|
||||
irrelevant-files: !inherit
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres|mariadb|valkey)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mysql.*|mariadb.*|valkey.*)\.py$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: keydb
|
||||
TROVE_DATASTORE_VERSION: 6.3.3
|
||||
TROVE_STATE_CHANGE_WAIT_TIME: 900
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
backup_wait_timeout: 1200
|
||||
default_datastore_versions: keydb:6.3.3
|
||||
|
||||
- job:
|
||||
name: trove-tempest-cinder-storage-driver-keydb
|
||||
parent: trove-tempest-snapshot
|
||||
irrelevant-files: !inherit
|
||||
- ^trove/guestagent/datastore/(postgres|mariadb|mysql|valkey)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mysql.*|mariadb.*|valkey.*)\.py$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: keydb
|
||||
TROVE_DATASTORE_VERSION: 6.3.3
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
backup_wait_timeout: 1200
|
||||
default_datastore_versions: keydb:6.3.3
|
||||
|
||||
- job:
|
||||
name: trove-tempest-ubuntu-ssl-keydb
|
||||
parent: trove-tempest-ubuntu-ssl-base
|
||||
files: !inherit
|
||||
- ^trove/guestagent/.*keydb.*\.py$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: keydb
|
||||
TROVE_DATASTORE_VERSION: 6.3.3
|
||||
TROVE_STATE_CHANGE_WAIT_TIME: 900
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
backup_wait_timeout: 1200
|
||||
default_datastore_versions: keydb:6.3.3
|
||||
|
||||
- job:
|
||||
name: trove-tempest-ubuntu-ssl-replication-keydb
|
||||
parent: trove-tempest-ubuntu-ssl-replication
|
||||
files: !inherit
|
||||
- ^trove/guestagent/.*keydb.*\.py$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: keydb
|
||||
TROVE_DATASTORE_VERSION: 6.3.3
|
||||
TROVE_STATE_CHANGE_WAIT_TIME: 900
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
backup_wait_timeout: 1200
|
||||
default_datastore_versions: keydb:6.3.3
|
||||
@@ -15,7 +15,7 @@
|
||||
- ^backup/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/strategies/replication/
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres)/.*$
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres|valkey|keydb)/.*$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
@@ -43,7 +43,7 @@
|
||||
- ^contrib/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/strategies/replication/
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres)/.*$
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres|valkey|keydb)/.*$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
@@ -71,8 +71,8 @@
|
||||
- ^contrib/
|
||||
- ^backup/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mysql.*)\.py$
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres|valkey|keydb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mysql.*|valkey.*|keydb.*)\.py$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
@@ -100,8 +100,8 @@
|
||||
- ^contrib/
|
||||
- ^backup/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/datastore/(postgres|mysql)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mysql.*)\.py$
|
||||
- ^trove/guestagent/datastore/(postgres|mysql|valkey|keydb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mysql.*|valkey.*|keydb.*)\.py$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
- ^backup/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/strategies/replication/
|
||||
- ^trove/guestagent/datastore/(postgres|mariadb)/.*$
|
||||
- ^trove/guestagent/datastore/(postgres|mariadb|valkey|keydb)/.*$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
@@ -43,7 +43,7 @@
|
||||
- ^contrib/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/strategies/replication/
|
||||
- ^trove/guestagent/datastore/(postgres|mariadb)/.*$
|
||||
- ^trove/guestagent/datastore/(postgres|mariadb|valkey|keydb)/.*$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
@@ -72,8 +72,8 @@
|
||||
- ^contrib/
|
||||
- ^backup/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/datastore/(postgres|mariadb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mariadb.*)\.py$
|
||||
- ^trove/guestagent/datastore/(postgres|mariadb|valkey|keydb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mariadb.*|valkey.*|keydb.*)\.py$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
@@ -102,8 +102,8 @@
|
||||
- ^contrib/
|
||||
- ^backup/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/datastore/(postgres|mariadb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mariadb.*)\.py$
|
||||
- ^trove/guestagent/datastore/(postgres|mariadb|valkey|keydb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mariadb.*|valkey.*|keydb.*)\.py$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
- ^backup/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/strategies/replication/
|
||||
- ^trove/guestagent/datastore/(mysql.*|mariadb)/.*$
|
||||
- ^trove/guestagent/datastore/(mysql.*|mariadb|valkey|keydb)/.*$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
@@ -44,7 +44,7 @@
|
||||
- ^contrib/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/strategies/replication/
|
||||
- ^trove/guestagent/datastore/(mysql.*|mariadb)/.*$
|
||||
- ^trove/guestagent/datastore/(mysql.*|mariadb|valkey|keydb)/.*$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
@@ -72,8 +72,8 @@
|
||||
- ^contrib/
|
||||
- ^backup/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/datastore/(mysql.*|mariadb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(mariadb.*|mysql.*)\.py$
|
||||
- ^trove/guestagent/datastore/(mysql.*|mariadb|valkey|keydb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(mariadb.*|mysql.*|valkey.*|keydb.*)\.py$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
@@ -101,8 +101,8 @@
|
||||
- ^contrib/
|
||||
- ^backup/
|
||||
- ^\..+
|
||||
- ^trove/guestagent/datastore/(mysql|mariadb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(mysql.*|mariadb.*)\.py$
|
||||
- ^trove/guestagent/datastore/(mysql|mariadb|valkey|keydb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(mysql.*|mariadb.*|valkey.*|keydb.*)\.py$
|
||||
- ^trove/tests/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
|
||||
@@ -45,6 +45,26 @@
|
||||
voting: false
|
||||
- trove-tempest-cinder-storage-driver-postgresql:
|
||||
voting: false
|
||||
- trove-tempest-ubuntu-base-keydb
|
||||
- trove-tempest-ubuntu-backup-keydb:
|
||||
voting: false
|
||||
- trove-tempest-ubuntu-ssl-keydb
|
||||
- trove-tempest-ubuntu-ssl-replication-keydb:
|
||||
voting: false
|
||||
- trove-tempest-ubuntu-replication-keydb:
|
||||
voting: false
|
||||
- trove-tempest-cinder-storage-driver-keydb:
|
||||
voting: false
|
||||
- trove-tempest-ubuntu-base-valkey
|
||||
- trove-tempest-ubuntu-backup-valkey:
|
||||
voting: false
|
||||
- trove-tempest-ubuntu-ssl-valkey
|
||||
- trove-tempest-ubuntu-ssl-replication-valkey:
|
||||
voting: false
|
||||
- trove-tempest-ubuntu-replication-valkey:
|
||||
voting: false
|
||||
- trove-tempest-cinder-storage-driver-valkey:
|
||||
voting: false
|
||||
- trove-tox-bandit-baseline
|
||||
- trove-ubuntu-guest-image-build
|
||||
gate:
|
||||
@@ -52,6 +72,7 @@
|
||||
- trove-tempest-ubuntu-base-mysql
|
||||
- trove-tempest-ubuntu-base-mariadb
|
||||
- trove-tempest-ubuntu-base-postgresql
|
||||
- trove-tempest-ubuntu-base-valkey
|
||||
experimental:
|
||||
jobs:
|
||||
- trove-tempest-ipv6-only
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
# valkey jobs
|
||||
- job:
|
||||
name: trove-tempest-ubuntu-base-valkey
|
||||
parent: trove-tempest-ubuntu-base
|
||||
irrelevant-files: !inherit
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres|mariadb|keydb.*)/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: valkey
|
||||
TROVE_DATASTORE_VERSION: 9
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
enabled_datastores: "valkey"
|
||||
default_datastore_versions: valkey:9
|
||||
|
||||
- job:
|
||||
name: trove-tempest-ubuntu-backup-valkey
|
||||
parent: trove-tempest-ubuntu-backup
|
||||
irrelevant-files: !inherit
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres|mariadb|keydb.*)/.*$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: valkey
|
||||
TROVE_DATASTORE_VERSION: 9
|
||||
TROVE_STATE_CHANGE_WAIT_TIME: 900
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
backup_wait_timeout: 1200
|
||||
default_datastore_versions: valkey:9
|
||||
|
||||
- job:
|
||||
name: trove-tempest-ubuntu-replication-valkey
|
||||
parent: trove-tempest-ubuntu-replication
|
||||
irrelevant-files: !inherit
|
||||
- ^trove/guestagent/datastore/(mysql.*|postgres|mariadb|keydb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mysql.*|mariadb.*|keydb.*)\.py$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: valkey
|
||||
TROVE_DATASTORE_VERSION: 9
|
||||
TROVE_STATE_CHANGE_WAIT_TIME: 900
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
backup_wait_timeout: 1200
|
||||
default_datastore_versions: valkey:9
|
||||
|
||||
- job:
|
||||
name: trove-tempest-cinder-storage-driver-valkey
|
||||
parent: trove-tempest-snapshot
|
||||
irrelevant-files: !inherit
|
||||
- ^trove/guestagent/datastore/(postgres|mariadb|mysql|keydb)/.*$
|
||||
- ^trove/guestagent/strategies/replication/(postgresql.*|mysql.*|mariadb.*|keydb.*)\.py$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: valkey
|
||||
TROVE_DATASTORE_VERSION: 9
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
backup_wait_timeout: 1200
|
||||
default_datastore_versions: valkey:9
|
||||
|
||||
- job:
|
||||
name: trove-tempest-ubuntu-ssl-valkey
|
||||
parent: trove-tempest-ubuntu-ssl-base
|
||||
files: !inherit
|
||||
- ^trove/guestagent/.*valkey.*\.py$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: valkey
|
||||
TROVE_DATASTORE_VERSION: 9
|
||||
TROVE_STATE_CHANGE_WAIT_TIME: 900
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
backup_wait_timeout: 1200
|
||||
default_datastore_versions: valkey:9
|
||||
|
||||
- job:
|
||||
name: trove-tempest-ubuntu-ssl-replication-valkey
|
||||
parent: trove-tempest-ubuntu-ssl-replication
|
||||
files: !inherit
|
||||
- ^trove/guestagent/.*valkey.*\.py$
|
||||
vars:
|
||||
devstack_localrc:
|
||||
TROVE_DATASTORE_TYPE: valkey
|
||||
TROVE_DATASTORE_VERSION: 9
|
||||
TROVE_STATE_CHANGE_WAIT_TIME: 900
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
database:
|
||||
backup_wait_timeout: 1200
|
||||
default_datastore_versions: valkey:9
|
||||
Reference in new issue
Block a user