mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
Fixed all-member-ready check
This commit is contained in:
parent
6e9de81f48
commit
e5e39b41f7
3 changed files with 35 additions and 12 deletions
|
@ -23,8 +23,6 @@
|
|||
package v1alpha
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -214,16 +212,24 @@ func (ds *DeploymentStatusMembers) RemoveByID(id string, group ServerGroup) erro
|
|||
}
|
||||
|
||||
// AllMembersReady returns true when all members are in the Ready state.
|
||||
func (ds DeploymentStatusMembers) AllMembersReady() bool {
|
||||
if err := ds.ForeachServerGroup(func(group ServerGroup, list MemberStatusList) error {
|
||||
for _, x := range list {
|
||||
if !x.Conditions.IsTrue(ConditionTypeReady) {
|
||||
return fmt.Errorf("not ready")
|
||||
}
|
||||
func (ds DeploymentStatusMembers) AllMembersReady(mode DeploymentMode, syncEnabled bool) bool {
|
||||
syncReady := func() bool {
|
||||
if syncEnabled {
|
||||
return ds.SyncMasters.AllMembersReady() && ds.SyncWorkers.AllMembersReady()
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return true
|
||||
}
|
||||
switch mode {
|
||||
case DeploymentModeSingle:
|
||||
return ds.Single.MembersReady() > 0
|
||||
case DeploymentModeActiveFailover:
|
||||
return ds.Agents.AllMembersReady() && ds.Single.MembersReady() > 0
|
||||
case DeploymentModeCluster:
|
||||
return ds.Agents.AllMembersReady() &&
|
||||
ds.DBServers.AllMembersReady() &&
|
||||
ds.Coordinators.AllMembersReady() &&
|
||||
syncReady()
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -134,3 +134,19 @@ func (l MemberStatusList) SelectMemberToRemove() (MemberStatus, error) {
|
|||
}
|
||||
return MemberStatus{}, maskAny(errors.Wrap(NotFoundError, "No member available for removal"))
|
||||
}
|
||||
|
||||
// MembersReady returns the number of members that are in the Ready state.
|
||||
func (l MemberStatusList) MembersReady() int {
|
||||
readyCount := 0
|
||||
for _, x := range l {
|
||||
if x.Conditions.IsTrue(ConditionTypeReady) {
|
||||
readyCount++
|
||||
}
|
||||
}
|
||||
return readyCount
|
||||
}
|
||||
|
||||
// AllMembersReady returns the true if all members are in the Ready state.
|
||||
func (l MemberStatusList) AllMembersReady() bool {
|
||||
return len(l) == l.MembersReady()
|
||||
}
|
||||
|
|
|
@ -217,7 +217,8 @@ func (r *Resources) InspectPods(ctx context.Context) error {
|
|||
})
|
||||
|
||||
// Update overall conditions
|
||||
allMembersReady := status.Members.AllMembersReady()
|
||||
spec := r.context.GetSpec()
|
||||
allMembersReady := status.Members.AllMembersReady(spec.GetMode(), spec.Sync.IsEnabled())
|
||||
status.Conditions.Update(api.ConditionTypeReady, allMembersReady, "", "")
|
||||
|
||||
// Update conditions
|
||||
|
|
Loading…
Reference in a new issue