Skip to content

Commit eaee230

Browse files
authored
[Bugfix] Add fix for Members without PVC (#763)
1 parent 7f350d4 commit eaee230

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

pkg/apis/deployment/v1/deployment_spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (s *DeploymentSpec) GetAllowMemberRecreation(group ServerGroup) bool {
172172
groupSpec := s.GetServerGroupSpec(group)
173173

174174
switch group {
175-
case ServerGroupDBServers, ServerGroupCoordinators:
175+
case ServerGroupDBServers, ServerGroupCoordinators, ServerGroupSyncMasters, ServerGroupSyncWorkers:
176176
if v := groupSpec.AllowMemberRecreation; v == nil {
177177
return true
178178
} else {

pkg/apis/deployment/v2alpha1/deployment_spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (s *DeploymentSpec) GetAllowMemberRecreation(group ServerGroup) bool {
172172
groupSpec := s.GetServerGroupSpec(group)
173173

174174
switch group {
175-
case ServerGroupDBServers, ServerGroupCoordinators:
175+
case ServerGroupDBServers, ServerGroupCoordinators, ServerGroupSyncMasters, ServerGroupSyncWorkers:
176176
if v := groupSpec.AllowMemberRecreation; v == nil {
177177
return true
178178
} else {

pkg/deployment/reconcile/action_context.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ type ActionContext interface {
7575
// Returns member status, true when found, or false
7676
// when no such member is found.
7777
GetMemberStatusByID(id string) (api.MemberStatus, bool)
78+
// GetMemberStatusAndGroupByID returns the current member status and group
79+
// for the member with given id.
80+
// Returns member status, true when found, or false
81+
// when no such member is found.
82+
GetMemberStatusAndGroupByID(id string) (api.MemberStatus, api.ServerGroup, bool)
7883
// CreateMember adds a new member to the given group.
7984
// If ID is non-empty, it will be used, otherwise a new ID is created.
8085
CreateMember(ctx context.Context, group api.ServerGroup, id string) (string, error)
@@ -286,6 +291,15 @@ func (ac *actionContext) GetMemberStatusByID(id string) (api.MemberStatus, bool)
286291
return m, ok
287292
}
288293

294+
// GetMemberStatusAndGroupByID returns the current member status and group
295+
// for the member with given id.
296+
// Returns member status, true when found, or false
297+
// when no such member is found.
298+
func (ac *actionContext) GetMemberStatusAndGroupByID(id string) (api.MemberStatus, api.ServerGroup, bool) {
299+
status, _ := ac.context.GetStatus()
300+
return status.Members.ElementByID(id)
301+
}
302+
289303
// CreateMember adds a new member to the given group.
290304
// If ID is non-empty, it will be used, otherwise a new ID is created.
291305
func (ac *actionContext) CreateMember(ctx context.Context, group api.ServerGroup, id string) (string, error) {

pkg/deployment/reconcile/action_recreate_member.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,29 @@ type actionRecreateMember struct {
6161
// Returns true if the action is completely finished, false in case
6262
// the start time needs to be recorded and a ready condition needs to be checked.
6363
func (a *actionRecreateMember) Start(ctx context.Context) (bool, error) {
64-
m, ok := a.actionCtx.GetMemberStatusByID(a.action.MemberID)
64+
m, g, ok := a.actionCtx.GetMemberStatusAndGroupByID(a.action.MemberID)
6565
if !ok {
6666
return false, errors.Newf("expecting member to be present in list, but it is not")
6767
}
6868

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

75-
return false, errors.WithStack(err)
77+
return false, errors.WithStack(err)
78+
}
7679
}
7780

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

83-
if err = a.actionCtx.UpdateMember(ctx, m); err != nil {
86+
if err := a.actionCtx.UpdateMember(ctx, m); err != nil {
8487
return false, errors.WithStack(err)
8588
}
8689

0 commit comments

Comments
 (0)