コード例 #1
0
 def _ensure_release_lbaas(self, loadbalancer_crd):
     self._drv_lbaas.release_loadbalancer(
         loadbalancer_crd['status'].get('loadbalancer'))
     utils.clean_lb_crd_status(utils.get_res_unique_name(loadbalancer_crd))
     # NOTE(ltomasbo): give some extra time to ensure the Load
     # Balancer VIP is also released
     time.sleep(1)
コード例 #2
0
ファイル: lbaasv2.py プロジェクト: jupierce/kuryr-kubernetes
    def _find_loadbalancer(self, loadbalancer):
        lbaas = clients.get_loadbalancer_client()
        response = lbaas.load_balancers(
            name=loadbalancer['name'],
            project_id=loadbalancer['project_id'],
            vip_address=str(loadbalancer['ip']),
            vip_subnet_id=loadbalancer['subnet_id'],
            provider=loadbalancer['provider'])

        try:
            os_lb = next(response)  # openstacksdk returns a generator
            loadbalancer['id'] = os_lb.id
            loadbalancer['port_id'] = self._get_vip_port(loadbalancer).id
            loadbalancer['provider'] = os_lb.provider
            if os_lb.provisioning_status == 'ERROR':
                self.release_loadbalancer(loadbalancer)
                utils.clean_lb_crd_status(loadbalancer['name'])
                return None
        except (KeyError, StopIteration):
            return None

        return loadbalancer
コード例 #3
0
ファイル: lbaasv2.py プロジェクト: openshift/kuryr-kubernetes
    def _find_loadbalancer(self, loadbalancer):
        lbaas = clients.get_loadbalancer_client()
        request = {
            'project_id': loadbalancer['project_id'],
            'vip_address': str(loadbalancer['ip']),
            'vip_subnet_id': loadbalancer['subnet_id']
        }

        # NOTE(maysams): To make sure we find the api LB managed
        # by CNO, we avoid including the name and provider fields
        # and include them only when the resource was already
        # managed by Kuryr.
        if loadbalancer['name'] != K8S_DEFAULT_SVC_NAME:
            request['name'] = loadbalancer['name']
            request['provider'] = loadbalancer['provider']

        response = lbaas.load_balancers(**request)

        try:
            os_lb = next(response)  # openstacksdk returns a generator
            loadbalancer['id'] = os_lb.id
            loadbalancer['port_id'] = self._get_vip_port(loadbalancer).id
            loadbalancer['provider'] = os_lb.provider
            # NOTE(maysams): the Load Balancer should be removed when
            # has status ERROR or when an upgrade happened and the LB
            # was previously handled by CNO, so it has different name than
            # what is defined on CRD and resources are configured with
            # different protocol.
            if (os_lb.provisioning_status == 'ERROR'
                    or (loadbalancer['name'] == K8S_DEFAULT_SVC_NAME
                        and os_lb.name != K8S_DEFAULT_SVC_NAME)):
                self.release_loadbalancer(loadbalancer)
                utils.clean_lb_crd_status(loadbalancer['name'])
                return None
        except (KeyError, StopIteration):
            return None

        return loadbalancer
コード例 #4
0
ファイル: lbaasv2.py プロジェクト: jupierce/kuryr-kubernetes
    def _wait_for_provisioning(self,
                               loadbalancer,
                               timeout,
                               interval=_LB_STS_POLL_FAST_INTERVAL):
        lbaas = clients.get_loadbalancer_client()

        for remaining in self._provisioning_timer(timeout, interval):
            try:
                response = lbaas.get_load_balancer(loadbalancer['id'])
            except os_exc.ResourceNotFound:
                LOG.debug("Cleaning CRD status for deleted "
                          "loadbalancer %s", loadbalancer['name'])
                utils.clean_lb_crd_status(loadbalancer['name'])
                return None

            status = response.provisioning_status
            if status == 'ACTIVE':
                LOG.debug("Provisioning complete for %(lb)s",
                          {'lb': loadbalancer})
                return loadbalancer
            elif status == 'ERROR':
                LOG.debug("Releasing loadbalancer %s with error status",
                          loadbalancer['id'])
                self.release_loadbalancer(loadbalancer)
                utils.clean_lb_crd_status(loadbalancer['name'])
                return None
            elif status == 'DELETED':
                LOG.debug("Cleaning CRD status for deleted "
                          "loadbalancer %s", loadbalancer['name'])
                utils.clean_lb_crd_status(loadbalancer['name'])
                return None
            else:
                LOG.debug(
                    "Provisioning status %(status)s for %(lb)s, "
                    "%(rem).3gs remaining until timeout", {
                        'status': status,
                        'lb': loadbalancer,
                        'rem': remaining
                    })

        raise k_exc.ResourceNotReady(loadbalancer)