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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- Always use JWT Authorized requests in internal communication
- Add Operator Maintenance Management feature
- Add support for ARANGODB_OVERRIDE_DETECTED_NUMBER_OF_CORES ArangoDB Environment Variable

## [1.0.6](https://github.com/arangodb/kube-arangodb/tree/1.0.6) (2020-08-19)
- Add Operator Namespaced mode (Alpha)
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/deployment/v1/database_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package v1

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

Expand Down
1 change: 1 addition & 0 deletions pkg/apis/deployment/v1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type DeploymentSpec struct {

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

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

Single ServerGroupSpec `json:"single"`
Expand Down
20 changes: 20 additions & 0 deletions pkg/apis/deployment/v1/server_group_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type ServerGroupSpec struct {
Resources core.ResourceRequirements `json:"resources,omitempty"`
// OverrideDetectedTotalMemory determines if memory should be overrided based on values in resources.
OverrideDetectedTotalMemory *bool `json:"overrideDetectedTotalMemory,omitempty"`
// OverrideDetectedNumberOfCores determines if number of cores should be overrided based on values in resources.
OverrideDetectedNumberOfCores *bool `json:"overrideDetectedNumberOfCores,omitempty"`
// Tolerations specifies the tolerations added to Pods in this group.
Tolerations []core.Toleration `json:"tolerations,omitempty"`
// Annotations specified the annotations added to Pods in this group.
Expand Down Expand Up @@ -368,6 +370,24 @@ func (s ServerGroupSpec) GetProbesSpec() ServerGroupProbesSpec {
return ServerGroupProbesSpec{}
}

// GetOverrideDetectedTotalMemory returns OverrideDetectedTotalMemory with default value (false)
func (s ServerGroupSpec) GetOverrideDetectedTotalMemory() bool {
if s.OverrideDetectedTotalMemory == nil {
return false
}

return *s.OverrideDetectedTotalMemory
}

// OverrideDetectedNumberOfCores returns OverrideDetectedNumberOfCores with default value (false)
func (s ServerGroupSpec) GetOverrideDetectedNumberOfCores() bool {
if s.OverrideDetectedNumberOfCores == nil {
return false
}

return *s.OverrideDetectedNumberOfCores
}

// Validate the given group spec
func (s ServerGroupSpec) Validate(group ServerGroup, used bool, mode DeploymentMode, env Environment) error {
if used {
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.

18 changes: 14 additions & 4 deletions pkg/deployment/resources/pod_creator_arangod.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ import (
)

const (
ArangoDExecutor string = "/usr/sbin/arangod"
ArangoDBOverrideDetectedTotalMemoryEnv = "ARANGODB_OVERRIDE_DETECTED_TOTAL_MEMORY"
ArangoDExecutor string = "/usr/sbin/arangod"
ArangoDBOverrideDetectedTotalMemoryEnv = "ARANGODB_OVERRIDE_DETECTED_TOTAL_MEMORY"
ArangoDBOverrideDetectedNumberOfCoresEnv = "ARANGODB_OVERRIDE_DETECTED_NUMBER_OF_CORES"
)

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

if util.BoolOrDefault(a.groupSpec.OverrideDetectedTotalMemory, false) {
if a.groupSpec.Resources.Limits != nil {
if a.groupSpec.Resources.Limits != nil {
if a.groupSpec.GetOverrideDetectedTotalMemory() {
if limits, ok := a.groupSpec.Resources.Limits[core.ResourceMemory]; ok {
envs.Add(true, core.EnvVar{
Name: ArangoDBOverrideDetectedTotalMemoryEnv,
Value: fmt.Sprintf("%d", limits.Value()),
})
}
}

if a.groupSpec.GetOverrideDetectedNumberOfCores() {
if limits, ok := a.groupSpec.Resources.Limits[core.ResourceCPU]; ok {
envs.Add(true, core.EnvVar{
Name: ArangoDBOverrideDetectedNumberOfCoresEnv,
Value: fmt.Sprintf("%d", limits.Value()),
})
}
}
}

if len(a.groupSpec.Envs) > 0 {
Expand Down