Salt: mount.swap always executes

Created on 18 May 2015  路  11Comments  路  Source: saltstack/salt

On Ubuntu 14.04, I have a simple swap state:

partition_/dev/xvde:
  cmd.run:
    - name: parted -s -a optimal /dev/xvde mklabel gpt -- "mkpartfs swap linux-swap 1 32GB; mkpart extra ext4 32GB -1"
    - unless: cat /proc/swaps | grep /dev/xvde || mount |grep /dev/xvde

/dev/xvde1:
  mount.swap

The mount.swap state always runs. It succeeds ("Swap /dev/xvde1 already active") with no changes, but when run with test=true it thinks the current state of fstab (or my mounted filesystems) is incorrect (the second state is yellow).

local:
----------
          ID: partition_/dev/xvde
    Function: cmd.run
        Name: parted -s -a optimal /dev/xvde mklabel gpt -- "mkpartfs swap linux-swap 1 32GB; mkpart extra ext4 32GB -1"
      Result: True
     Comment: unless execution succeeded
     Started: 22:32:35.279124
    Duration: 6.74 ms
     Changes:   
----------
          ID: /dev/xvde1
    Function: mount.swap
      Result: None
     Comment: Swap /dev/xvde1 is set to be added to the fstab and to be activated
     Started: 22:32:35.286113
    Duration: 0.876 ms
     Changes:   

Summary
------------
Succeeded: 2 (unchanged=1)
Failed:    0
------------
Total states run:     2

My /etc/fstab:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/xvda1  /               ext4    errors=remount-ro,noatime,barrier=0 0       1
#/dev/xvdc1 none            swap    sw              0       0
/dev/xvde1      none    swap    defaults    0 0
$ salt-call --versions-report
                  Salt: 2014.7.5
                Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
                Jinja2: 2.7.2
              M2Crypto: 0.21.1
        msgpack-python: 0.3.0
          msgpack-pure: Not Installed
              pycrypto: 2.6.1
               libnacl: Not Installed
                PyYAML: 3.10
                 ioflo: Not Installed
                 PyZMQ: 14.0.1
                  RAET: Not Installed
                   ZMQ: 4.0.4
                  Mako: 0.9.1
 Debian source package: 2014.7.5+ds-1ubuntu1
Bug P3 Platform State Module fixed-pending-your-verification severity-medium

Most helpful comment

still broken in 2017.7.1

Salt Version:
           Salt: 2017.7.1

Dependency Versions:
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: 2.2
      docker-py: Not Installed
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.7.3
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.21.1
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.2
   mysql-python: 1.2.3
      pycparser: 2.10
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.9 (default, Jun 29 2016, 13:08:31)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
           RAET: Not Installed
          smmap: 0.8.2
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: debian 8.8
         locale: ANSI_X3.4-1968
        machine: x86_64
        release: 3.16.0-4-amd64
         system: Linux
        version: debian 8.8
          ID: /swap
    Function: mount.swap
      Result: None
     Comment: Swap /swap is set to be added to the fstab and to be activated
     Started: 10:41:02.190715
    Duration: 0.814 ms
     Changes:

sudo swapon -s

Filename                                Type            Size    Used    Priority
/swap                                   file            4194300 0       -1

cat /etc/fstab

# /etc/fstab: static file system information.
UUID=b5d092d7-8fce-407b-81f3-83e0cb6f0c78   /   ext4  errors=remount-ro   0   1
UUID=296d86bb-f2d1-41fe-89c9-5e5078b4da1f /boot ext4 errors=remount-ro 0 2
/swap           none    swap    defaults        0 0

All 11 comments

Thanks for the report @notpeter. I know @garethgreenaway was doing a lot of work with mount states, so this may already be fixed on a newer version such as 2015.5.0, though I don't know for sure. Would you be able to try this on a newer version? Have you seen this one before @garethgreenaway?

still broken in 2017.7.1

Salt Version:
           Salt: 2017.7.1

Dependency Versions:
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: 2.2
      docker-py: Not Installed
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.7.3
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.21.1
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.2
   mysql-python: 1.2.3
      pycparser: 2.10
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.9 (default, Jun 29 2016, 13:08:31)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
           RAET: Not Installed
          smmap: 0.8.2
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: debian 8.8
         locale: ANSI_X3.4-1968
        machine: x86_64
        release: 3.16.0-4-amd64
         system: Linux
        version: debian 8.8
          ID: /swap
    Function: mount.swap
      Result: None
     Comment: Swap /swap is set to be added to the fstab and to be activated
     Started: 10:41:02.190715
    Duration: 0.814 ms
     Changes:

sudo swapon -s

Filename                                Type            Size    Used    Priority
/swap                                   file            4194300 0       -1

cat /etc/fstab

# /etc/fstab: static file system information.
UUID=b5d092d7-8fce-407b-81f3-83e0cb6f0c78   /   ext4  errors=remount-ro   0   1
UUID=296d86bb-f2d1-41fe-89c9-5e5078b4da1f /boot ext4 errors=remount-ro 0 2
/swap           none    swap    defaults        0 0

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

I believe this is still broken

Thank you for updating this issue. It is no longer marked as stale.

FYI, this issue is fixed in 2018.3.

@garethgreenaway Thanks. I'm used to poking the stale bot when it's over eager to close issues, most issues I follow are closed when fixed, or I can easily see a commit related to them being fixed.

This will go into the next 2017.7, https://github.com/saltstack/salt/pull/51246

@timwsuqld No worries. Looks like I didn't tag the issue in the PR when it was fixed.

Closing as this is available in the latest 2017.7 and 2018.3 releases, if the issue remains please let us know and we can reopen the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

qiushics picture qiushics  路  3Comments

erwindon picture erwindon  路  3Comments

saurabhnemade picture saurabhnemade  路  3Comments

Arguros picture Arguros  路  3Comments

zieba88 picture zieba88  路  3Comments