Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] No minion presense #9

Open
3 of 9 tasks
JesperBeltman opened this issue Oct 17, 2024 · 2 comments · May be fixed by #10
Open
3 of 9 tasks

[BUG] No minion presense #9

JesperBeltman opened this issue Oct 17, 2024 · 2 comments · May be fixed by #10
Labels
bug Something isn't working

Comments

@JesperBeltman
Copy link

JesperBeltman commented Oct 17, 2024

Description
When exploring the usage of mysql with salt I found a problem where the presence detection does not work when enabling the mysql_cache. This is due to many factors as far as i was able to read the ls function is not returning the minion name its returning the etcd_key column value which is data in my case. I'd like to make a PR for this issue in the future.

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

The code above is the source of mysql_cache list or also ls called here function. What it is supposed to return is minion name, this is not in the select of the sql statement, the minion name is in the bank column.

salt/presence/present {
"_stamp": "2024-10-17T12:25:05.694697",
"present": []
}

Setup
I am using a Proxmox hypervisor for testing with salt, nothing special about it.
Two minions are connected to the salt-master one is a linux desktop VM and the other is windows 11 VM.

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior
Enable mysql_cache and have presence_events turned on the master.
Now looking at the events you would be able to see this json:

salt/presence/present   {
    "_stamp": "2024-10-17T14:01:15.311226",
    "present": []
}

Expected behavior
Expect a list of alived minions when running:
salt-run manage.alived

Versions Report
Salt Version:
Salt: 3007.1

Python Version:
Python: 3.10.14 (main, Apr 3 2024, 21:30:09) [GCC 11.2.0]

Dependency Versions:
cffi: 1.16.0
cherrypy: unknown
dateutil: 2.8.2
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.4
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.7
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 23.1
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.5.2
PyYAML: 6.0.1
PyZMQ: 25.1.2
relenv: 0.16.0
smmap: Not Installed
timelib: 0.3.0
Tornado: 6.3.3
ZMQ: 4.3.4

Salt Package Information:
Package Type: onedir

System Versions:
dist: ubuntu 24.04.1 noble
locale: utf-8
machine: x86_64
release: 6.8.0-45-generic
system: Linux
version: Ubuntu 24.04.1 noble

@JesperBeltman JesperBeltman added the bug Something isn't working label Oct 17, 2024
@JesperBeltman JesperBeltman linked a pull request Oct 17, 2024 that will close this issue
3 tasks
@lkubb
Copy link
Member

lkubb commented Nov 3, 2024

Please see my explanation of the issue here: #10 (review)

In the meantime, I discovered a corresponding issue + PR at the Salt core repo:

saltstack/salt#66102
saltstack/salt#66103

I believe the proposed fix there to still be inadequate because - following the filesystem hierarchy analogy - it only lists "subdirectories" while skipping over "files" in the requested cache bank and lists subdirectories of subdirectories (it should only list direct children).

@JesperBeltman
Copy link
Author

Thank you for the time invested, I will slimm down the changes.
I agree with what you have said. Then I will request a feat aswell for using both mysql_cache and mysql as a returner with seperate configs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants