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
This commit is contained in:
Benjamin Schanzel 2022-01-18 16:35:25 +01:00 committed by Tobias Henkel
parent 4f52386611
commit 7baf066d4f
1 changed files with 3 additions and 2 deletions

View File

@ -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