Skip to content

Commit cbfa934

Browse files
authored
[Feature] Add ARANGODB_OVERRIDE_DETECTED_NUMBER_OF_CORES env (#629)
1 parent 17c8ea8 commit cbfa934

File tree

6 files changed

+42
-4
lines changed

6 files changed

+42
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
44
- Always use JWT Authorized requests in internal communication
55
- Add Operator Maintenance Management feature
6+
- Add support for ARANGODB_OVERRIDE_DETECTED_NUMBER_OF_CORES ArangoDB Environment Variable
67

78
## [1.0.6](https://github.com/arangodb/kube-arangodb/tree/1.0.6) (2020-08-19)
89
- Add Operator Namespaced mode (Alpha)

pkg/apis/deployment/v1/database_spec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package v1
2424

2525
type DatabaseSpec struct {
26+
// Maintenance manage maintenance mode on Cluster side. Requires maintenance feature to be enabled
2627
Maintenance *bool `json:"maintenance,omitempty"`
2728
}
2829

pkg/apis/deployment/v1/deployment_spec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ type DeploymentSpec struct {
9595

9696
ID *ServerIDGroupSpec `json:"id,omitempty"`
9797

98+
// Database holds information about database state, like maintenance mode
9899
Database *DatabaseSpec `json:"database,omitempty"`
99100

100101
Single ServerGroupSpec `json:"single"`

pkg/apis/deployment/v1/server_group_spec.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ type ServerGroupSpec struct {
5454
Resources core.ResourceRequirements `json:"resources,omitempty"`
5555
// OverrideDetectedTotalMemory determines if memory should be overrided based on values in resources.
5656
OverrideDetectedTotalMemory *bool `json:"overrideDetectedTotalMemory,omitempty"`
57+
// OverrideDetectedNumberOfCores determines if number of cores should be overrided based on values in resources.
58+
OverrideDetectedNumberOfCores *bool `json:"overrideDetectedNumberOfCores,omitempty"`
5759
// Tolerations specifies the tolerations added to Pods in this group.
5860
Tolerations []core.Toleration `json:"tolerations,omitempty"`
5961
// Annotations specified the annotations added to Pods in this group.
@@ -368,6 +370,24 @@ func (s ServerGroupSpec) GetProbesSpec() ServerGroupProbesSpec {
368370
return ServerGroupProbesSpec{}
369371
}
370372

373+
// GetOverrideDetectedTotalMemory returns OverrideDetectedTotalMemory with default value (false)
374+
func (s ServerGroupSpec) GetOverrideDetectedTotalMemory() bool {
375+
if s.OverrideDetectedTotalMemory == nil {
376+
return false
377+
}
378+
379+
return *s.OverrideDetectedTotalMemory
380+
}
381+
382+
// OverrideDetectedNumberOfCores returns OverrideDetectedNumberOfCores with default value (false)
383+
func (s ServerGroupSpec) GetOverrideDetectedNumberOfCores() bool {
384+
if s.OverrideDetectedNumberOfCores == nil {
385+
return false
386+
}
387+
388+
return *s.OverrideDetectedNumberOfCores
389+
}
390+
371391
// Validate the given group spec
372392
func (s ServerGroupSpec) Validate(group ServerGroup, used bool, mode DeploymentMode, env Environment) error {
373393
if used {

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/deployment/resources/pod_creator_arangod.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ import (
4242
)
4343

4444
const (
45-
ArangoDExecutor string = "/usr/sbin/arangod"
46-
ArangoDBOverrideDetectedTotalMemoryEnv = "ARANGODB_OVERRIDE_DETECTED_TOTAL_MEMORY"
45+
ArangoDExecutor string = "/usr/sbin/arangod"
46+
ArangoDBOverrideDetectedTotalMemoryEnv = "ARANGODB_OVERRIDE_DETECTED_TOTAL_MEMORY"
47+
ArangoDBOverrideDetectedNumberOfCoresEnv = "ARANGODB_OVERRIDE_DETECTED_NUMBER_OF_CORES"
4748
)
4849

4950
var _ interfaces.PodCreator = &MemberArangoDPod{}
@@ -154,15 +155,24 @@ func (a *ArangoDContainer) GetEnvs() []core.EnvVar {
154155
envs.Add(true, k8sutil.GetLifecycleEnv()...)
155156
}
156157

157-
if util.BoolOrDefault(a.groupSpec.OverrideDetectedTotalMemory, false) {
158-
if a.groupSpec.Resources.Limits != nil {
158+
if a.groupSpec.Resources.Limits != nil {
159+
if a.groupSpec.GetOverrideDetectedTotalMemory() {
159160
if limits, ok := a.groupSpec.Resources.Limits[core.ResourceMemory]; ok {
160161
envs.Add(true, core.EnvVar{
161162
Name: ArangoDBOverrideDetectedTotalMemoryEnv,
162163
Value: fmt.Sprintf("%d", limits.Value()),
163164
})
164165
}
165166
}
167+
168+
if a.groupSpec.GetOverrideDetectedNumberOfCores() {
169+
if limits, ok := a.groupSpec.Resources.Limits[core.ResourceCPU]; ok {
170+
envs.Add(true, core.EnvVar{
171+
Name: ArangoDBOverrideDetectedNumberOfCoresEnv,
172+
Value: fmt.Sprintf("%d", limits.Value()),
173+
})
174+
}
175+
}
166176
}
167177

168178
if len(a.groupSpec.Envs) > 0 {

0 commit comments

Comments
 (0)