diff --git a/pkg/apis/deployment/v1/deployment_spec.go b/pkg/apis/deployment/v1/deployment_spec.go index 42b914088..85cbf3283 100644 --- a/pkg/apis/deployment/v1/deployment_spec.go +++ b/pkg/apis/deployment/v1/deployment_spec.go @@ -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 { diff --git a/pkg/apis/deployment/v2alpha1/deployment_spec.go b/pkg/apis/deployment/v2alpha1/deployment_spec.go index 67e010dfd..a2e5dff77 100644 --- a/pkg/apis/deployment/v2alpha1/deployment_spec.go +++ b/pkg/apis/deployment/v2alpha1/deployment_spec.go @@ -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 { diff --git a/pkg/deployment/reconcile/action_context.go b/pkg/deployment/reconcile/action_context.go index 5f38e0cc3..3df33fcd7 100644 --- a/pkg/deployment/reconcile/action_context.go +++ b/pkg/deployment/reconcile/action_context.go @@ -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) @@ -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) { diff --git a/pkg/deployment/reconcile/action_recreate_member.go b/pkg/deployment/reconcile/action_recreate_member.go index a3268ff48..b883acfc0 100644 --- a/pkg/deployment/reconcile/action_recreate_member.go +++ b/pkg/deployment/reconcile/action_recreate_member.go @@ -61,18 +61,21 @@ 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 { @@ -80,7 +83,7 @@ func (a *actionRecreateMember) Start(ctx context.Context) (bool, error) { 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) }