Skip to content

Commit

Permalink
Prevent race condition in replication of configuration
Browse files Browse the repository at this point in the history
Temporary files may be removed while the configuration is being
synchronized. This could lead to sporadic FileNotFoundError exceptions
which our system level tests stumbled upon every now and then.

How it could look like:

```
FileNotFoundError: [Errno 2] No such file or directory: '/omd/sites/int_test/var/check_mk/web/automation/.last_login.mk.new5lqntxh5'a
```

The replication code now deals better with such situations by catching
the exceptions and skipping the file in question.

Change-Id: Iaeaab4b4a2f4753c0268795cfccce1852898b9c8
  • Loading branch information
LarsMichelsen committed Nov 25, 2024
1 parent ea8460a commit 461f0b1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmk/gui/watolib/activate_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2067,17 +2067,20 @@ def _get_replication_dir_config_sync_file_infos_per_inode(

for dir_name in dir_names:
dir_path = os.path.join(root, dir_name)
if (
os.path.exists(dir_path)
and os.path.islink(dir_path)
and not dir_name == GENERAL_DIR_EXCLUDE
):
inode_sync_states[os.stat(dir_path).st_ino] = _get_config_sync_file_info(dir_path)
try:
if os.path.islink(dir_path) and not dir_name == GENERAL_DIR_EXCLUDE:
inode_sync_states[os.stat(dir_path).st_ino] = _get_config_sync_file_info(
dir_path
)
except FileNotFoundError:
pass # Ignore directories vanishing during processing

for file_name in file_names:
file_path = os.path.join(root, file_name)
if os.path.exists(file_path):
try:
inode_sync_states[os.stat(file_path).st_ino] = _get_config_sync_file_info(file_path)
except FileNotFoundError:
pass # Ignore files vanishing during processing


def _prepare_for_activation_tasks(
Expand Down

0 comments on commit 461f0b1

Please sign in to comment.