From 7baf066d4fc5fc86a1fec910d9bc67eb720da709 Mon Sep 17 00:00:00 2001 From: Benjamin Schanzel Date: Tue, 18 Jan 2022 16:35:25 +0100 Subject: [PATCH] Fix tenant-quota for providers without label quota infos Some providers do not implement the quotaNeededByLabel method, e.g. the static driver. When having tenant-resource-limits enabled, this method gets called to find out the resources needed when fulfilling a node reuquest. In the case of the static driver, this errors out with an AttributeError. To circumvent this, check if the current provider implements the QuotaSupport mixin, and skip any tenant-quota related action if not. Change-Id: I76449379d29e87260884c16bfce4c47093eafb2d --- nodepool/launcher.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nodepool/launcher.py b/nodepool/launcher.py index af7d6510d..cb2de5aef 100644 --- a/nodepool/launcher.py +++ b/nodepool/launcher.py @@ -31,7 +31,7 @@ from nodepool import provider_manager from nodepool import stats from nodepool import config as nodepool_config from nodepool import zk -from nodepool.driver.utils import QuotaInformation +from nodepool.driver.utils import QuotaInformation, QuotaSupport from nodepool.logconfig import get_annotated_logger from nodepool.version import version_info as npd_version_info @@ -168,7 +168,8 @@ class PoolWorker(threading.Thread, stats.StatsReporter): # check tenant quota if the request has a tenant associated # and there are resource limits configured for this tenant check_tenant_quota = req.tenant_name and req.tenant_name \ - in self.nodepool.config.tenant_resource_limits + in self.nodepool.config.tenant_resource_limits \ + and isinstance(pm, QuotaSupport) if check_tenant_quota and not self._hasTenantQuota(req, pm): # Defer request for it to be handled and fulfilled at a later