Skip to content

Commit f363f22

Browse files
author
lamai93
committed
Simplify logic.
1 parent e095a5a commit f363f22

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pkg/apis/deployment/v1alpha/member_status_list.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,25 +183,24 @@ func (l MemberStatusList) AllMembersReady() bool {
183183

184184
// AllConditionTrueSince returns true if all members satisfy the condition since the given period
185185
func (l MemberStatusList) AllConditionTrueSince(cond ConditionType, status v1.ConditionStatus, period time.Duration) bool {
186-
trueCount := 0
187186
for _, x := range l {
188187
if c, ok := x.Conditions.Get(cond); ok {
189188
if c.Status == status && c.LastTransitionTime.Time.Add(period).Before(time.Now()) {
190-
trueCount++
189+
continue
191190
}
192191
}
192+
return false
193193
}
194194

195-
return trueCount == len(l)
195+
return true
196196
}
197197

198198
// AllFailed returns true if all members are failed
199199
func (l MemberStatusList) AllFailed() bool {
200-
failedCount := 0
201200
for _, x := range l {
202-
if x.Phase.IsFailed() {
203-
failedCount++
201+
if !x.Phase.IsFailed() {
202+
return false
204203
}
205204
}
206-
return failedCount == len(l)
205+
return true
207206
}

0 commit comments

Comments
 (0)