func()

in ray-on-gke/tpu/kuberay-tpu-webhook/main.go [801:828]


func (t *TPUWebhookServer) addPod(obj interface{}) {
	pod := obj.(*corev1.Pod)
	klog.V(1).InfoS("addPod", "Pod", pod.Namespace+"/"+pod.Name, "Time", time.Now())

	if t.lastAdmitted == "" {
		// There is not a pending TPU worker Pod to the informer cache, unblock if waiting and return
		for t.waiting > 0 {
			t.wg.Done()
			t.waiting -= 1
		}
		return
	}
	if t.waiting == 0 {
		// Webhook is not waiting, no-op
		return
	}
	// Check if Pod in cache is the last admitted TPU Pod
	isLastAdmitted, err := t.isLastAdmittedPod(pod)
	if err != nil {
		klog.Errorf("Invalid addPod: %s", err)
		return
	}
	if isLastAdmitted {
		// Informer cache has been updated, unblock the next Mutate call
		t.wg.Done()
		t.waiting -= 1
	}
}