mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
fix pod scheduling retry logic
This commit is contained in:
parent
078bc364b4
commit
48b26e2dfc
@ -183,11 +183,11 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
|
||||
go func() {
|
||||
defer util.HandleCrash()
|
||||
podID := pod.Name
|
||||
podNamespace := pod.Namespace
|
||||
backoff.wait(podID)
|
||||
// Get the pod again; it may have changed/been scheduled already.
|
||||
pod = &api.Pod{}
|
||||
ctx := api.WithNamespace(api.NewContext(), pod.Namespace)
|
||||
err := factory.Client.Get().Namespace(api.Namespace(ctx)).Path("pods").Path(podID).Do().Into(pod)
|
||||
err := factory.Client.Get().Namespace(podNamespace).Path("pods").Path(podID).Do().Into(pod)
|
||||
if err != nil {
|
||||
glog.Errorf("Error getting pod %v for retry: %v; abandoning", podID, err)
|
||||
return
|
||||
|
@ -183,7 +183,7 @@ func TestPollMinions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDefaultErrorFunc(t *testing.T) {
|
||||
testPod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
testPod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "bar"}}
|
||||
handler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: runtime.EncodeOrDie(latest.Codec, testPod),
|
||||
@ -212,7 +212,7 @@ func TestDefaultErrorFunc(t *testing.T) {
|
||||
if !exists {
|
||||
continue
|
||||
}
|
||||
handler.ValidateRequest(t, "/api/"+testapi.Version()+"/pods/foo", "GET", nil)
|
||||
handler.ValidateRequest(t, "/api/"+testapi.Version()+"/pods/foo?namespace=bar", "GET", nil)
|
||||
if e, a := testPod, got; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("Expected %v, got %v", e, a)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user