Skip to content

Commit

Permalink
Bump minimum supported version and cleanup logic for unsupported vers…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
SaaldjorMike committed Sep 21, 2023
1 parent 6a05b88 commit 6cd19ea
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 69 deletions.
9 changes: 1 addition & 8 deletions controllers/humiocluster_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

const (
Image = "humio/humio-core:1.82.1"
Image = "humio/humio-core:1.100.0"
HelperImage = "humio/humio-operator-helper:6f11f218c1ff386537d63a3ee0f003249604f131"
targetReplicationFactor = 2
storagePartitionsCount = 24
Expand Down Expand Up @@ -383,13 +383,6 @@ func (hnp HumioNodePool) GetEnvironmentVariables() []corev1.EnvVar {
}

humioVersion, _ := HumioVersionFromString(hnp.GetImage())
if ok, _ := humioVersion.AtLeast(HumioVersionWithDefaultSingleUserAuth); !ok {
envDefaults = append(envDefaults, corev1.EnvVar{
Name: "AUTHENTICATION_METHOD",
Value: "single-user",
})
}

if ok, _ := humioVersion.AtLeast(HumioVersionWithoutOldVhostSelection); !ok {
if EnvVarHasValue(hnp.humioNodeSpec.EnvironmentVariables, "USING_EPHEMERAL_DISKS", "true") &&
EnvVarHasKey(hnp.humioNodeSpec.EnvironmentVariables, "ZOOKEEPER_URL") {
Expand Down
2 changes: 1 addition & 1 deletion controllers/humiocluster_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func Test_constructContainerArgs(t *testing.T) {
&humiov1alpha1.HumioCluster{
Spec: humiov1alpha1.HumioClusterSpec{
HumioNodeSpec: humiov1alpha1.HumioNodeSpec{
Image: fmt.Sprintf("humio/humio-core:%s", HumioVersionWithNewVhostSelection),
Image: fmt.Sprintf("humio/humio-core:%s", HumioVersionMinimumSupported),
EnvironmentVariables: []corev1.EnvVar{
{
Name: "USING_EPHEMERAL_DISKS",
Expand Down
4 changes: 1 addition & 3 deletions controllers/humiocluster_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (
)

const (
HumioVersionMinimumSupported = "1.36.0"
HumioVersionWithDefaultSingleUserAuth = "1.68.0"
HumioVersionWithNewVhostSelection = "1.70.0"
HumioVersionMinimumSupported = "1.70.0"
HumioVersionWithoutOldVhostSelection = "1.80.0"
HumioVersionWithAutomaticPartitionManagement = "1.89.0"
)
Expand Down
54 changes: 20 additions & 34 deletions controllers/suite/clusters/humiocluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ import (
)

const (
oldSupportedHumioVersion = "humio/humio-core:1.56.2"
oldSupportedHumioVersion = "humio/humio-core:1.70.0"
oldUnsupportedHumioVersion = "humio/humio-core:1.18.4"

upgradePatchBestEffortOldVersion = "humio/humio-core:1.82.0"
upgradePatchBestEffortNewVersion = "humio/humio-core:1.82.1"

upgradeRollingBestEffortVersionJumpOldVersion = "humio/humio-core:1.56.3"
upgradeRollingBestEffortVersionJumpOldVersion = "humio/humio-core:1.70.0"
upgradeRollingBestEffortVersionJumpNewVersion = "humio/humio-core:1.76.2"

imageSourceConfigmapOldVersion = upgradePatchBestEffortOldVersion
Expand Down Expand Up @@ -1107,7 +1107,7 @@ var _ = Describe("HumioCluster Controller", func() {
Expect(updatedHumioCluster.Annotations).To(HaveKeyWithValue(revisionKey, "1"))

suite.UsingClusterBy(key.Name, "Updating the cluster image unsuccessfully")
updatedImage := "humio/humio-operator:1.36.7-missing-image"
updatedImage := "humio/humio-operator:1.70.7-missing-image"
Eventually(func() error {
updatedHumioCluster = humiov1alpha1.HumioCluster{}
err := k8sClient.Get(ctx, key, &updatedHumioCluster)
Expand Down Expand Up @@ -1287,7 +1287,7 @@ var _ = Describe("HumioCluster Controller", func() {
}
toCreate := suite.ConstructBasicSingleNodeHumioCluster(key, true)
toCreate.Spec.NodeCount = 2
toCreate.Spec.EnvironmentVariables = suite.FilterZookeeperURLIfVersionIsRecentEnough(controllers.NewHumioNodeManagerFromHumioCluster(toCreate).GetImage(), []corev1.EnvVar{
toCreate.Spec.EnvironmentVariables = []corev1.EnvVar{
{
Name: "test",
Value: "",
Expand Down Expand Up @@ -1320,7 +1320,7 @@ var _ = Describe("HumioCluster Controller", func() {
Name: "HUMIO_OPTS",
Value: "-Dakka.log-config-on-start=on -Dlog4j2.formatMsgNoLookups=true -Dzookeeper.client.secure=false",
},
})
}

suite.UsingClusterBy(key.Name, "Creating the cluster successfully")
ctx := context.Background()
Expand All @@ -1335,7 +1335,7 @@ var _ = Describe("HumioCluster Controller", func() {
}

suite.UsingClusterBy(key.Name, "Updating the environment variable successfully")
updatedEnvironmentVariables := suite.FilterZookeeperURLIfVersionIsRecentEnough(controllers.NewHumioNodeManagerFromHumioCluster(toCreate).GetImage(), []corev1.EnvVar{
updatedEnvironmentVariables := []corev1.EnvVar{
{
Name: "test",
Value: "update",
Expand Down Expand Up @@ -1368,7 +1368,7 @@ var _ = Describe("HumioCluster Controller", func() {
Name: "HUMIO_OPTS",
Value: "-Dakka.log-config-on-start=on -Dlog4j2.formatMsgNoLookups=true -Dzookeeper.client.secure=false",
},
})
}

Eventually(func() error {
updatedHumioCluster = humiov1alpha1.HumioCluster{}
Expand Down Expand Up @@ -1423,7 +1423,7 @@ var _ = Describe("HumioCluster Controller", func() {
toCreate := constructBasicMultiNodePoolHumioCluster(key, true, 1)
toCreate.Spec.NodeCount = 1
toCreate.Spec.NodePools[0].NodeCount = 1
toCreate.Spec.EnvironmentVariables = suite.FilterZookeeperURLIfVersionIsRecentEnough(controllers.NewHumioNodeManagerFromHumioCluster(toCreate).GetImage(), []corev1.EnvVar{
toCreate.Spec.EnvironmentVariables = []corev1.EnvVar{
{
Name: "test",
Value: "",
Expand Down Expand Up @@ -1452,8 +1452,8 @@ var _ = Describe("HumioCluster Controller", func() {
Name: "ENABLE_IOC_SERVICE",
Value: "false",
},
})
toCreate.Spec.NodePools[0].EnvironmentVariables = suite.FilterZookeeperURLIfVersionIsRecentEnough(controllers.NewHumioNodeManagerFromHumioNodePool(toCreate, &toCreate.Spec.NodePools[0]).GetImage(), []corev1.EnvVar{
}
toCreate.Spec.NodePools[0].EnvironmentVariables = []corev1.EnvVar{
{
Name: "test",
Value: "",
Expand Down Expand Up @@ -1482,7 +1482,7 @@ var _ = Describe("HumioCluster Controller", func() {
Name: "ENABLE_IOC_SERVICE",
Value: "false",
},
})
}

suite.UsingClusterBy(key.Name, "Creating the cluster successfully")
ctx := context.Background()
Expand All @@ -1499,7 +1499,7 @@ var _ = Describe("HumioCluster Controller", func() {
}

suite.UsingClusterBy(key.Name, "Updating the environment variable on main node pool successfully")
updatedEnvironmentVariables := suite.FilterZookeeperURLIfVersionIsRecentEnough(controllers.NewHumioNodeManagerFromHumioCluster(toCreate).GetImage(), []corev1.EnvVar{
updatedEnvironmentVariables := []corev1.EnvVar{
{
Name: "test",
Value: "update",
Expand Down Expand Up @@ -1528,7 +1528,7 @@ var _ = Describe("HumioCluster Controller", func() {
Name: "ENABLE_IOC_SERVICE",
Value: "false",
},
})
}
Eventually(func() error {
updatedHumioCluster = humiov1alpha1.HumioCluster{}
err := k8sClient.Get(ctx, key, &updatedHumioCluster)
Expand Down Expand Up @@ -1597,7 +1597,7 @@ var _ = Describe("HumioCluster Controller", func() {
clusterPods, _ = kubernetes.ListPods(ctx, k8sClient, key.Namespace, additionalNodePoolManager.GetPodLabels())

suite.UsingClusterBy(key.Name, "Updating the environment variable on additional node pool successfully")
updatedEnvironmentVariables = suite.FilterZookeeperURLIfVersionIsRecentEnough(controllers.NewHumioNodeManagerFromHumioNodePool(toCreate, &toCreate.Spec.NodePools[0]).GetImage(), []corev1.EnvVar{
updatedEnvironmentVariables = []corev1.EnvVar{
{
Name: "test",
Value: "update",
Expand Down Expand Up @@ -1626,7 +1626,7 @@ var _ = Describe("HumioCluster Controller", func() {
Name: "ENABLE_IOC_SERVICE",
Value: "false",
},
})
}
Eventually(func() error {
updatedHumioCluster = humiov1alpha1.HumioCluster{}
err := k8sClient.Get(ctx, key, &updatedHumioCluster)
Expand Down Expand Up @@ -2241,10 +2241,7 @@ var _ = Describe("HumioCluster Controller", func() {

hnp = controllers.NewHumioNodeManagerFromHumioCluster(&updatedHumioCluster)
expectedContainerArgString := "export CORES=$(getconf _NPROCESSORS_ONLN) && export HUMIO_OPTS=\"$HUMIO_OPTS -XX:ActiveProcessorCount=$(getconf _NPROCESSORS_ONLN)\" && export ZONE=$(cat /shared/availability-zone) && exec bash /app/humio/run.sh"
humioVersion, _ := controllers.HumioVersionFromString(hnp.GetImage())
if ok, _ := humioVersion.AtLeast(controllers.HumioVersionWithNewVhostSelection); !ok {
expectedContainerArgString = "export CORES=$(getconf _NPROCESSORS_ONLN) && export HUMIO_OPTS=\"$HUMIO_OPTS -XX:ActiveProcessorCount=$(getconf _NPROCESSORS_ONLN)\" && export ZONE=$(cat /shared/availability-zone) && export ZOOKEEPER_PREFIX_FOR_NODE_UUID=/humio_$(cat /shared/availability-zone)_ && exec bash /app/humio/run.sh"
}

Eventually(func() []string {
clusterPods, _ = kubernetes.ListPods(ctx, k8sClient, key.Namespace, hnp.GetPodLabels())
if len(clusterPods) > 0 {
Expand All @@ -2257,17 +2254,10 @@ var _ = Describe("HumioCluster Controller", func() {
clusterPods, err := kubernetes.ListPods(ctx, k8sClient, key.Namespace, hnp.GetPodLabels())
Expect(err).ToNot(HaveOccurred())
humioIdx, _ := kubernetes.GetContainerIndexByName(clusterPods[0], controllers.HumioContainerName)
if ok, _ := humioVersion.AtLeast(controllers.HumioVersionWithNewVhostSelection); !ok {
Expect(clusterPods[0].Spec.Containers[humioIdx].Env).To(ContainElement(corev1.EnvVar{
Name: "ZOOKEEPER_URL_FOR_NODE_UUID",
Value: "$(ZOOKEEPER_URL)",
}))
} else {
Expect(clusterPods[0].Spec.Containers[humioIdx].Env).ToNot(ContainElement(corev1.EnvVar{
Name: "ZOOKEEPER_URL_FOR_NODE_UUID",
Value: "$(ZOOKEEPER_URL)",
}))
}
Expect(clusterPods[0].Spec.Containers[humioIdx].Env).ToNot(ContainElement(corev1.EnvVar{
Name: "ZOOKEEPER_URL_FOR_NODE_UUID",
Value: "$(ZOOKEEPER_URL)",
}))
})
})

Expand Down Expand Up @@ -2305,10 +2295,6 @@ var _ = Describe("HumioCluster Controller", func() {
hnp = controllers.NewHumioNodeManagerFromHumioCluster(&updatedHumioCluster)

expectedContainerArgString := "export CORES=$(getconf _NPROCESSORS_ONLN) && export HUMIO_OPTS=\"$HUMIO_OPTS -XX:ActiveProcessorCount=$(getconf _NPROCESSORS_ONLN)\" && export ZONE=$(cat /shared/availability-zone) && exec bash /app/humio/run.sh"
humioVersion, _ := controllers.HumioVersionFromString(hnp.GetImage())
if ok, _ := humioVersion.AtLeast(controllers.HumioVersionWithNewVhostSelection); !ok {
expectedContainerArgString = "export CORES=$(getconf _NPROCESSORS_ONLN) && export HUMIO_OPTS=\"$HUMIO_OPTS -XX:ActiveProcessorCount=$(getconf _NPROCESSORS_ONLN)\" && export ZONE=$(cat /shared/availability-zone) && export ZOOKEEPER_PREFIX_FOR_NODE_UUID=/humio_ && exec bash /app/humio/run.sh"
}
Eventually(func() []string {
clusterPods, _ = kubernetes.ListPods(ctx, k8sClient, key.Namespace, controllers.NewHumioNodeManagerFromHumioCluster(toCreate).GetPodLabels())
if len(clusterPods) > 0 {
Expand Down
18 changes: 2 additions & 16 deletions controllers/suite/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func ConstructBasicNodeSpecForHumioCluster(key types.NamespacedName) humiov1alph
Image: controllers.Image,
ExtraKafkaConfigs: "security.protocol=PLAINTEXT",
NodeCount: 1,
EnvironmentVariables: FilterZookeeperURLIfVersionIsRecentEnough(controllers.Image, []corev1.EnvVar{
EnvironmentVariables: []corev1.EnvVar{
{
Name: "ZOOKEEPER_URL",
Value: "humio-cp-zookeeper-0.humio-cp-zookeeper-headless.default:2181",
Expand Down Expand Up @@ -210,7 +210,7 @@ func ConstructBasicNodeSpecForHumioCluster(key types.NamespacedName) humiov1alph
Name: "HUMIO_OPTS",
Value: "-Dakka.log-config-on-start=on -Dlog4j2.formatMsgNoLookups=true -Dzookeeper.client.secure=false",
},
}),
},
DataVolumePersistentVolumeClaimSpecTemplate: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteOnce,
Expand All @@ -233,20 +233,6 @@ func ConstructBasicNodeSpecForHumioCluster(key types.NamespacedName) humiov1alph
return nodeSpec
}

func FilterZookeeperURLIfVersionIsRecentEnough(image string, envVars []corev1.EnvVar) []corev1.EnvVar {
var filteredEnvVars []corev1.EnvVar
for _, envVar := range envVars {
humioVersion, _ := controllers.HumioVersionFromString(image)

if ok, _ := humioVersion.AtLeast(controllers.HumioVersionWithNewVhostSelection); ok &&
strings.HasPrefix(envVar.Name, "ZOOKEEPER_") {
continue
}
filteredEnvVars = append(filteredEnvVars, envVar)
}
return filteredEnvVars
}

func ConstructBasicSingleNodeHumioCluster(key types.NamespacedName, useAutoCreatedLicense bool) *humiov1alpha1.HumioCluster {
humioCluster := &humiov1alpha1.HumioCluster{
ObjectMeta: metav1.ObjectMeta{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/go-logr/zapr v1.2.3
github.com/google/go-cmp v0.5.9
github.com/google/martian v2.1.0+incompatible
github.com/humio/cli v0.32.1
github.com/humio/cli v0.32.3
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.11-0.20230807134635-babe25fc5472
github.com/prometheus/client_golang v1.14.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/humio/cli v0.32.1 h1:0jLc6+i4Ur/9vrsdQQnj2mjhwSECk3x6xzZ8I9irfHU=
github.com/humio/cli v0.32.1/go.mod h1:I4yilQO5wI6uc7NMLmKSGFATY3AZddCbehIvjESK8WQ=
github.com/humio/cli v0.32.3 h1:iBodQTpwGuadyg9zwCc5zXWNvFELxNxH6M08MO1Y+Ho=
github.com/humio/cli v0.32.3/go.mod h1:I4yilQO5wI6uc7NMLmKSGFATY3AZddCbehIvjESK8WQ=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
Expand Down
4 changes: 2 additions & 2 deletions images/helper/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/humio/humio-operator/images/helper
go 1.20

require (
github.com/humio/cli v0.32.1
github.com/cli/shurcooL-graphql v0.0.3
github.com/humio/cli v0.32.3
k8s.io/api v0.26.8
k8s.io/apimachinery v0.26.8
k8s.io/client-go v0.26.8
)

require (
github.com/cli/shurcooL-graphql v0.0.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
Expand Down
4 changes: 2 additions & 2 deletions images/helper/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/humio/cli v0.32.1 h1:0jLc6+i4Ur/9vrsdQQnj2mjhwSECk3x6xzZ8I9irfHU=
github.com/humio/cli v0.32.1/go.mod h1:I4yilQO5wI6uc7NMLmKSGFATY3AZddCbehIvjESK8WQ=
github.com/humio/cli v0.32.3 h1:iBodQTpwGuadyg9zwCc5zXWNvFELxNxH6M08MO1Y+Ho=
github.com/humio/cli v0.32.3/go.mod h1:I4yilQO5wI6uc7NMLmKSGFATY3AZddCbehIvjESK8WQ=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
Expand Down

0 comments on commit 6cd19ea

Please sign in to comment.