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 @@ -2,6 +2,7 @@

## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- Fix ArangoMember race with multiple ArangoDeployments within single namespace
- Allow to define Member Recreation Policy within group

## [1.2.0](https://github.com/arangodb/kube-arangodb/tree/1.2.0) (2021-07-16)
- Enable "Operator Internal Metrics Exporter" by default
Expand Down
20 changes: 20 additions & 0 deletions pkg/apis/deployment/v1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,26 @@ type DeploymentSpec struct {
CommunicationMethod *DeploymentCommunicationMethod `json:"communicationMethod,omitempty"`
}

// GetAllowMemberRecreation returns member recreation policy based on group and settings
func (s *DeploymentSpec) GetAllowMemberRecreation(group ServerGroup) bool {
if s == nil {
return false
}

groupSpec := s.GetServerGroupSpec(group)

switch group {
case ServerGroupDBServers, ServerGroupCoordinators:
if v := groupSpec.AllowMemberRecreation; v == nil {
return true
} else {
return *v
}
default:
return false
}
}

// GetRestoreFrom returns the restore from string or empty string if not set
func (s *DeploymentSpec) GetRestoreFrom() string {
return util.StringOrDefault(s.RestoreFrom)
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 @@ -141,6 +141,8 @@ type ServerGroupSpec struct {
ShutdownDelay *int `json:"shutdownDelay,omitempty"`
// InternalPort define port used in internal communication, can be accessed over localhost via sidecar
InternalPort *int `json:"internalPort,omitempty"`
// AllowMemberRecreation allows to recreate member. Value is used only for Coordinator and DBServer with default to True, for all other groups set to false.
AllowMemberRecreation *bool `json:"allowMemberRecreation,omitempty"`
}

// ServerGroupSpecSecurityContext contains specification for pod security context
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.

10 changes: 7 additions & 3 deletions pkg/apis/deployment/v2alpha1/arango_member_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@

package v2alpha1

import core "k8s.io/api/core/v1"
import (
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
)

type ArangoMemberSpec struct {
Group ServerGroup `json:"group,omitempty"`
ID string `json:"id,omitempty"`
Group ServerGroup `json:"group,omitempty"`
ID string `json:"id,omitempty"`
DeploymentUID types.UID `json:"deploymentUID,omitempty"`

Template *core.PodTemplate `json:"template,omitempty"`
TemplateChecksum string `json:"templateChecksum,omitempty"`
Expand Down
20 changes: 20 additions & 0 deletions pkg/apis/deployment/v2alpha1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,26 @@ type DeploymentSpec struct {
CommunicationMethod *DeploymentCommunicationMethod `json:"communicationMethod,omitempty"`
}

// GetAllowMemberRecreation returns member recreation policy based on group and settings
func (s *DeploymentSpec) GetAllowMemberRecreation(group ServerGroup) bool {
if s == nil {
return false
}

groupSpec := s.GetServerGroupSpec(group)

switch group {
case ServerGroupDBServers, ServerGroupCoordinators:
if v := groupSpec.AllowMemberRecreation; v == nil {
return true
} else {
return *v
}
default:
return false
}
}

// GetRestoreFrom returns the restore from string or empty string if not set
func (s *DeploymentSpec) GetRestoreFrom() string {
return util.StringOrDefault(s.RestoreFrom)
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 @@ -141,6 +141,8 @@ type ServerGroupSpec struct {
ShutdownDelay *int `json:"shutdownDelay,omitempty"`
// InternalPort define port used in internal communication, can be accessed over localhost via sidecar
InternalPort *int `json:"internalPort,omitempty"`
// AllowMemberRecreation allows to recreate member. Value is used only for Coordinator and DBServer with default to True, for all other groups set to false.
AllowMemberRecreation *bool `json:"allowMemberRecreation,omitempty"`
}

// ServerGroupSpecSecurityContext contains specification for pod security context
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.

19 changes: 12 additions & 7 deletions pkg/deployment/reconcile/plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,18 @@ func createPlan(ctx context.Context, log zerolog.Logger, apiObject k8sutil.APIOb
plan = append(plan,
api.NewAction(api.ActionTypeRecreateMember, group, m.ID))
default:
memberLog.Msg("Creating member replacement plan because member has failed")
plan = append(plan,
api.NewAction(api.ActionTypeRemoveMember, group, m.ID),
api.NewAction(api.ActionTypeAddMember, group, ""),
api.NewAction(api.ActionTypeWaitForMemberUp, group, api.MemberIDPreviousAction),
)

if spec.GetAllowMemberRecreation(group) {
memberLog.Msg("Creating member replacement plan because member has failed")
plan = append(plan,
api.NewAction(api.ActionTypeRemoveMember, group, m.ID),
api.NewAction(api.ActionTypeAddMember, group, ""),
api.NewAction(api.ActionTypeWaitForMemberUp, group, api.MemberIDPreviousAction),
)
} else {
memberLog.Msg("Restoring old member. Recreation is disabled for group")
plan = append(plan,
api.NewAction(api.ActionTypeRecreateMember, group, m.ID))
}
}
}
return nil
Expand Down