[BUG] MySQL cache driver unable to enumerate minions, breaks manage.present
@dwoz is already working on this.
Since Jul 29, 2024.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
The MySQL minion cache is unable to enumerate minions and fails when running actions relying on mysql_cache.ls
This causes manage.present to fail.
Setup
Please be as specific as possible and give set-up details.
- [ *] container (Kubernetes, Docker, containerd, etc. please specify)
- [ *] onedir packaging
Steps to Reproduce the behavior
Configure /etc/salt/master with MySQL cache
# /etc/salt/master
cache: mysql
mysql.host: "..."
mysql.port: 3306
mysql.user: saltstack
mysql.password: "..."
Run salt-run manage.status to confirm the minions are present via events
$ salt-run manage.status
- minion1
- minion2
$
The bug:
Run salt-run manage.present which should use the minion cache to determine presence
$ salt-run manage.present
$
Expected behavior
A clear and concise description of what you expected to happen.
$ salt-run manage.present
- minion1
- minion2
$
Versions Report
Minion/master running 3006.6
Additional context
The data
MariaDB [salt_cache]> select etcd_key, bank from salt where bank LIKE 'minions/%' limit 2;
+----------+-------------------------------------------------------+
| etcd_key | bank |
+----------+-------------------------------------------------------+
| data | minions/minion1 |
| data | minions/minion2 |
+----------+-------------------------------------------------------+
The code in mysql_cache.py is:
def ls(bank):
"""
Return an iterable object containing all entries stored in the specified
bank.
"""
_init_client()
query = "SELECT etcd_key FROM {} WHERE bank=%s".format(
__context__["mysql_table_name"]
)
cur, _ = run_query(__context__.get("mysql_client"), query, args=(bank,))
out = [row[0] for row in cur.fetchall()]
cur.close()
return out
It appears to mistakenly return etcd_key instead of the path of the minion. Return looks like ['data', 'data', ... ]. ls would be expected to return ["minion1", "minion2"]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.