saltstack / saltstack/salt

[BUG] KeyError: 'disk.blkid' on mount.mounted for NFS mount

Open
#65,441 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
Sometime around 3006.0 - 3006.2 I started getting errors on my mount.mounted states for NFS mounts:

----------
          ID: mount_/etc/salt/pki/master/minions
    Function: mount.mounted
        Name: /etc/salt/pki/master/minions
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/state.py", line 2381, in call
                  ret = self.states[cdata["full"]](
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
                  ret = self.loader.run(run_func, *args, **kwargs)
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1293, in wrapper
                  return f(*args, **kwargs)
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/mount.py", line 242, in mounted
                  active = __salt__["mount.active"](extended=True)
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
                  ret = self.loader.run(run_func, *args, **kwargs)
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/mount.py", line 277, in active
                  _active_mountinfo(ret)
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/mount.py", line 59, in _active_mountinfo
                  __context__["disk.blkid"] = __salt__["disk.blkid"]()
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/context.py", line 78, in __getitem__
                  return self.value()[item]
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 349, in __getitem__
                  super().__getitem__(item)  # try to get the item from the dictionary
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/lazy.py", line 105, in __getitem__
                  raise KeyError(key)
              KeyError: 'disk.blkid'
     Started: 14:32:19.750162
    Duration: 34.566 ms
     Changes:   

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

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

State:

  mount_/etc/salt/pki/master/minions:
    mount.mounted:
    - name: /etc/salt/pki/master/minions
    - device: 192.0.2.97:/etc/salt/pki/master/minions
    - fstype: nfs4
    - opts:
      - defaults
      - rw
      - nosuid
      - nodev
      - noexec
      - relatime
      - vers=4.1
      - rsize=65536
      - wsize=65536
      - namlen=255
      - hard
      - proto=tcp
      - timeo=600
      - retrans=2
      - sec=sys
      - local_lock=none
    - persist: true
    - mount: true

Steps to Reproduce the behavior
Try to apply the above state

Expected behavior
State would report no changes

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
              Salt: 3006.3

Python Version:
            Python: 3.10.13 (main, Sep  6 2023, 02:11:27) [GCC 11.2.0]

Dependency Versions:
              cffi: 1.14.6
          cherrypy: unknown
          dateutil: 2.8.1
         docker-py: Not Installed
             gitdb: Not Installed
         gitpython: Not Installed
            Jinja2: 3.1.2
           libgit2: 1.5.0
      looseversion: 1.0.2
          M2Crypto: Not Installed
              Mako: Not Installed
           msgpack: 1.0.2
      msgpack-pure: Not Installed
      mysql-python: Not Installed
         packaging: 22.0
         pycparser: 2.21
          pycrypto: Not Installed
      pycryptodome: 3.9.8
            pygit2: 1.11.1
      python-gnupg: 0.4.8
            PyYAML: 6.0.1
             PyZMQ: 23.2.0
            relenv: 0.13.10
             smmap: Not Installed
           timelib: 0.2.4
           Tornado: 4.5.3
               ZMQ: 4.3.4

Salt Extensions:
 saltext.bitwarden: 0.0.1b15
    saltext.vmware: 23.6.29.0rc1

System Versions:
              dist: almalinux 8.7 Stone Smilodon
            locale: utf-8
           machine: x86_64
           release: 4.18.0-425.19.2.el8_7.x86_64
            system: Linux
           version: AlmaLinux 8.7 Stone Smilodon

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with salt/modules/mount.py, especially _active_mountinfo and active, then trace the mount.mounted call in salt/states/mount.py. Reproduce the reported NFS state using the supplied configuration and verify that applying it no longer raises KeyError: 'disk.blkid' and reports no changes when the mount is already active.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
infrastructure, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.