Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Fix Early Connections for 3.10+ #1496

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pkg/deployment/features/version_3_10.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
39 changes: 38 additions & 1 deletion pkg/deployment/rotation/arangod_containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions pkg/deployment/rotation/arangod_containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down