diff --git a/orca/common/clients/istio/client.py b/orca/common/clients/istio/client.py index 38ad3db..9fa10fe 100644 --- a/orca/common/clients/istio/client.py +++ b/orca/common/clients/istio/client.py @@ -22,19 +22,19 @@ def get(kind): client = k8s.ClientFactory.get() if kind == 'virtual_service': return k8s.CustomResourceProxy( - client.CustomObjectsApi().list_cluster_custom_object, + 'virtual_service', client.CustomObjectsApi().list_cluster_custom_object, group="networking.istio.io", version="v1alpha3", plural="virtualservices") elif kind == 'destination_rule': return k8s.CustomResourceProxy( - client.CustomObjectsApi().list_cluster_custom_object, + 'destination_rule', client.CustomObjectsApi().list_cluster_custom_object, group="networking.istio.io", version="v1alpha3", plural="destinationrules") elif kind == 'gateway': return k8s.CustomResourceProxy( - client.CustomObjectsApi().list_cluster_custom_object, + 'gateway', client.CustomObjectsApi().list_cluster_custom_object, group="networking.istio.io", version="v1alpha3", plural="gateways") diff --git a/orca/common/clients/k8s/client.py b/orca/common/clients/k8s/client.py index 5910e10..a3dd445 100644 --- a/orca/common/clients/k8s/client.py +++ b/orca/common/clients/k8s/client.py @@ -36,48 +36,51 @@ def get(kind): client = ClientFactory.get() if kind == 'pod': return ResourceProxy( - client.CoreV1Api().list_pod_for_all_namespaces) + 'pod', client.CoreV1Api().list_pod_for_all_namespaces) elif kind == 'service': return ResourceProxy( - client.CoreV1Api().list_service_for_all_namespaces) + 'service', client.CoreV1Api().list_service_for_all_namespaces) elif kind == 'endpoints': return ResourceProxy( - client.CoreV1Api().list_endpoints_for_all_namespaces) + 'endpoints', client.CoreV1Api().list_endpoints_for_all_namespaces) elif kind == 'config_map': return ResourceProxy( - client.CoreV1Api().list_config_map_for_all_namespaces) + 'config_map', client.CoreV1Api().list_config_map_for_all_namespaces) elif kind == 'secret': return ResourceProxy( - client.CoreV1Api().list_secret_for_all_namespaces) + 'secret', client.CoreV1Api().list_secret_for_all_namespaces) elif kind == 'node': return ResourceProxy( - client.CoreV1Api().list_node) + 'node', client.CoreV1Api().list_node) elif kind == 'deployment': return ResourceProxy( - client.AppsV1Api().list_deployment_for_all_namespaces) + 'deployment', client.AppsV1Api().list_deployment_for_all_namespaces) elif kind == 'stateful_set': return ResourceProxy( - client.AppsV1Api().list_stateful_set_for_all_namespaces) + 'stateful_set', client.AppsV1Api().list_stateful_set_for_all_namespaces) elif kind == 'daemon_set': return ResourceProxy( - client.AppsV1Api().list_daemon_set_for_all_namespaces) + 'daemon_set', client.AppsV1Api().list_daemon_set_for_all_namespaces) elif kind == 'replica_set': return ResourceProxy( + 'replica_set', client.ExtensionsV1beta1Api().list_replica_set_for_all_namespaces) elif kind == 'storage_class': return ResourceProxy( - client.StorageV1Api().list_storage_class) + 'storage_class', client.StorageV1Api().list_storage_class) elif kind == 'persistent_volume': return ResourceProxy( - client.CoreV1Api().list_persistent_volume) + 'persistent_volume', client.CoreV1Api().list_persistent_volume) elif kind == 'persistent_volume_claim': return ResourceProxy( + 'persistent_volume_claim', client.CoreV1Api().list_persistent_volume_claim_for_all_namespaces) elif kind == 'namespace': return ResourceProxy( - client.CoreV1Api().list_namespace) + 'namespace', client.CoreV1Api().list_namespace) elif kind == 'horizontal_pod_autoscaler': return ResourceProxy( + 'horizontal_pod_autoscaler', client.AutoscalingV1Api().list_horizontal_pod_autoscaler_for_all_namespaces) else: raise Exception("Unknown kind %s" % kind) @@ -85,7 +88,8 @@ def get(kind): class ResourceProxy(object): - def __init__(self, list_fn): + def __init__(self, kind, list_fn): + self._kind = kind self._list_fn = list_fn def get_all(self): @@ -93,6 +97,7 @@ def get_all(self): def watch(self): while True: + LOG.debug("Restarting watch for resource kind: %s", self._kind) for event in self._watch_resource(): event_type, event_obj = event['type'], event['object'] @@ -118,8 +123,8 @@ def _watch_resource(self): class CustomResourceProxy(ResourceProxy): - def __init__(self, list_fn, group, version, plural): - super().__init__(list_fn) + def __init__(self, kind, list_fn, group, version, plural): + super().__init__(kind, list_fn) self._group = group self._version = version self._plural = plural