Merge pull request #8044 from jackfrancis/cherry-pick-8011-to-cluster-autoscaler-release-1.29
Allow draining when StatefulSet kind has custom API Group
This commit is contained in:
commit
f3dffce01c
|
@ -110,6 +110,10 @@ func (r *Rule) Drainable(drainCtx *drainability.DrainContext, pod *apiv1.Pod) dr
|
|||
return drainability.NewBlockedStatus(drain.ControllerNotFound, fmt.Errorf("replication controller for %s/%s is not available, err: %v", pod.Namespace, pod.Name, err))
|
||||
}
|
||||
} else if refKind == "StatefulSet" {
|
||||
if refGroup.Group != "apps" {
|
||||
// We don't have a listener for the other StatefulSet group.
|
||||
return drainability.NewUndefinedStatus()
|
||||
}
|
||||
ss, err := drainCtx.Listers.StatefulSetLister().StatefulSets(controllerNamespace).Get(controllerRef.Name)
|
||||
|
||||
if err != nil && ss == nil {
|
||||
|
|
|
@ -143,6 +143,30 @@ func TestDrainable(t *testing.T) {
|
|||
},
|
||||
rcs: []*apiv1.ReplicationController{&rc},
|
||||
},
|
||||
"SS-managed pod by a custom API Group": {
|
||||
pod: &apiv1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "bar",
|
||||
Namespace: "default",
|
||||
OwnerReferences: test.GenerateOwnerReferences(statefulset.Name, "StatefulSet", "kruise/v1", ""),
|
||||
},
|
||||
Spec: apiv1.PodSpec{
|
||||
NodeName: "node",
|
||||
},
|
||||
},
|
||||
},
|
||||
"SS-managed pod by a custom API Group with missing reference": {
|
||||
pod: &apiv1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "bar",
|
||||
Namespace: "default",
|
||||
OwnerReferences: test.GenerateOwnerReferences("missing", "StatefulSet", "kruise/v1", ""),
|
||||
},
|
||||
Spec: apiv1.PodSpec{
|
||||
NodeName: "node",
|
||||
},
|
||||
},
|
||||
},
|
||||
"RS-managed pod": {
|
||||
pod: &apiv1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
Loading…
Reference in New Issue