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

[Feature] SchedulerName Pod Customization (#794)

This commit is contained in:
Adam Janikowski 2021-09-22 16:08:34 +02:00 committed by GitHub
parent 8a60d17677
commit c786630eea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 132 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -1505,6 +1505,11 @@ func (in *ServerGroupSpec) DeepCopyInto(out *ServerGroupSpec) {
*out = new(string)
**out = **in
}
if in.SchedulerName != nil {
in, out := &in.SchedulerName, &out.SchedulerName
*out = new(string)
**out = **in
}
if in.StorageClassName != nil {
in, out := &in.StorageClassName, &out.StorageClassName
*out = new(string)

View file

@ -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
@ -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

View file

@ -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

View file

@ -1505,6 +1505,11 @@ func (in *ServerGroupSpec) DeepCopyInto(out *ServerGroupSpec) {
*out = new(string)
**out = **in
}
if in.SchedulerName != nil {
in, out := &in.SchedulerName, &out.SchedulerName
*out = new(string)
**out = **in
}
if in.StorageClassName != nil {
in, out := &in.StorageClassName, &out.StorageClassName
*out = new(string)

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}
}

View file

@ -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...)
}

View file

@ -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 {