diff options
| author | Michal Arbet <michal.arbet@ultimum.io> | 2025-06-04 09:40:03 +0200 |
|---|---|---|
| committer | Michal Arbet <michal.arbet@ultimum.io> | 2025-06-04 10:24:54 +0200 |
| commit | b643e8f9fd3e9d8e881e112e53183db743f1e5d3 (patch) | |
| tree | 3da2ff045d02c9c16bc0440db40380f087055f1f /docker/proxysql | |
| parent | 9a5315e9d250ca520a8bc38f67013e0b632de08e (diff) | |
| download | kolla-b643e8f9fd3e9d8e881e112e53183db743f1e5d3.tar.gz kolla-b643e8f9fd3e9d8e881e112e53183db743f1e5d3.zip | |
Fix ProxySQL rule sanity check to support username-based routing
Kolla Ansible now generates ProxySQL query rules not only based on
the schema name (schemaname), but also on the username. This is
needed to properly route queries that are executed before a database
schema is selected, such as `SET AUTOCOMMIT` or `ROLLBACK`.
To support this, the ProxySQL config sanity check must correctly
deduplicate rules based on both `schemaname` and `username`, and
avoid false positives when both types are used simultaneously.
This change adjusts the logic in `kolla_proxysql_config_sync` to:
- recognize rules by key `schema:<schemaname>` or `user:<username>`
- assign unique rule IDs only to truly distinct rules
- log and skip exact duplicates with appropriate context
This fix is required to support the Kolla Ansible patch below.
Needed-By: https://review.opendev.org/c/openstack/kolla-ansible/+/951599
Change-Id: I99acd1984ee555a5b6c731e6ee460a33677060d0
Diffstat (limited to 'docker/proxysql')
| -rw-r--r-- | docker/proxysql/kolla_proxysql_config_sync | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/docker/proxysql/kolla_proxysql_config_sync b/docker/proxysql/kolla_proxysql_config_sync index d6d531f30..094642c8a 100644 --- a/docker/proxysql/kolla_proxysql_config_sync +++ b/docker/proxysql/kolla_proxysql_config_sync @@ -93,14 +93,24 @@ class ProxySQLConfig: rules = list() rule_id = 1 for rule in self.config['mysql_query_rules']: - if rule['schemaname'] not in rules_added: - rules_added.append(rule['schemaname']) + if 'schemaname' in rule: + key = f"schema:{rule['schemaname']}" + elif 'username' in rule: + key = f"user:{rule['username']}" + else: + LOG.warning( + f"Rule without schemaname or username found, skipping: {rule}" + ) + continue + + if key not in rules_added: + rules_added.append(key) rule['rule_id'] = rule_id rules.append(rule) rule_id += 1 else: - LOG.warning("Rule witch schemaname {} already exist, ignoring." - .format(rule['schemaname'])) + LOG.warning("Duplicate rule for {}, ignoring.".format(key)) + self.config['mysql_query_rules'] = rules def _write_dict(self, key, value): |
