Fix background layout updates in zuul-web

Change Ia0a524053a110e8e48f709d219651e2ad9c8513d updated the scheduler
to more aggressively use the file cache, but did not make the corresponding
updates to zuul-web.  This means that configuration changes are not being
reflected in the web UI until the service restarts.

This corrects that and adds a test.

Change-Id: Iebdf485105bd02e57fa0d3db5ba162308b640ca0
This commit is contained in:
James E. Blair
2022-04-13 16:05:18 -07:00
parent d6ace2cec6
commit 55f77c0f80
7 changed files with 85 additions and 1 deletions

View File

@@ -0,0 +1 @@
test

View File

@@ -0,0 +1,52 @@
- pipeline:
name: check
manager: independent
trigger:
gerrit:
- event: patchset-created
- event: comment-added
comment: '^(Patch Set [0-9]+:\n\n)?(?i:recheck)$'
success:
gerrit:
Verified: 1
failure:
gerrit:
Verified: -1
- pipeline:
name: gate
manager: dependent
success-message: Build succeeded (gate).
trigger:
gerrit:
- event: comment-added
approval:
- Approved: 1
success:
gerrit:
Verified: 2
submit: true
failure:
gerrit:
Verified: -2
start:
gerrit:
Verified: 0
precedence: high
- job:
name: base
parent: null
- job:
name: test
run: playbooks/run.yaml
- project:
name: common-config
check:
jobs:
- test
gate:
jobs:
- test

View File

@@ -0,0 +1,2 @@
- hosts: all
tasks: []

View File

@@ -0,0 +1 @@
test

View File

@@ -0,0 +1,8 @@
- tenant:
name: tenant-one
source:
gerrit:
config-projects:
- common-config
untrusted-projects:
- org/project

View File

@@ -1265,6 +1265,23 @@ class TestWebMultiTenant(BaseTestWeb):
sorted(["tenant-one", "tenant-two", "tenant-four"]))
class TestEmptyConfig(BaseTestWeb):
tenant_config_file = 'config/empty-config/main.yaml'
def test_empty_config_startup(self):
# Test that we can bootstrap a tenant with an empty config
resp = self.get_url("api/tenant/tenant-one/jobs").json()
self.assertEqual(len(resp), 1)
self.commitConfigUpdate(
'common-config',
'config/empty-config/git/common-config/new-zuul.yaml')
self.scheds.execute(lambda app: app.sched.reconfigure(app.config))
self.waitUntilSettled()
resp = self.get_url("api/tenant/tenant-one/jobs").json()
self.assertEqual(len(resp), 3)
class TestWebSecrets(BaseTestWeb):
tenant_config_file = 'config/secrets/main.yaml'

View File

@@ -2084,7 +2084,6 @@ class ZuulWeb(object):
tenant_names = set(self.abide.tenants)
tenant_names.update(self.unparsed_abide.tenants.keys())
min_ltimes = defaultdict(lambda: defaultdict(lambda: -1))
for tenant_name in tenant_names:
# Reload the tenant if the layout changed.
if (self.local_layout_state.get(tenant_name)
@@ -2096,11 +2095,15 @@ class ZuulWeb(object):
layout_uuid = layout_state and layout_state.uuid
if layout_state:
min_ltimes = self.tenant_layout_state.getMinLtimes(
layout_state)
branch_cache_min_ltimes = (
layout_state.branch_cache_min_ltimes)
else:
# Consider all project branch caches valid if
# we don't have a layout state.
min_ltimes = defaultdict(
lambda: defaultdict(lambda: -1))
branch_cache_min_ltimes = defaultdict(lambda: -1)
# The tenant will be stored in self.abide.tenants after