From e8ae7211dabbd07093f50d6dfb383da3bb14f13d Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 17 Jun 2021 15:14:41 -0400 Subject: [PATCH] deprecate FileLock (#75032) Co-authored-by: flowerysong --- changelogs/fragments/filelock_bye.yml | 2 ++ lib/ansible/module_utils/common/file.py | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/filelock_bye.yml diff --git a/changelogs/fragments/filelock_bye.yml b/changelogs/fragments/filelock_bye.yml new file mode 100644 index 00000000000..69f923284ef --- /dev/null +++ b/changelogs/fragments/filelock_bye.yml @@ -0,0 +1,2 @@ +deprecated_features: + - module_utils' FileLock is scheduled to be removed, it is not used due to its unreliable nature. diff --git a/lib/ansible/module_utils/common/file.py b/lib/ansible/module_utils/common/file.py index 9703ea782eb..93e26b98610 100644 --- a/lib/ansible/module_utils/common/file.py +++ b/lib/ansible/module_utils/common/file.py @@ -19,6 +19,7 @@ import sys from contextlib import contextmanager from ansible.module_utils._text import to_bytes, to_native, to_text from ansible.module_utils.six import b, binary_type +from ansible.module_utils.common.warnings import deprecate try: import selinux @@ -122,6 +123,8 @@ class FileLock: unwanted and/or unexpected behaviour ''' def __init__(self): + deprecate("FileLock is not reliable and has never been used in core for that reason. There is no current alternative that works across POSIX targets", + version='2.16') self.lockfd = None @contextmanager