Skip to content

Commit 25ad4c2

Browse files
authored
Merge pull request #8011 from jinglinliang/allow-third-party-sts-to-drain
Allow draining when StatefulSet kind has custom API Group
2 parents 43d6fbd + 25af21c commit 25ad4c2

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

cluster-autoscaler/simulator/drainability/rules/replicacount/rule.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ func (r *Rule) Drainable(drainCtx *drainability.DrainContext, pod *apiv1.Pod, _
111111
return drainability.NewBlockedStatus(drain.ControllerNotFound, fmt.Errorf("replication controller for %s/%s is not available, err: %v", pod.Namespace, pod.Name, err))
112112
}
113113
} else if refKind == "StatefulSet" {
114+
if refGroup.Group != "apps" {
115+
// We don't have a listener for the other StatefulSet group.
116+
return drainability.NewUndefinedStatus()
117+
}
118+
114119
ss, err := drainCtx.Listers.StatefulSetLister().StatefulSets(controllerNamespace).Get(controllerRef.Name)
115120

116121
if err != nil && ss == nil {

cluster-autoscaler/simulator/drainability/rules/replicacount/rule_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,30 @@ func TestDrainable(t *testing.T) {
243243
wantReason: drain.ControllerNotFound,
244244
wantError: true,
245245
},
246+
"SS-managed pod by a custom API Group": {
247+
pod: &apiv1.Pod{
248+
ObjectMeta: metav1.ObjectMeta{
249+
Name: "bar",
250+
Namespace: "default",
251+
OwnerReferences: test.GenerateOwnerReferences(statefulset.Name, "StatefulSet", "kruise/v1", ""),
252+
},
253+
Spec: apiv1.PodSpec{
254+
NodeName: "node",
255+
},
256+
},
257+
},
258+
"SS-managed pod by a custom API Group with missing reference": {
259+
pod: &apiv1.Pod{
260+
ObjectMeta: metav1.ObjectMeta{
261+
Name: "bar",
262+
Namespace: "default",
263+
OwnerReferences: test.GenerateOwnerReferences("missing", "StatefulSet", "kruise/v1", ""),
264+
},
265+
Spec: apiv1.PodSpec{
266+
NodeName: "node",
267+
},
268+
},
269+
},
246270
"RS-managed pod": {
247271
pod: &apiv1.Pod{
248272
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)