Skip to content

Commit c786630

Browse files
authored
[Feature] SchedulerName Pod Customization (#794)
1 parent 8a60d17 commit c786630

File tree

11 files changed

+132
-5
lines changed

11 files changed

+132
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
- Changing the topics' log level without restarting the container.
1010
When the topic is removed from the argument list then it will not
1111
be turned off in the ArangoDB automatically.
12-
12+
- Allow to customize SchedulerName inside Member Pod
13+
1314
## [1.2.2](https://github.com/arangodb/kube-arangodb/tree/1.2.2) (2021-09-09)
1415
- Update 'github.com/arangodb/arangosync-client' dependency to v0.7.0
1516
- Add HighPriorityPlan to ArangoDeployment Status

pkg/apis/deployment/v1/server_group_spec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ type ServerGroupSpec struct {
8181
Args []string `json:"args,omitempty"`
8282
// Entrypoint overrides container executable
8383
Entrypoint *string `json:"entrypoint,omitempty"`
84+
// SchedulerName define scheduler name used for group
85+
SchedulerName *string `json:"schedulerName,omitempty"`
8486
// StorageClassName specifies the classname for storage of the servers.
8587
StorageClassName *string `json:"storageClassName,omitempty"`
8688
// Resources holds resource requests & limits

pkg/apis/deployment/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/deployment/v2alpha1/plan.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (a ActionType) String() string {
4949
// Priority returns plan priority
5050
func (a ActionType) Priority() ActionPriority {
5151
switch a {
52-
case ActionTypeMemberPhaseUpdate, ActionTypeMemberRIDUpdate, ActionTypeSetMemberCondition, ActionTypeBootstrapSetAgencyInfo:
52+
case ActionTypeMemberPhaseUpdate, ActionTypeMemberRIDUpdate, ActionTypeSetMemberCondition:
5353
return ActionPriorityHigh
5454
default:
5555
return ActionPriorityNormal
@@ -165,8 +165,6 @@ const (
165165
ActionTypeArangoMemberUpdatePodSpec ActionType = "ArangoMemberUpdatePodSpec"
166166
// ActionTypeArangoMemberUpdatePodStatus updates pod spec
167167
ActionTypeArangoMemberUpdatePodStatus ActionType = "ArangoMemberUpdatePodStatus"
168-
// ActionTypeBootstrapSetAgencyInfo set agency info into state
169-
ActionTypeBootstrapSetAgencyInfo ActionType = "BootstrapSetAgencyInfo"
170168

171169
// Runtime Updates
172170
// ActionTypeRuntimeContainerImageUpdate updates container image in runtime

pkg/apis/deployment/v2alpha1/server_group_spec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ type ServerGroupSpec struct {
8181
Args []string `json:"args,omitempty"`
8282
// Entrypoint overrides container executable
8383
Entrypoint *string `json:"entrypoint,omitempty"`
84+
// SchedulerName define scheduler name used for group
85+
SchedulerName *string `json:"schedulerName,omitempty"`
8486
// StorageClassName specifies the classname for storage of the servers.
8587
StorageClassName *string `json:"storageClassName,omitempty"`
8688
// Resources holds resource requests & limits

pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/deployment/resources/pod_creator_arangod.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,10 @@ func (m *MemberArangoDPod) createMetricsExporterSidecarExternalExporter() *core.
571571
func (m *MemberArangoDPod) ApplyPodSpec(p *core.PodSpec) error {
572572
p.SecurityContext = m.groupSpec.SecurityContext.NewPodSecurityContext()
573573

574+
if s := m.groupSpec.SchedulerName; s != nil {
575+
p.SchedulerName = *s
576+
}
577+
574578
return nil
575579
}
576580

pkg/deployment/resources/pod_creator_sync.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ func (m *MemberSyncPod) Validate(cachedStatus interfaces.Inspector) error {
315315
}
316316

317317
func (m *MemberSyncPod) ApplyPodSpec(spec *core.PodSpec) error {
318+
if s := m.groupSpec.SchedulerName; s != nil {
319+
spec.SchedulerName = *s
320+
}
321+
318322
return nil
319323
}
320324

pkg/deployment/rotation/arangod.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2020 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package rotation
22+
23+
import (
24+
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
25+
core "k8s.io/api/core/v1"
26+
)
27+
28+
func podCompare(_ api.DeploymentSpec, _ api.ServerGroup, spec, status *core.PodSpec) compareFunc {
29+
return func(builder api.ActionBuilder) (mode Mode, plan api.Plan, err error) {
30+
if spec.SchedulerName != status.SchedulerName {
31+
status.SchedulerName = spec.SchedulerName
32+
mode = mode.And(SilentRotation)
33+
}
34+
35+
return
36+
}
37+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2020-2021 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
// Author Adam Janikowski
21+
//
22+
23+
package rotation
24+
25+
import (
26+
"testing"
27+
28+
core "k8s.io/api/core/v1"
29+
)
30+
31+
func Test_ArangoD_SchedulerName(t *testing.T) {
32+
testCases := []TestCase{
33+
{
34+
name: "Change SchedulerName from Empty",
35+
spec: buildPodSpec(func(pod *core.PodTemplateSpec) {
36+
pod.Spec.SchedulerName = ""
37+
}),
38+
status: buildPodSpec(func(pod *core.PodTemplateSpec) {
39+
pod.Spec.SchedulerName = "new"
40+
}),
41+
42+
expectedMode: SilentRotation,
43+
},
44+
{
45+
name: "Change SchedulerName into Empty",
46+
spec: buildPodSpec(func(pod *core.PodTemplateSpec) {
47+
pod.Spec.SchedulerName = "new"
48+
}),
49+
status: buildPodSpec(func(pod *core.PodTemplateSpec) {
50+
pod.Spec.SchedulerName = ""
51+
}),
52+
53+
expectedMode: SilentRotation,
54+
},
55+
{
56+
name: "SchedulerName equals",
57+
spec: buildPodSpec(func(pod *core.PodTemplateSpec) {
58+
pod.Spec.SchedulerName = ""
59+
}),
60+
status: buildPodSpec(func(pod *core.PodTemplateSpec) {
61+
pod.Spec.SchedulerName = ""
62+
}),
63+
64+
expectedMode: SkippedRotation,
65+
},
66+
}
67+
68+
runTestCases(t)(testCases...)
69+
}

0 commit comments

Comments
 (0)