saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

[BUG] 'salt-call grains.item gpus:vendor' lists only a single GPU vendor #63079

Open rjc opened 2 years ago

rjc commented 2 years ago

Description

All GPU vendors and GPU model names are visible when running:

# salt-call grains.item gpus
local:
    ----------
    gpus:
        |_
          ----------
          model:
              G200eR2
          vendor:
              matrox
        |_
          ----------
          model:
              GK110GL [Tesla K20m]
          vendor:
              nvidia

However, only a single one is shown when running:

# salt-call grains.item gpus:vendor
local:
    ----------
    gpus:vendor:
        matrox

On different machines, also with Matrox and Nvidia GPUs, the result will differ and the latter vendor is shown:

# salt-call grains.item gpus:vendor
local:
    ----------
    gpus:vendor:
        nvidia

The results are deterministic insofar as not to flip between vendors on the same machine but I can't seem to find the pattern why on some machines it is one and on other machines the other vendor is shown.

This makes it impossible to target machines using that particular grain, e.g.:

  'gpus:vendor:nvidia':
    - match: grain
    - foo

will only run/apply foo to machines which return nvidia as the first, and only, vendor.

Setup This can be observed without any specific Salt configuration in place.

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

Steps to Reproduce the behavior

Run salt-call grains.item gpus:vendor on any machine with GPUs from several vendors.

Expected behavior

Have all vendors returned like so:

# salt-call grains.item gpus:vendor
local:
    ----------
    gpus:vendor:
        - intel
        - matrox
        - nvidia

The same could be extended to gpus:model name:

# salt-call grains.item gpus:model
local:
    ----------
    gpus:model:
        - Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller
        - RV710/M92 [Mobility Radeon HD 4330/4350/4550]
        - GK180GL [Tesla K40c]

Versions Report

salt --versions-report ```yaml # salt --versions-report Salt Version: Salt: 3005.1 Dependency Versions: cffi: Not Installed cherrypy: Not Installed dateutil: 2.6.1 docker-py: Not Installed gitdb: 2.0.3 gitpython: 2.1.8 Jinja2: 2.10 libgit2: 0.26.0 M2Crypto: Not Installed Mako: 1.0.7 msgpack: 0.5.6 msgpack-pure: Not Installed mysql-python: Not Installed pycparser: Not Installed pycrypto: 2.6.1 pycryptodome: 3.4.7 pygit2: 0.26.2 Python: 3.6.9 (default, Jun 29 2022, 11:45:57) python-gnupg: 0.4.1 PyYAML: 3.12 PyZMQ: 17.1.2 smmap: 2.0.3 timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.2.5 System Versions: dist: ubuntu 18.04 Bionic Beaver locale: UTF-8 machine: x86_64 release: 5.4.0-132-generic system: Linux version: Ubuntu 18.04 Bionic Beaver ```
OrangeDog commented 1 year ago

Any grain with a list of dicts will have the same behaviour. So does pillar.get and config.get.

I think this has been reported before, but I can't find the issue.

jjjj326562 commented 1 year ago

I've run into this same issue. The "Expected Behavior" by @rjc is what I would expect