Try loading all policy files even if some files are invalid

This change ensures that horizon tries to load all policy files even
if an invalid policy file is found, so that horizon can use as many
policy rules as it can parse.

Closes-Bug: #1917483
Change-Id: I24f8da71460129ee7162af5f307a7e405addb15d
This commit is contained in:
Takashi Kajinami 2021-03-03 00:22:50 +09:00
parent cb7038d07e
commit 82900d727f
1 changed files with 5 additions and 0 deletions

View File

@ -74,6 +74,11 @@ def _get_enforcer():
LOG.warning("Cannot load a policy file '%s' for service '%s' "
"due to IOError. One possible reason is "
"permission denied.", policy_file, service)
except ValueError:
LOG.warning("Cannot load a policy file '%s' for service '%s' "
"due to ValueError. The file might be wrongly "
"formatted.", policy_file, service)
# Ensure enforcer.rules is populated.
if enforcer.rules:
LOG.debug("adding enforcer for service: %s", service)