mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
GC should retry on patch error
This commit is contained in:
@@ -586,3 +586,37 @@ func TestUnblockOwnerReference(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrphanDependentsFailure(t *testing.T) {
|
||||
testHandler := &fakeActionHandler{
|
||||
response: map[string]FakeResponse{
|
||||
"PATCH" + "/api/v1/namespaces/ns1/pods/pod": {
|
||||
409,
|
||||
[]byte{},
|
||||
},
|
||||
},
|
||||
}
|
||||
srv, clientConfig := testServerAndClientConfig(testHandler.ServeHTTP)
|
||||
defer srv.Close()
|
||||
|
||||
gc := setupGC(t, clientConfig)
|
||||
defer close(gc.stop)
|
||||
|
||||
dependents := []*node{
|
||||
{
|
||||
identity: objectReference{
|
||||
OwnerReference: metav1.OwnerReference{
|
||||
Kind: "Pod",
|
||||
APIVersion: "v1",
|
||||
Name: "pod",
|
||||
},
|
||||
Namespace: "ns1",
|
||||
},
|
||||
},
|
||||
}
|
||||
err := gc.orphanDependents(objectReference{}, dependents)
|
||||
expected := `the server reported a conflict (patch pods pod)`
|
||||
if err == nil || !strings.Contains(err.Error(), expected) {
|
||||
t.Errorf("expected error contains text %s, got %v", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user