summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-08-15 22:59:09 +0000
committerGerrit Code Review <review@openstack.org>2022-08-15 22:59:09 +0000
commitafebbb6a6caae95c5edf56333a191d9c525d4c1d (patch)
tree3cd0704250412fbae7bc549cf8b0c32b82ac18a1
parentbb1b0d5c1108b2b4d21559535e9c120b732e99b2 (diff)
parentd61b9772ff6c5af57d93414bdc0f1a9d62ae35b4 (diff)
downloadzuul-afebbb6a6caae95c5edf56333a191d9c525d4c1d.tar.gz
Merge "Fix zoned executor metric when unzoned is allowed"
-rw-r--r--tests/unit/test_scheduler.py12
-rw-r--r--zuul/executor/server.py4
-rw-r--r--zuul/scheduler.py4
3 files changed, 18 insertions, 2 deletions
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index 5e0385be3..66c508fea 100644
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -226,6 +226,18 @@ class TestSchedulerZoneFallback(ZuulTestCase):
def test_jobs_executed(self):
"Test that jobs are executed and a change is merged per zone"
self.hold_jobs_in_queue = True
+
+ # Validate that the reported executor stats are correct. Since
+ # the executor accepts zoned and unzoned job it should be counted
+ # in both metrics.
+ self.assertReportedStat(
+ 'zuul.executors.online', value='1', kind='g')
+ self.assertReportedStat(
+ 'zuul.executors.unzoned.online', value='1', kind='g')
+ self.assertReportedStat(
+ 'zuul.executors.zone.test-provider_vpn.online',
+ value='1', kind='g')
+
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
A.addApproval('Code-Review', 2)
self.fake_gerrit.addEvent(A.addApproval('Approved', 1))
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index eac7fa7e5..e00612e9e 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -3157,6 +3157,10 @@ class ExecutorServer(BaseMergeServer):
self.allow_unzoned = get_default(self.config, 'executor',
'allow_unzoned', False)
+ # If this executor has no zone configured it is implicitly unzoned
+ if self.zone is None:
+ self.allow_unzoned = True
+
# Those attributes won't change, so it's enough to set them once on the
# component info.
self.component_info.zone = self.zone
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index 272235757..dfc922cf1 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -438,12 +438,12 @@ class Scheduler(threading.Thread):
mergers_online = 0
for executor_component in self.component_registry.all("executor"):
- if executor_component.allow_unzoned or not executor_component.zone:
+ if executor_component.allow_unzoned:
if executor_component.state == BaseComponent.RUNNING:
executors_unzoned_online += 1
if executor_component.accepting_work:
executors_unzoned_accepting += 1
- else:
+ if executor_component.zone:
zone_stats = zoned_executor_stats.setdefault(
executor_component.zone,
executor_stats_default.copy())