Skip to content

Commit

Permalink
fix: test InPlacePodVerticalScaling all the time (#7592)
Browse files Browse the repository at this point in the history
  • Loading branch information
free6om authored Jun 21, 2024
1 parent 21d8733 commit 7260d53
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
11 changes: 0 additions & 11 deletions pkg/controller/instanceset/in_place_update_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"reflect"
"strings"

"github.com/rogpeppe/go-internal/semver"
"golang.org/x/exp/slices"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -34,7 +33,6 @@ import (
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/constant"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
"github.com/apecloud/kubeblocks/pkg/dataprotection/utils"
viper "github.com/apecloud/kubeblocks/pkg/viperx"
)

Expand All @@ -47,15 +45,6 @@ const (
)

func supportPodVerticalScaling() bool {
kubeVersion, err := utils.GetKubeVersion()
// if the Kubernetes version is unknown, assume pod vertical scaling is not supported.
if err != nil {
return false
}
if semver.Compare(kubeVersion, "v1.29") >= 0 {
return true
}

return utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling)
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/controller/instanceset/in_place_update_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/version"

"github.com/apecloud/kubeblocks/pkg/constant"
"github.com/apecloud/kubeblocks/pkg/controller/builder"
Expand Down Expand Up @@ -168,9 +167,6 @@ var _ = Describe("instance util test", func() {
Expect(policy).Should(Equal(InPlaceUpdatePolicy))

By("build a pod without revision updated, with basic mutable and resources fields updated")
kubeVersion := viper.GetString(constant.CfgKeyServerInfo)
defer viper.Set(constant.CfgKeyServerInfo, kubeVersion)
viper.Set(constant.CfgKeyServerInfo, version.Info{GitVersion: "v1.29.3"})
pod4 := pod3.DeepCopy()
randInt := rand.Int()
requests := corev1.ResourceList{
Expand All @@ -179,7 +175,7 @@ var _ = Describe("instance util test", func() {
pod4.Spec.Containers[0].Resources.Requests = requests
policy, err = getPodUpdatePolicy(its, pod4)
Expect(err).Should(BeNil())
Expect(policy).Should(Equal(InPlaceUpdatePolicy))
Expect(policy).Should(Equal(RecreatePolicy))

By("build a pod without revision updated, with resources fields updated")
pod5 := pod1.DeepCopy()
Expand All @@ -190,7 +186,7 @@ var _ = Describe("instance util test", func() {
pod5.Spec.Containers[0].Resources.Requests = requests
policy, err = getPodUpdatePolicy(its, pod5)
Expect(err).Should(BeNil())
Expect(policy).Should(Equal(InPlaceUpdatePolicy))
Expect(policy).Should(Equal(RecreatePolicy))

By("build a pod without revision updated, with resources fields updated, with IgnorePodVerticalScaling enabled")
ignorePodVerticalScaling := viper.GetBool(FeatureGateIgnorePodVerticalScaling)
Expand Down

0 comments on commit 7260d53

Please sign in to comment.