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
2 changes: 1 addition & 1 deletion pkg/apis/deployment/v1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (s *DeploymentSpec) GetAllowMemberRecreation(group ServerGroup) bool {
groupSpec := s.GetServerGroupSpec(group)

switch group {
case ServerGroupDBServers, ServerGroupCoordinators:
case ServerGroupDBServers, ServerGroupCoordinators, ServerGroupSyncMasters, ServerGroupSyncWorkers:
if v := groupSpec.AllowMemberRecreation; v == nil {
return true
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/deployment/v2alpha1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (s *DeploymentSpec) GetAllowMemberRecreation(group ServerGroup) bool {
groupSpec := s.GetServerGroupSpec(group)

switch group {
case ServerGroupDBServers, ServerGroupCoordinators:
case ServerGroupDBServers, ServerGroupCoordinators, ServerGroupSyncMasters, ServerGroupSyncWorkers:
if v := groupSpec.AllowMemberRecreation; v == nil {
return true
} else {
Expand Down
14 changes: 14 additions & 0 deletions pkg/deployment/reconcile/action_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ type ActionContext interface {
// Returns member status, true when found, or false
// when no such member is found.
GetMemberStatusByID(id string) (api.MemberStatus, bool)
// GetMemberStatusAndGroupByID returns the current member status and group
// for the member with given id.
// Returns member status, true when found, or false
// when no such member is found.
GetMemberStatusAndGroupByID(id string) (api.MemberStatus, api.ServerGroup, bool)
// CreateMember adds a new member to the given group.
// If ID is non-empty, it will be used, otherwise a new ID is created.
CreateMember(ctx context.Context, group api.ServerGroup, id string) (string, error)
Expand Down Expand Up @@ -286,6 +291,15 @@ func (ac *actionContext) GetMemberStatusByID(id string) (api.MemberStatus, bool)
return m, ok
}

// GetMemberStatusAndGroupByID returns the current member status and group
// for the member with given id.
// Returns member status, true when found, or false
// when no such member is found.
func (ac *actionContext) GetMemberStatusAndGroupByID(id string) (api.MemberStatus, api.ServerGroup, bool) {
status, _ := ac.context.GetStatus()
return status.Members.ElementByID(id)
}

// CreateMember adds a new member to the given group.
// If ID is non-empty, it will be used, otherwise a new ID is created.
func (ac *actionContext) CreateMember(ctx context.Context, group api.ServerGroup, id string) (string, error) {
Expand Down
19 changes: 11 additions & 8 deletions pkg/deployment/reconcile/action_recreate_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,29 @@ type actionRecreateMember struct {
// Returns true if the action is completely finished, false in case
// the start time needs to be recorded and a ready condition needs to be checked.
func (a *actionRecreateMember) Start(ctx context.Context) (bool, error) {
m, ok := a.actionCtx.GetMemberStatusByID(a.action.MemberID)
m, g, ok := a.actionCtx.GetMemberStatusAndGroupByID(a.action.MemberID)
if !ok {
return false, errors.Newf("expecting member to be present in list, but it is not")
}

_, err := a.actionCtx.GetPvc(ctx, m.PersistentVolumeClaimName)
if err != nil {
if kubeErrors.IsNotFound(err) {
return false, errors.Newf("PVC is missing %s. Members won't be recreated without old PV", m.PersistentVolumeClaimName)
}
switch g {
case api.ServerGroupDBServers, api.ServerGroupAgents: // Only DBServers and Agents use persistent data
_, err := a.actionCtx.GetPvc(ctx, m.PersistentVolumeClaimName)
if err != nil {
if kubeErrors.IsNotFound(err) {
return false, errors.Newf("PVC is missing %s. Members won't be recreated without old PV", m.PersistentVolumeClaimName)
}

return false, errors.WithStack(err)
return false, errors.WithStack(err)
}
}

if m.Phase == api.MemberPhaseFailed {
// Change cluster phase to ensure it wont be removed
m.Phase = api.MemberPhaseNone
}

if err = a.actionCtx.UpdateMember(ctx, m); err != nil {
if err := a.actionCtx.UpdateMember(ctx, m); err != nil {
return false, errors.WithStack(err)
}

Expand Down