Bug 1354410

Summary: [RFE] Backport x-systemd.idle-timeout to RHEL7
Product: Red Hat Enterprise Linux 7 Reporter: Jayaram <jradhakr>
Component: systemdAssignee: Jan Synacek <jsynacek>
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.2CC: bblaskov, fsumsal, giulioo, hunter86_bg, jsynacek, msekleta, sbhat, systemd-maint-list, systemd-maint
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: systemd-219-32.el7 Doc Type: Enhancement
Doc Text:
Feature: Support for automatically unmounting a mounted file system after specified amount of time. This is done via the 'x-systemd.idle-timeout' option that can be used along with other options in /etc/fstab. Reason: Customer asked for it. It's a generally useful feature. Result: The feature was backported from upstream and is now supported.
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 09:09:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1298243    

Description Jayaram 2016-07-11 09:23:47 UTC
Description of problem:

.NFS automount in systemd, but x-systemd.idle-timeout doesn't unmount the filesystem after the specified amount of time


Version-Release number of selected component (if applicable):

RHEL7.2 -- 
3.10.0-327.10.1.el7.x86_64 --
systemd-219-19.el7_2.4.x86_64
nfs-utils-1.3.0-0.21.el7_2.x86_64


How reproducible:

In /etc/fstab the nfs entry as follows;--

~~~
192.168.122.2:/storage /mnt nfs noauto,x-systemd.automount,x-systemd.device-timeout=10,x-systemd.idle-timeout=1800,nofail,timeo=14,nolock 0 0
~~~

Note: here i tried with different timeout value, still not luck

#cat  /var/run/systemd/generator/mnt.mount
=======================
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)

[Mount]
What=192.168.122.2:/storage
Where=/mnt
Type=nfs
Options=noauto,x-systemd.automount,x-systemd.idle-timeout=1800,nofail,timeo=14,nolock
=======================

#cat  /var/run/systemd/generator/mnt.automount
=====================
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Before=remote-fs.target
[Automount]
Where=/mnt
=====================

>> Reboot the machine

>> Access the share by 
#df -h /mnt
Filesystem              Size  Used Avail Use% Mounted on
192.168.122.2:/storage  6.5G  2.4G  3.8G  39% /mnt



Actual results:

It is not unmonting the share after the timeout value 1800 which is 30min. 


Expected results:

It should unmount the NFS share after the timeout value.

Comment 5 giulioo 2016-10-24 17:37:55 UTC
According to 
  https://github.com/systemd/systemd/blob/master/NEWS
the "x-systemd.idle-timeout" directive was added in systemd 220.

RHEL7.2 ships with systemd-219-19.el7_2.13.x86_64
and, according to the rpm's changelog, nothing related to it has been manually patched:

$ rpm -q systemd
systemd-219-19.el7_2.13.x86_64
$ rpm -ql --changelog systemd|grep idle
$

so it seems it's normal for RHEL7's systemd to ignore it.

Comment 7 Jan Synacek 2017-02-08 09:17:09 UTC
https://github.com/lnykryn/systemd-rhel/pull/89

I'll provide a testing build shortly.

Comment 12 Frantisek Sumsal 2017-03-17 13:07:00 UTC
Verified with systemd-219-32.el7.

