Skip to content

Commit

Permalink
Allow for zones / pools with no attributes
Browse files Browse the repository at this point in the history
if a zone or a pool with no attributes use passed
to the `attribute` filter, we can get a RelationNotLoaded
error, this catches the error, and adds an empty dict in
place.

Change-Id: Iac405643d119feb95f6d0931c5ba6935e899a9f6
Closes-Bug: #1639748
(cherry picked from commit 438e39e)
  • Loading branch information
grahamhayes authored and Carthaca committed Feb 1, 2017
1 parent 1e09a62 commit c7dc4fa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions designate/scheduler/filters/attribute_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from oslo_log import log as logging
from oslo_utils.strutils import bool_from_string

from designate import exceptions
from designate.objects import PoolAttributeList
from designate.scheduler.filters import base

Expand Down Expand Up @@ -57,11 +58,16 @@ class AttributeFilter(base.Filter):

def filter(self, context, pools, zone):

zone_attributes = zone.attributes.to_dict()
try:
zone_attributes = zone.attributes.to_dict()
except exceptions.RelationNotLoaded:
zone_attributes = {}

def evaluate_pool(pool):

pool_attributes = pool.attributes.to_dict()
try:
pool_attributes = pool.attributes.to_dict()
except exceptions.RelationNotLoaded:
pool_attributes = {}

# Check if the keys requested exist in this pool
if not {key for key in six.iterkeys(pool_attributes)}.issuperset(
Expand Down

0 comments on commit c7dc4fa

Please sign in to comment.