summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jim@acmegating.com>2022-04-13 16:05:18 -0700
committerJames E. Blair <jim@acmegating.com>2022-04-13 16:09:36 -0700
commit55f77c0f80033909870de1fda435ef856cd67c38 (patch)
tree8c8ae05c6bbdb799174b9be68c1afcdf0142547e
parentd6ace2cec617f77786fd72e847d6c4f00538834c (diff)
downloadzuul-55f77c0f80033909870de1fda435ef856cd67c38.tar.gz
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
-rw-r--r--tests/fixtures/config/empty-config/git/common-config/README1
-rw-r--r--tests/fixtures/config/empty-config/git/common-config/new-zuul.yaml52
-rw-r--r--tests/fixtures/config/empty-config/git/common-config/playbooks/run.yaml2
-rw-r--r--tests/fixtures/config/empty-config/git/org_project/README1
-rw-r--r--tests/fixtures/config/empty-config/main.yaml8
-rw-r--r--tests/unit/test_web.py17
-rwxr-xr-xzuul/web/__init__.py5
7 files changed, 85 insertions, 1 deletions
diff --git a/tests/fixtures/config/empty-config/git/common-config/README b/tests/fixtures/config/empty-config/git/common-config/README
new file mode 100644
index 000000000..9daeafb98
--- /dev/null
+++ b/tests/fixtures/config/empty-config/git/common-config/README
@@ -0,0 +1 @@
+test
diff --git a/tests/fixtures/config/empty-config/git/common-config/new-zuul.yaml b/tests/fixtures/config/empty-config/git/common-config/new-zuul.yaml
new file mode 100644
index 000000000..eecb481ef
--- /dev/null
+++ b/tests/fixtures/config/empty-config/git/common-config/new-zuul.yaml
@@ -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
diff --git a/tests/fixtures/config/empty-config/git/common-config/playbooks/run.yaml b/tests/fixtures/config/empty-config/git/common-config/playbooks/run.yaml
new file mode 100644
index 000000000..f679dceae
--- /dev/null
+++ b/tests/fixtures/config/empty-config/git/common-config/playbooks/run.yaml
@@ -0,0 +1,2 @@
+- hosts: all
+ tasks: []
diff --git a/tests/fixtures/config/empty-config/git/org_project/README b/tests/fixtures/config/empty-config/git/org_project/README
new file mode 100644
index 000000000..9daeafb98
--- /dev/null
+++ b/tests/fixtures/config/empty-config/git/org_project/README
@@ -0,0 +1 @@
+test
diff --git a/tests/fixtures/config/empty-config/main.yaml b/tests/fixtures/config/empty-config/main.yaml
new file mode 100644
index 000000000..208e274b1
--- /dev/null
+++ b/tests/fixtures/config/empty-config/main.yaml
@@ -0,0 +1,8 @@
+- tenant:
+ name: tenant-one
+ source:
+ gerrit:
+ config-projects:
+ - common-config
+ untrusted-projects:
+ - org/project
diff --git a/tests/unit/test_web.py b/tests/unit/test_web.py
index 83620320b..4b696534b 100644
--- a/tests/unit/test_web.py
+++ b/tests/unit/test_web.py
@@ -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'
diff --git a/zuul/web/__init__.py b/zuul/web/__init__.py
index ddcffcd97..b031ee020 100755
--- a/zuul/web/__init__.py
+++ b/zuul/web/__init__.py
@@ -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