New version:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: backport x-systemd.idle-timeout [BZ#1354410]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 09:02:16 ] :: [ INFO    ] :: using '/var/tmp/beakerlib-3834001/backup' as backup destination
:: [  BEGIN   ] :: Running 'echo '127.0.0.1:/storage /testmntAxqN0e nfs noauto,x-systemd.automount,x-systemd.idle-timeout=1800 0 0' >> /etc/fstab'
:: [   PASS   ] :: Command 'echo '127.0.0.1:/storage /testmntAxqN0e nfs noauto,x-systemd.automount,x-systemd.idle-timeout=1800 0 0' >> /etc/fstab' (Expected 0, got 0)
:: [  BEGIN   ] :: Running '/usr/lib/systemd/system-generators/systemd-fstab-generator 'mounts.h5u' 'mounts.h5u' 'mounts.h5u''
:: [   PASS   ] :: Command '/usr/lib/systemd/system-generators/systemd-fstab-generator 'mounts.h5u' 'mounts.h5u' 'mounts.h5u'' (Expected 0, got 0)
:: [  BEGIN   ] :: Running 'ls -la mounts.h5u'
total 60
drwx------. 6 root root 4096 Mar 17 09:02 .
drwx------. 3 root root 4096 Mar 17 09:02 ..
-rw-r--r--. 1 root root  461 Mar 17 09:02 boot.mount
-rw-r--r--. 1 root root  186 Mar 17 09:02 dev-mapper-VolGroup00\x2dLogVol01.swap
drwxr-xr-x. 2 root root 4096 Mar 17 09:02 local-fs.target.requires
drwxr-xr-x. 2 root root 4096 Mar 17 09:02 local-fs.target.wants
-rw-r--r--. 1 root root  307 Mar 17 09:02 mnt-engarchive.mount
-rw-r--r--. 1 root root  282 Mar 17 09:02 mnt-qa.mount
-rw-r--r--. 1 root root  343 Mar 17 09:02 mnt-redhat.mount
-rw-r--r--. 1 root root  292 Mar 17 09:02 mnt-tpsdist.mount
-rw-r--r--. 1 root root  228 Mar 17 09:02 -.mount
drwxr-xr-x. 2 root root 4096 Mar 17 09:02 remote-fs.target.requires
drwxr-xr-x. 2 root root 4096 Mar 17 09:02 swap.target.requires
-rw-r--r--. 1 root root  219 Mar 17 09:02 testmntAxqN0e.automount
-rw-r--r--. 1 root root  267 Mar 17 09:02 testmntAxqN0e.mount
:: [   PASS   ] :: Command 'ls -la mounts.h5u' (Expected 0, got 0)
:: [  BEGIN   ] :: Running 'cat 'mounts.h5u/testmntAxqN0e.automount''
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Before=remote-fs.target
[Automount]
Where=/testmntAxqN0e
TimeoutIdleSec=30min
:: [   PASS   ] :: Command 'cat 'mounts.h5u/testmntAxqN0e.automount'' (Expected 0, got 0)
:: [   PASS   ] :: File 'mounts.h5u/testmntAxqN0e.automount' should contain 'TimeoutIdleSec=30min' 
:: [  BEGIN   ] :: Running 'rm -fr 'mounts.h5u''
:: [   PASS   ] :: Command 'rm -fr 'mounts.h5u'' (Expected 0, got 0)


Old version for comparison:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: backport x-systemd.idle-timeout [BZ#1354410]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 09:05:04 ] :: [ INFO    ] :: using '/var/tmp/beakerlib-7117001/backup' as backup destination
:: [  BEGIN   ] :: Running 'echo '127.0.0.1:/storage /testmntYePhQn nfs noauto,x-systemd.automount,x-systemd.idle-timeout=1800 0 0' >> /etc/fstab'
:: [   PASS   ] :: Command 'echo '127.0.0.1:/storage /testmntYePhQn nfs noauto,x-systemd.automount,x-systemd.idle-timeout=1800 0 0' >> /etc/fstab' (Expected 0, got 0)
:: [  BEGIN   ] :: Running '/usr/lib/systemd/system-generators/systemd-fstab-generator 'mounts.XPG' 'mounts.XPG' 'mounts.XPG''
:: [   PASS   ] :: Command '/usr/lib/systemd/system-generators/systemd-fstab-generator 'mounts.XPG' 'mounts.XPG' 'mounts.XPG'' (Expected 0, got 0)
:: [  BEGIN   ] :: Running 'ls -la mounts.XPG'
total 60
drwx------. 6 root root 4096 Mar 17 09:05 .
drwx------. 3 root root 4096 Mar 17 09:05 ..
-rw-r--r--. 1 root root  461 Mar 17 09:05 boot.mount
-rw-r--r--. 1 root root  186 Mar 17 09:05 dev-mapper-VolGroup00\x2dLogVol01.swap
drwxr-xr-x. 2 root root 4096 Mar 17 09:05 local-fs.target.requires
drwxr-xr-x. 2 root root 4096 Mar 17 09:05 local-fs.target.wants
-rw-r--r--. 1 root root  307 Mar 17 09:05 mnt-engarchive.mount
-rw-r--r--. 1 root root  282 Mar 17 09:05 mnt-qa.mount
-rw-r--r--. 1 root root  343 Mar 17 09:05 mnt-redhat.mount
-rw-r--r--. 1 root root  292 Mar 17 09:05 mnt-tpsdist.mount
-rw-r--r--. 1 root root  228 Mar 17 09:05 -.mount
drwxr-xr-x. 2 root root 4096 Mar 17 09:05 remote-fs.target.requires
drwxr-xr-x. 2 root root 4096 Mar 17 09:05 swap.target.requires
-rw-r--r--. 1 root root  198 Mar 17 09:05 testmntYePhQn.automount
-rw-r--r--. 1 root root  267 Mar 17 09:05 testmntYePhQn.mount
:: [   PASS   ] :: Command 'ls -la mounts.XPG' (Expected 0, got 0)
:: [  BEGIN   ] :: Running 'cat 'mounts.XPG/testmntYePhQn.automount''
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Before=remote-fs.target
[Automount]
Where=/testmntYePhQn
:: [   PASS   ] :: Command 'cat 'mounts.XPG/testmntYePhQn.automount'' (Expected 0, got 0)
:: [   FAIL   ] :: File 'mounts.XPG/testmntYePhQn.automount' should contain 'TimeoutIdleSec=30min' 
:: [  BEGIN   ] :: Running 'rm -fr 'mounts.XPG''
:: [   PASS   ] :: Command 'rm -fr 'mounts.XPG'' (Expected 0, got 0)

Comment 13 errata-xmlrpc 2017-08-01 09:09:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:2297

Comment 14 David Tardon 2018-06-22 11:22:19 UTC
*** Bug 1476234 has been marked as a duplicate of this bug. ***