Merge "CORD-2965 Fix crash when StatefulSet resources encountered"
diff --git a/xos/synchronizer/pull_steps/pull_pods.py b/xos/synchronizer/pull_steps/pull_pods.py
index 4a51fb4..b1cc71d 100644
--- a/xos/synchronizer/pull_steps/pull_pods.py
+++ b/xos/synchronizer/pull_steps/pull_pods.py
@@ -57,7 +57,7 @@
if kind == "ReplicaSet":
resource = self.v1apps.read_namespaced_replica_set(name, trust_domain.name)
elif kind == "StatefulSet":
- resource = self.v1apps.read_namespaced_statefule_set(name, trust_domain.name)
+ resource = self.v1apps.read_namespaced_stateful_set(name, trust_domain.name)
elif kind == "DaemonSet":
resource = self.v1apps.read_namespaced_daemon_set(name, trust_domain.name)
elif kind == "Deployment":
@@ -211,38 +211,41 @@
# For each k8s pod, see if there is an xos pod. If there is not, then create the xos pod.
for (k,pod) in k8s_pods_by_name.items():
- if not k in xos_pods_by_name:
- trust_domain = self.get_trustdomain_from_pod(pod, owner_service=kubernetes_service)
- if not trust_domain:
- log.warning("Unable to determine trust_domain for %s" % k)
- continue
+ try:
+ if not k in xos_pods_by_name:
+ trust_domain = self.get_trustdomain_from_pod(pod, owner_service=kubernetes_service)
+ if not trust_domain:
+ log.warning("Unable to determine trust_domain for %s" % k)
+ continue
- principal = self.get_principal_from_pod(pod, trust_domain)
- slice = self.get_slice_from_pod(pod, trust_domain=trust_domain, principal=principal)
- image = self.get_image_from_pod(pod)
+ principal = self.get_principal_from_pod(pod, trust_domain)
+ slice = self.get_slice_from_pod(pod, trust_domain=trust_domain, principal=principal)
+ image = self.get_image_from_pod(pod)
- if not slice:
- log.warning("Unable to determine slice for %s" % k)
- continue
+ if not slice:
+ log.warning("Unable to determine slice for %s" % k)
+ continue
- xos_pod = KubernetesServiceInstance(name=k,
- pod_ip = pod.status.pod_ip,
- owner = kubernetes_service,
- slice = slice,
- image = image,
- backend_handle = self.obj_to_handle(pod),
- xos_managed = False)
- xos_pod.save()
- xos_pods_by_name[k] = xos_pod
- log.info("Created XOS POD %s" % xos_pod.name)
+ xos_pod = KubernetesServiceInstance(name=k,
+ pod_ip = pod.status.pod_ip,
+ owner = kubernetes_service,
+ slice = slice,
+ image = image,
+ backend_handle = self.obj_to_handle(pod),
+ xos_managed = False)
+ xos_pod.save()
+ xos_pods_by_name[k] = xos_pod
+ log.info("Created XOS POD %s" % xos_pod.name)
- # Check to see if the ip address has changed. This can happen for pods that are managed by XOS. The IP
- # isn't available immediately when XOS creates a pod, but shows up a bit later. So handle that case
- # here.
- xos_pod = xos_pods_by_name[k]
- if (pod.status.pod_ip is not None) and (xos_pod.pod_ip != pod.status.pod_ip):
- xos_pod.pod_ip = pod.status.pod_ip
- xos_pod.save(update_fields = ["pod_ip"])
+ # Check to see if the ip address has changed. This can happen for pods that are managed by XOS. The IP
+ # isn't available immediately when XOS creates a pod, but shows up a bit later. So handle that case
+ # here.
+ xos_pod = xos_pods_by_name[k]
+ if (pod.status.pod_ip is not None) and (xos_pod.pod_ip != pod.status.pod_ip):
+ xos_pod.pod_ip = pod.status.pod_ip
+ xos_pod.save(update_fields = ["pod_ip"])
+ except:
+ log.exception("Failed to process k8s pod", k=k, pod=pod)
# For each xos pod, see if there is no k8s pod. If that's the case, then the pud must have been deleted.
for (k,xos_pod) in xos_pods_by_name.items():