[BUG] Not removing entries from /etc/fstab
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
The mount states are not correctly removing entries from /etc/fstab, leading to duplicates.
Setup
/mnt/test:
mount.mounted:
- device: 'sshfs#me@host:/path'
- fstype: fuse
- opts: {{ mount_opts }}
- extra_mount_invisible_keys: {{ fuse_and_ssh_opts }}
- mkmnt: true
- persist: true
Steps to Reproduce the behavior
Attempt 1: Change device and apply the state
# salt-call state.apply
local:
----------
ID: /mnt/test
Function: mount.mounted
Result: True
Comment: Target was successfully mounted. Added new entry to the fstab.
Started: 08:27:58.714180
Duration: 102.657 ms
Changes:
----------
mount:
True
persist:
new
umount:
Forced unmount because devices don't match. Wanted: sshfs#me@host:/path2 (me@host:/path2), current: me@host:/path
Summary for local
--------------
Succeeded: 163 (changed=1)
Failed: 0
--------------
Total states run: 163
Total run time: 18.415 s
# grep /mnt/test /etc/fstab
sshfs#me@host:/path /mnt/test fuse OPTS...
sshfs#me@host:/path2 /mnt/test fuse OPTS...
Attempt 2: Apply a mount.fstab_absent state:
# salt-call state.single mount.fstab_absent name=foo fs_file=/mnt/test
local:
----------
ID: foo
Function: mount.fstab_absent
Result: True
Comment: /mnt/test entry removed from /etc/fstab.
Started: 08:41:51.302527
Duration: 2.983 ms
Changes:
----------
persist:
removed
Summary for local
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 2.983 ms
# grep /mnt/test /etc/fstab
sshfs#me@host:/path /mnt/test fuse OPTS...
sshfs#me@host:/path2 /mnt/test fuse OPTS...
Expected behavior
mount.mounted should ensure previous fstab entry is removed when making changes.
mount.fstab_absent should delete entries by target, and should not report changes when there were none
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3003.3
Dependency Versions:
cffi: 1.14.5
cherrypy: Not Installed
dateutil: 2.7.3
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.10.1
libgit2: 1.1.0
M2Crypto: 0.31.0
Mako: Not Installed
msgpack: 0.6.2
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.20
pycrypto: Not Installed
pycryptodome: 3.6.1
pygit2: 1.6.1
Python: 3.8.10 (default, Jun 2 2021, 10:49:15)
python-gnupg: 0.4.5
PyYAML: 5.3.1
PyZMQ: 18.1.1
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.2
System Versions:
dist: ubuntu 20.04 focal
locale: utf-8
machine: x86_64
release: 5.4.0-86-generic
system: Linux
version: Ubuntu 20.04 focal
Workaround
fix issue:
cmd.run:
- name: "sed -i '\\|/mnt/test|d' /etc/fstab"
- prereq:
- mount: /mnt/test
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.
Research direction
Start with the mount.mounted and mount.fstab_absent state entry points, reproducing both reported cases against /etc/fstab. Done means changing a device removes the prior target entry, fstab_absent removes all entries for the target, and a missing target reports no change; add regression coverage for both behaviors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, python
- Domain
- devops, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100