diff --git a/cluster-autoscaler/simulator/drainability/rules/replicacount/rule.go b/cluster-autoscaler/simulator/drainability/rules/replicacount/rule.go index e03c6d365e580e01e0471edef7f9dce389d823cc..15d408dd7c4c07c46fa8f914c9f2771ebd0c8d9d 100644 --- a/cluster-autoscaler/simulator/drainability/rules/replicacount/rule.go +++ b/cluster-autoscaler/simulator/drainability/rules/replicacount/rule.go @@ -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 { diff --git a/cluster-autoscaler/simulator/drainability/rules/replicated/rule_test.go b/cluster-autoscaler/simulator/drainability/rules/replicated/rule_test.go index ce2943eb42c7965471c5ad6e7fb948d65ac19d22..44c3dd3a099f46b32fd0ebca23f1e03d249f1d8a 100644 --- a/cluster-autoscaler/simulator/drainability/rules/replicated/rule_test.go +++ b/cluster-autoscaler/simulator/drainability/rules/replicated/rule_test.go @@ -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{