Skip to content

[BUG]salt['grains.filter_by']() not checking grains correctly against grain values with spaces in them #60976

Closed

Description

@macmandr197

Description
I'm trying to use the file.managed module, and choosing a specific file based upon the result of a grain using filter_by

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)
init.sls

{% from "path/gpu_models.yaml" import gpu_model_map with context %}
{% set gpu_model = salt['grains.filter_by'](gpu_model_map, grain=salt['grains.get']('gpus:0:model')) %}

{% from "path/gpu_vendors.yaml" import gpu_vendor_map with context %}
{% set gpu_vendor = salt['grains'].filter_by(gpu_vendor_map, grain='gpus:vendor') %}
...
#install the graphics agent
install_teradici:
  pkg.installed:
    - name: {{ gpu_vendor.teradici_agent}}
    - version: {{ gpu_vendor.teradici_agent_version}}
    - require: 
      - teradici_repo #step omitted from snippet

#manage the xorg.conf.d override file pcoip.conf, and only if the graphics agent has been installed.
teradici_xorg_conf:
  file.managed:
    - source: salt://centos76/ghost_vfx/software/teradici/{{ gpu_model.xorg_file }}
    - name: /etc/X11/xorg.conf.d/pcoip.conf
    - user: root
    - group: root
    - mode: '0644'
    - require: 
      - install_teradici
      - pkg: pcoip-agent-graphics
...

GPU map

{% load_yaml as gpu_model_map %}

'GK110GL [Quadro K6000]':
  xorg_file: teradici_k.conf

'GK106GL [Quadro K4000]':
  xorg_file: teradici_k.conf

'GK104GL [Quadro K4200]':
  xorg_file: teradici_k.conf

'Device 1eb1':
  xorg_file: teradici_mp.conf

'GM204GL [Quadro M4000]':
  xorg_file: teradici_mp.conf

'GP104GL [Quadro P4000]':
  xorg_file: teradici_mp.conf

'GM200GL [Quadro M6000]':
  xorg_file: teradici_mp.conf

'GM200GL [Quadro M6000 24GB]':
  xorg_file: teradici_mp.conf

{% endload %}

Vendors Map

{%- load_yaml as gpu_vendor_map %}

nvidia:
  teradici_agent: pcoip-agent-graphics
  teradici_agent_version: 20.04.0-1
unknown:
  teradici_agent: pcoip-agent-standard
  teradici_agent_version: 20.04.0-1

{%- endload %}

Please be as specific as possible and give set-up details.
using v 3002.7 on CentOS 7.6.

  • [ y] on-prem machine
  • [ n] VM (Virtualbox, KVM, etc. please specify)
  • [ n] VM running on a cloud service, please be explicit and add details
  • [ n] container (Kubernetes, Docker, containerd, etc. please specify)
  • [ n] or a combination, please be explicit
  • [ n] jails if it is FreeBSD

Steps to Reproduce the behavior
(Include debug logs if possible and relevant)
place files in a relevant location on a CentOS Machine with a Graphics card installed. Can be a Quadro, or whatever GPU you have. Just be sure to update the GPU map with the resulting gpus:0:model grain value. after that run the state file.

Expected behavior
With a Quadro P4000 (grain value "GP104GL [Quadro P4000]", the jinja variables should render as the following:
gpu_vendor.teradici_agent pcoip-agent-graphics

gpu_vendor.teradici_agent_version 20.04.0-1

gpu_model.xorg_model teradici_mp.conf

However, the gpu_model.xorg_model value always ends up as None (which would be the default value of xorg_file) however, I have a matching value in my map file? I literally copy and pasted the grain result into the map file and surrounded it in quotes.

Activity

  1. added
    bug
    on Sep 29, 2021
  2. welcome commented on Sep 29, 2021

    @welcome

    Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
    Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

    There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
    If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

  3. macmandr197 commented on Oct 4, 2021

    @macmandr197
    Author

    anyone here?

  4. added
    severity-medium
    and removed on Oct 5, 2021
  5. added this to the Approved milestone on Oct 5, 2021
  6. macmandr197 commented on Oct 12, 2021

    @macmandr197
    Author

    Hey @frogunder may I ask what it was that made you decide to add this to the approved status? would like to understand the bug-reporting/triage lifecycle as I use Salt more. Thanks!

  7. frogunder commented on Oct 13, 2021

    @frogunder
    Contributor

    Hi, yeah for sure. I marked it as approved because I believe it is a valid bug.

    That does however not mean that a salt core engineer will work on this issue. That is determined by other factors and is ultimately up to the manager to decide. Lets say this issue gets a lot of traction, many other people are reporting similar issues that are or can be related, it might be more possible that it will be worked on.
    If this was a regression, it would most likely be fixed soon.
    Many of the issues that are currently reported are not considered urgent and it will most likely be up to the salt-community to work on a fix for them.

  8. macmandr197 commented on Oct 13, 2021

    @macmandr197
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugseverity-medium

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions