Do not Sync ProviderFailed Pod Status (#227)

This commit is contained in:
Robbie Zhang
2018-06-18 10:21:09 -07:00
committed by GitHub
parent 5286869440
commit 027b76651d

View File

@@ -28,6 +28,10 @@ import (
"k8s.io/client-go/tools/clientcmd"
)
const (
PodStatusReason_ProviderFailed = "ProviderFailed"
)
// Server masquarades itself as a kubelet and allows for the virtual node to be backed by non-vm/node providers.
type Server struct {
nodeName string
@@ -331,7 +335,7 @@ func (s *Server) createPod(pod *corev1.Pod) error {
if origErr := s.provider.CreatePod(pod); origErr != nil {
pod.ResourceVersion = "" // Blank out resource version to prevent object has been modified error
pod.Status.Phase = corev1.PodFailed
pod.Status.Reason = "ProviderFailed"
pod.Status.Reason = PodStatusReason_ProviderFailed
pod.Status.Message = origErr.Error()
_, err := s.k8sClient.CoreV1().Pods(pod.Namespace).UpdateStatus(pod)
@@ -377,6 +381,10 @@ func (s *Server) updatePodStatuses() {
continue
}
if pod.Status.Phase == corev1.PodFailed && pod.Status.Reason == PodStatusReason_ProviderFailed {
continue
}
status, err := s.provider.GetPodStatus(pod.Namespace, pod.Name)
if err != nil {
log.Printf("Error retrieving pod '%s' status from provider: %s\n", pod.Name, err)