Skip to content

Commit

Permalink
Fixed all coordinators failed stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
lamai93 committed Apr 24, 2019
1 parent 6401034 commit c735bbb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions pkg/deployment/context_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ func (d *Deployment) UpdateStatus(status api.DeploymentStatus, lastVersion int32
return nil
}

// UpdateMember updates the deployment status wrt the given member.
func (d *Deployment) UpdateMember(member api.MemberStatus) error {
status, lastVersion := d.GetStatus()
_, group, found := status.Members.ElementByID(member.ID)
if !found {
return maskAny(fmt.Errorf("Member %s not found", member.ID))
}
if err := status.Members.Update(member, group); err != nil {
return maskAny(err)
}
if err := d.UpdateStatus(status, lastVersion); err != nil {
log.Debug().Err(err).Msg("Updating CR status failed")
return maskAny(err)
}
return nil
}

// GetDatabaseClient returns a cached client for the entire database (cluster coordinators or single server),
// creating one if needed.
func (d *Deployment) GetDatabaseClient(ctx context.Context) (driver.Client, error) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/deployment/reconcile/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type Context interface {
// UpdateStatus replaces the status of the deployment with the given status and
// updates the resources in k8s.
UpdateStatus(status api.DeploymentStatus, lastVersion int32, force ...bool) error
// UpdateMember updates the deployment status wrt the given member.
UpdateMember(member api.MemberStatus) error
// GetDatabaseClient returns a cached client for the entire database (cluster coordinators or single server),
// creating one if needed.
GetDatabaseClient(ctx context.Context) (driver.Client, error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/reconcile/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (r *Reconciler) CheckDeployment() error {
r.log.Error().Err(err).Msg("Failed to delete pod")
}
m.Phase = api.MemberPhaseNone
if err := status.Members.Update(m, api.ServerGroupCoordinators); err != nil {
if err := r.context.UpdateMember(m); err != nil {
r.log.Error().Err(err).Msg("Failed to update member")
}
}
Expand Down

0 comments on commit c735bbb

Please sign in to comment.