diff --git a/cluster-autoscaler/simulator/drainability/rules/replicacount/rule.go b/cluster-autoscaler/simulator/drainability/rules/replicacount/rule.go index c256c53b56a75abb1c604d5f5c5543e8a924f16c..4ae35767f2c49d482555ce2f9fcf5a08e9b40f24 100644 --- a/cluster-autoscaler/simulator/drainability/rules/replicacount/rule.go +++ b/cluster-autoscaler/simulator/drainability/rules/replicacount/rule.go @@ -111,6 +111,11 @@ func (r *Rule) Drainable(drainCtx *drainability.DrainContext, pod *apiv1.Pod, _ 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 { diff --git a/cluster-autoscaler/simulator/drainability/rules/replicacount/rule_test.go b/cluster-autoscaler/simulator/drainability/rules/replicacount/rule_test.go index 8a98be0acc687dc1b25eaf966780a0b98b4718ba..74a55973e3453f5bbe0c75fdf8bf99990dfa0040 100644 --- a/cluster-autoscaler/simulator/drainability/rules/replicacount/rule_test.go +++ b/cluster-autoscaler/simulator/drainability/rules/replicacount/rule_test.go @@ -243,6 +243,30 @@ func TestDrainable(t *testing.T) { wantReason: drain.ControllerNotFound, wantError: true, }, + "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{