Merge "Fix labels encode"

This commit is contained in:
Zuul 2018-12-07 11:31:36 +00:00 committed by Gerrit Code Review
commit a84b3930d5
2 changed files with 6 additions and 0 deletions

View File

@ -189,6 +189,9 @@ class NetworkPolicyDriver(base.NetworkPolicyDriver):
cidrs = []
namespace_label = urlencode(namespace_selector[
'matchLabels'])
# NOTE(maysams): K8s API does not accept &, so we need to replace
# it with ',' or '%2C' instead
namespace_label = namespace_label.replace('&', ',')
matching_namespaces = self.kubernetes.get(
'{}/namespaces?labelSelector={}'.format(
constants.K8S_API_BASE, namespace_label)).get('items')

View File

@ -34,6 +34,9 @@ def _get_kuryrnetpolicy_crds(labels=None, namespace='default'):
labels.pop('pod-template-hash', None)
# removing pod-template-hash is necessary to fetch the proper list
labels = urlencode(labels)
# NOTE(maysams): K8s API does not accept &, so we need to replace
# it with ',' or '%2C' instead
labels = labels.replace('&', ',')
knp_path = '{}/{}/kuryrnetpolicies?labelSelector={}'.format(
constants.K8S_API_CRD_NAMESPACES, namespace, labels)
LOG.debug("K8s API Query %s", knp_path)