Skip to content

Commit 916eaec

Browse files
Catch OSError in ConfigManagerActor _read_config method
Becasuse: * not all files in self._config_paths might exists * catching the watchfiles signal and file reading happen in separate async thread and the file could be removed between signal detection and file reading. This prevents unexpected actor crash. Signed-off-by: Elzbieta Kotulska <[email protected]>
1 parent 9cec69a commit 916eaec

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/frequenz/sdk/config/_config_managing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ def _read_config(self) -> abc.Mapping[str, Any]:
130130
except ValueError as err:
131131
_logger.error("%s: Can't read config file, err: %s", self, err)
132132
error_count += 1
133+
except OSError as err:
134+
# It is ok for config file to don't exist.
135+
_logger.error(
136+
"%s: Error reading config file %s (%s). Ignoring it.",
137+
self,
138+
err,
139+
config_path,
140+
)
141+
error_count += 1
133142

134143
if error_count == len(self._config_paths):
135144
raise ValueError(f"{self}: Can't read any of the config files")

0 commit comments

Comments
 (0)