Skip to content
Snippets Groups Projects
Commit c99280d3 authored by Jack Francis's avatar Jack Francis
Browse files

Allow draining when StatefulSet kind has custom API Group

parent 0e856f58
Branches
Tags
No related merge requests found
...@@ -110,6 +110,10 @@ func (r *Rule) Drainable(drainCtx *drainability.DrainContext, pod *apiv1.Pod) dr ...@@ -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)) 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" { } 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) ss, err := drainCtx.Listers.StatefulSetLister().StatefulSets(controllerNamespace).Get(controllerRef.Name)
if err != nil && ss == nil { if err != nil && ss == nil {
......
...@@ -143,6 +143,30 @@ func TestDrainable(t *testing.T) { ...@@ -143,6 +143,30 @@ func TestDrainable(t *testing.T) {
}, },
rcs: []*apiv1.ReplicationController{&rc}, 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": { "RS-managed pod": {
pod: &apiv1.Pod{ pod: &apiv1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment