From c735bbb01f3b3d0e025090344c993e133939ef84 Mon Sep 17 00:00:00 2001 From: lamai93 Date: Wed, 24 Apr 2019 14:44:38 +0200 Subject: [PATCH] Fixed all coordinators failed stuff. --- pkg/deployment/context_impl.go | 17 +++++++++++++++++ pkg/deployment/reconcile/context.go | 2 ++ pkg/deployment/reconcile/reconciler.go | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/deployment/context_impl.go b/pkg/deployment/context_impl.go index a65a4dd39..c56d79717 100644 --- a/pkg/deployment/context_impl.go +++ b/pkg/deployment/context_impl.go @@ -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) { diff --git a/pkg/deployment/reconcile/context.go b/pkg/deployment/reconcile/context.go index bf98aab60..c8e692a25 100644 --- a/pkg/deployment/reconcile/context.go +++ b/pkg/deployment/reconcile/context.go @@ -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) diff --git a/pkg/deployment/reconcile/reconciler.go b/pkg/deployment/reconcile/reconciler.go index 804baa06a..847970adf 100644 --- a/pkg/deployment/reconcile/reconciler.go +++ b/pkg/deployment/reconcile/reconciler.go @@ -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") } }