mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Allow to disable member recreation (#761)
This commit is contained in:
parent
2879d36a79
commit
7f350d46ad
9 changed files with 74 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
5
pkg/apis/deployment/v1/zz_generated.deepcopy.go
generated
5
pkg/apis/deployment/v1/zz_generated.deepcopy.go
generated
|
@ -1522,6 +1522,11 @@ func (in *ServerGroupSpec) DeepCopyInto(out *ServerGroupSpec) {
|
|||
*out = new(int)
|
||||
**out = **in
|
||||
}
|
||||
if in.AllowMemberRecreation != nil {
|
||||
in, out := &in.AllowMemberRecreation, &out.AllowMemberRecreation
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1522,6 +1522,11 @@ func (in *ServerGroupSpec) DeepCopyInto(out *ServerGroupSpec) {
|
|||
*out = new(int)
|
||||
**out = **in
|
||||
}
|
||||
if in.AllowMemberRecreation != nil {
|
||||
in, out := &in.AllowMemberRecreation, &out.AllowMemberRecreation
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue