1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Bugfix] Fix Early Connections for 3.10+ (#1496)

This commit is contained in:
Adam Janikowski 2023-11-20 10:51:16 +01:00 committed by GitHub
parent 40a95a58bf
commit 229d8651fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 3 deletions

View file

@ -15,6 +15,7 @@
- (Feature) (ML) Handlers
- (Feature) Add P0 Compare Func
- (Bugfix) Handle optional taints for Storage Operator
- (Bugfix) Fix Early Connections for 3.10+
## [1.2.35](https://github.com/arangodb/kube-arangodb/tree/1.2.35) (2023-11-06)
- (Maintenance) Update go-driver to v1.6.0, update IsNotFound() checks

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -29,7 +29,8 @@ var version310 = &feature{
description: "Enable support for 3.10 features",
version: "3.10.0",
enterpriseRequired: false,
enabledByDefault: false,
enabledByDefault: true,
hidden: true,
}
func Version310() Feature {

View file

@ -51,7 +51,15 @@ func containersCompare(ds api.DeploymentSpec, g api.ServerGroup, spec, status *c
}
if specContainer.Name == api.ServerGroupReservedContainerNameServer {
if isOnlyLogLevelChanged(specContainer.Command, statusContainer.Command) {
// Lets check if server contains new args
specCommand := cleanServerContainerArgs(specContainer.Command)
statusCommand := cleanServerContainerArgs(statusContainer.Command)
if areArgsEqual(specCommand, statusCommand) {
statusContainer.Command = specContainer.Command
mode = mode.And(compare.SilentRotation)
} else if isOnlyLogLevelChanged(specCommand, statusCommand) {
plan = append(plan, builder.NewAction(api.ActionTypeRuntimeContainerArgsLogLevelUpdate).
AddParam(ContainerName, specContainer.Name))
@ -118,6 +126,35 @@ func containersCompare(ds api.DeploymentSpec, g api.ServerGroup, spec, status *c
})(ds, g, spec, status)
}
func areArgsEqual(a, b []string) bool {
if len(a) != len(b) {
return false
}
for id := range a {
if a[id] != b[id] {
return false
}
}
return true
}
func cleanServerContainerArgs(args []string) []string {
ret := make([]string, 0, len(args))
for _, arg := range args {
// Remove --server.early-connections from args (to calculate)
if arg == "--server.early-connections" || strings.HasPrefix(arg, "--server.early-connections=") {
continue
}
ret = append(ret, arg)
}
return ret
}
func initContainersCompare(deploymentSpec api.DeploymentSpec, group api.ServerGroup, spec, status *core.PodTemplateSpec) compare.Func {
return func(builder api.ActionBuilder) (compare.Mode, api.Plan, error) {
gs := deploymentSpec.GetServerGroupSpec(group)

View file

@ -276,6 +276,33 @@ func Test_Container_LogArgs(t *testing.T) {
runTestCases(t)(testCases...)
}
func Test_Server_Ignored_Args(t *testing.T) {
testCases := []TestCase{
logLevelTestCaseGen("Arg --server.early-connections has been added",
compare.SilentRotation,
[]string{},
[]string{"--server.early-connections"}),
logLevelTestCaseGen("Arg --server.early-connections has been removed",
compare.SilentRotation,
[]string{"--server.early-connections"},
[]string{}),
logLevelTestCaseGen("Arg --server.early-connections has been changed",
compare.SilentRotation,
[]string{"--server.early-connections"},
[]string{"--server.early-connections=false"}),
logLevelTestCaseGen("Arg --server.early-connections has been changed with order",
compare.SilentRotation,
[]string{"--server.early-connections", "--debug"},
[]string{"--debug", "--server.early-connections=false"}),
logLevelTestCaseGen("Arg --server.early-connections has been not changed, but other arg diff",
compare.GracefulRotation,
[]string{"--server.early-connections", "--debug2"},
[]string{"--debug", "--server.early-connections"}),
}
runTestCases(t)(testCases...)
}
func Test_Container_Args(t *testing.T) {
testCases := []TestCase{
{