Skip to content
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
- Changing the topics' log level without restarting the container.
When the topic is removed from the argument list then it will not
be turned off in the ArangoDB automatically.

- Allow to customize SchedulerName inside Member Pod

## [1.2.2](https://github.com/arangodb/kube-arangodb/tree/1.2.2) (2021-09-09)
- Update 'github.com/arangodb/arangosync-client' dependency to v0.7.0
- Add HighPriorityPlan to ArangoDeployment Status
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v1/server_group_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ type ServerGroupSpec struct {
Args []string `json:"args,omitempty"`
// Entrypoint overrides container executable
Entrypoint *string `json:"entrypoint,omitempty"`
// SchedulerName define scheduler name used for group
SchedulerName *string `json:"schedulerName,omitempty"`
// StorageClassName specifies the classname for storage of the servers.
StorageClassName *string `json:"storageClassName,omitempty"`
// Resources holds resource requests & limits
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/deployment/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions pkg/apis/deployment/v2alpha1/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (a ActionType) String() string {
// Priority returns plan priority
func (a ActionType) Priority() ActionPriority {
switch a {
case ActionTypeMemberPhaseUpdate, ActionTypeMemberRIDUpdate, ActionTypeSetMemberCondition, ActionTypeBootstrapSetAgencyInfo:
case ActionTypeMemberPhaseUpdate, ActionTypeMemberRIDUpdate, ActionTypeSetMemberCondition:
return ActionPriorityHigh
default:
return ActionPriorityNormal
Expand Down Expand Up @@ -165,8 +165,6 @@ const (
ActionTypeArangoMemberUpdatePodSpec ActionType = "ArangoMemberUpdatePodSpec"
// ActionTypeArangoMemberUpdatePodStatus updates pod spec
ActionTypeArangoMemberUpdatePodStatus ActionType = "ArangoMemberUpdatePodStatus"
// ActionTypeBootstrapSetAgencyInfo set agency info into state
ActionTypeBootstrapSetAgencyInfo ActionType = "BootstrapSetAgencyInfo"

// Runtime Updates
// ActionTypeRuntimeContainerImageUpdate updates container image in runtime
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v2alpha1/server_group_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ type ServerGroupSpec struct {
Args []string `json:"args,omitempty"`
// Entrypoint overrides container executable
Entrypoint *string `json:"entrypoint,omitempty"`
// SchedulerName define scheduler name used for group
SchedulerName *string `json:"schedulerName,omitempty"`
// StorageClassName specifies the classname for storage of the servers.
StorageClassName *string `json:"storageClassName,omitempty"`
// Resources holds resource requests & limits
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/deployment/resources/pod_creator_arangod.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,10 @@ func (m *MemberArangoDPod) createMetricsExporterSidecarExternalExporter() *core.
func (m *MemberArangoDPod) ApplyPodSpec(p *core.PodSpec) error {
p.SecurityContext = m.groupSpec.SecurityContext.NewPodSecurityContext()

if s := m.groupSpec.SchedulerName; s != nil {
p.SchedulerName = *s
}

return nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/deployment/resources/pod_creator_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ func (m *MemberSyncPod) Validate(cachedStatus interfaces.Inspector) error {
}

func (m *MemberSyncPod) ApplyPodSpec(spec *core.PodSpec) error {
if s := m.groupSpec.SchedulerName; s != nil {
spec.SchedulerName = *s
}

return nil
}

Expand Down
37 changes: 37 additions & 0 deletions pkg/deployment/rotation/arangod.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// DISCLAIMER
//
// Copyright 2020 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.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package rotation

import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
core "k8s.io/api/core/v1"
)

func podCompare(_ api.DeploymentSpec, _ api.ServerGroup, spec, status *core.PodSpec) compareFunc {
return func(builder api.ActionBuilder) (mode Mode, plan api.Plan, err error) {
if spec.SchedulerName != status.SchedulerName {
status.SchedulerName = spec.SchedulerName
mode = mode.And(SilentRotation)
}

return
}
}
69 changes: 69 additions & 0 deletions pkg/deployment/rotation/arangod_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// DISCLAIMER
//
// Copyright 2020-2021 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.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package rotation

import (
"testing"

core "k8s.io/api/core/v1"
)

func Test_ArangoD_SchedulerName(t *testing.T) {
testCases := []TestCase{
{
name: "Change SchedulerName from Empty",
spec: buildPodSpec(func(pod *core.PodTemplateSpec) {
pod.Spec.SchedulerName = ""
}),
status: buildPodSpec(func(pod *core.PodTemplateSpec) {
pod.Spec.SchedulerName = "new"
}),

expectedMode: SilentRotation,
},
{
name: "Change SchedulerName into Empty",
spec: buildPodSpec(func(pod *core.PodTemplateSpec) {
pod.Spec.SchedulerName = "new"
}),
status: buildPodSpec(func(pod *core.PodTemplateSpec) {
pod.Spec.SchedulerName = ""
}),

expectedMode: SilentRotation,
},
{
name: "SchedulerName equals",
spec: buildPodSpec(func(pod *core.PodTemplateSpec) {
pod.Spec.SchedulerName = ""
}),
status: buildPodSpec(func(pod *core.PodTemplateSpec) {
pod.Spec.SchedulerName = ""
}),

expectedMode: SkippedRotation,
},
}

runTestCases(t)(testCases...)
}
2 changes: 1 addition & 1 deletion pkg/deployment/rotation/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func compare(log zerolog.Logger, deploymentSpec api.DeploymentSpec, member api.M

g := generator(deploymentSpec, group, &spec.PodSpec.Spec, &podStatus.Spec)

if m, p, err := compareFuncs(b, g(containersCompare), g(initContainersCompare)); err != nil {
if m, p, err := compareFuncs(b, g(podCompare), g(containersCompare), g(initContainersCompare)); err != nil {
log.Err(err).Msg("Error while getting pod diff")
return SkippedRotation, nil, err
} else {
Expand Down