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:
Kubernetes Prow Robot 2025-04-17 12:11:07 -07:00 committed by GitHub
commit f3dffce01c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View File

@ -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 {

View File

@ -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{