The master resource cache was previously only invalidated at the start
of an audit cycle. Since sync and audit tasks can be handled by
different workers, a worker that only performs syncs could use a stale
cache for an extended period.
This commit introduces a time-based expiry for the cache, set to the
audit check interval (300 seconds). The cache is now reset if it's
older than the expiry time. This check is performed at the beginning
of each sync and audit, ensuring cache freshness across all workers.
Test Plan:
- PASS: Soak subcloud audits and verify the cache is forcibly reset
at the start of each audit cycle.
- PASS: After an audit, create new Keystone roles using dcorch's
proxy. Verify that subsequent sync operations on workers
with expired caches trigger a cache reset, while workers
that recently ran an audit do not reset their cache until
it expires.
- PASS: Create a new identity resource right after the audit in a
scale environment. Verify it correctly resets the cache
after not finding the resource but also doesn't reset if
the previous reset was performed less than 5 seconds before.
Closes-bug: 2119981
Change-Id: I2859778219814769ccee490b9d6ed5056a4b8028
Signed-off-by: Victor Romano <victor.gluzromano@windriver.com>