close file descriptor for apply_network_config lock

Current sysinv-agent can leak file descriptors for lock
apply_network_config.
The sysinv-agent periodically run audit task, in which the file
descriptor of "/run/apply_network_config.lock" is still open
after release.
The fix closes the file descriptor in its release function.

Story: 2002861
Task: 22810

Change-Id: Ie71d3c109513fd01991e1af0d8b48c28cf97e12d
Signed-off-by: Jack Ding <jack.ding@windriver.com>
This commit is contained in:
Jianqiang Shi 2018-06-18 09:29:09 -04:00 committed by Jack Ding
parent bf1101c9af
commit 946afa3cfd

View File

@ -497,6 +497,7 @@ class AgentManager(service.PeriodicService):
""" Release the lock guarding apply_network_config.sh """
if lockfd:
fcntl.flock(lockfd, fcntl.LOCK_UN)
os.close(lockfd)
def ihost_inv_get_and_report(self, icontext):
"""Collect data for an ihost.