mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +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() {
|
go func() {
|
||||||
defer util.HandleCrash()
|
defer util.HandleCrash()
|
||||||
podID := pod.Name
|
podID := pod.Name
|
||||||
|
podNamespace := pod.Namespace
|
||||||
backoff.wait(podID)
|
backoff.wait(podID)
|
||||||
// Get the pod again; it may have changed/been scheduled already.
|
// Get the pod again; it may have changed/been scheduled already.
|
||||||
pod = &api.Pod{}
|
pod = &api.Pod{}
|
||||||
ctx := api.WithNamespace(api.NewContext(), pod.Namespace)
|
err := factory.Client.Get().Namespace(podNamespace).Path("pods").Path(podID).Do().Into(pod)
|
||||||
err := factory.Client.Get().Namespace(api.Namespace(ctx)).Path("pods").Path(podID).Do().Into(pod)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error getting pod %v for retry: %v; abandoning", podID, err)
|
glog.Errorf("Error getting pod %v for retry: %v; abandoning", podID, err)
|
||||||
return
|
return
|
||||||
|
@ -183,7 +183,7 @@ func TestPollMinions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaultErrorFunc(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{
|
handler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: runtime.EncodeOrDie(latest.Codec, testPod),
|
ResponseBody: runtime.EncodeOrDie(latest.Codec, testPod),
|
||||||
@ -212,7 +212,7 @@ func TestDefaultErrorFunc(t *testing.T) {
|
|||||||
if !exists {
|
if !exists {
|
||||||
continue
|
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) {
|
if e, a := testPod, got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("Expected %v, got %v", e, a)
|
t.Errorf("Expected %v, got %v", e, a)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user