zuul/tests/fixtures/config/tenant-parser/extra.yaml
James E. Blair 5b851c14f2 Fix multi-tenant caching of extra config files
The cache of unparsed config data holds all of the config objects
on a project-branch, for all of the tenants.  That works as long
as all of the tenants load the same config files.  With the addition
of the extra-config-paths tenant option, different tenants may now
see different configuration files for the same project-branch.
Because the cache did not account for that, the data for the last
tenant to load a project-branch is what would be cached.

To correct this, make the global unparsed config cache aware of
which paths have been searched in constructing it, and cache each
file individually.  This allows the cache to continue to be
efficient across systems with large tenants where the same repos
appear multiple times, in that each configuration object will
still be stored only once.  However, by storing them along with
their files, the unparsed config for each tenant can be created
from the cache, even if the cache contains more files than that
tenant should see.  Because the cache remembers which files have
been searched, we can determine whether the cache results from a
prior tenant are valid for a later one, or if the later one is
meant to search more files, we can run another cat job and fetch
the larger set of files and expand the cache.

A unit test is adjusted to add a tenant which loads fewer files
before one which loads more to verify that the cache expands
appropriately when loading the second tenant.

Change-Id: I268d89dfaaaf65af2237ec852d706a2752535c4a
2019-07-03 18:43:37 -07:00

23 lines
534 B
YAML

# Load everything in a different tenant first without the extra files,
# to make sure that it doesn't poison the cache.
- tenant:
name: tenant-zero
source:
gerrit:
untrusted-projects:
- org/project1
- org/project2
- tenant:
name: tenant-one
source:
gerrit:
config-projects:
- common-config
untrusted-projects:
- org/project1
- org/project2:
extra-config-paths:
- extra.yaml
- extra.d/