Skip to content

Commit

Permalink
Fix long stop time
Browse files Browse the repository at this point in the history
Signed-off-by: shaoyue.chen <[email protected]>
  • Loading branch information
haorenfsa committed Jan 23, 2024
1 parent 4ab1ff2 commit 1e074e6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
6 changes: 0 additions & 6 deletions pkg/controllers/component_condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package controllers
import (
"context"
"fmt"
"time"

"github.com/milvus-io/milvus-operator/apis/milvus.io/v1beta1"
"github.com/milvus-io/milvus-operator/pkg/util/rest"
Expand Down Expand Up @@ -180,8 +179,6 @@ var CheckMilvusStopped = func(ctx context.Context, cli client.Client, mc v1beta1
return true, nil
}

var gracefulStopTimeout = time.Second * 30

func ExecKillIfTerminatingTooLong(ctx context.Context, podList *corev1.PodList) error {
// we use kubectl exec to kill milvus process, because tini ignore SIGKILL
cli := rest.GetRestClient()
Expand All @@ -190,9 +187,6 @@ func ExecKillIfTerminatingTooLong(ctx context.Context, podList *corev1.PodList)
if pod.DeletionTimestamp == nil {
continue
}
if time.Since(pod.DeletionTimestamp.Time) < gracefulStopTimeout {
continue
}
// kill milvus process
logger := ctrl.LoggerFrom(ctx)
containerName := pod.Labels[AppLabelComponent]
Expand Down
7 changes: 0 additions & 7 deletions pkg/controllers/component_condition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,6 @@ func TestExecKillIfTerminatingTooLong(t *testing.T) {
assert.NoError(t, err)
})

t.Run("delete sent, but not timeout", func(t *testing.T) {
pods.Items[0].DeletionTimestamp = &metav1.Time{Time: time.Now()}
pods.Items[1].DeletionTimestamp = &metav1.Time{Time: time.Now()}
err := ExecKillIfTerminatingTooLong(ctx, pods)
assert.NoError(t, err)
})

t.Run("kill ok", func(t *testing.T) {
pods.Items[0].DeletionTimestamp = &metav1.Time{Time: time.Now().Add(-time.Hour)}
pods.Items[1].DeletionTimestamp = &metav1.Time{Time: time.Now().Add(-time.Hour)}
Expand Down

0 comments on commit 1e074e6

Please sign in to comment.