-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set NNCP Degraded as soon as first enactment fails (#877)
Don't wait for all enactments to finish, set the Degraded condition as soon as first Failing enactment appears. Signed-off-by: Radim Hrazdil <[email protected]>
- Loading branch information
Showing
3 changed files
with
53 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,14 +118,28 @@ var _ = Describe("[rfe_id:3503][crit:medium][vendor:[email protected]][level:com | |
Expect(abortedConditions).To(Equal(len(nodes)-failingConditions), "other nodes should have aborted enactment") | ||
} | ||
|
||
By("Wait for enactments to reach failing or aborted state") | ||
var wg sync.WaitGroup | ||
wg.Add(len(nodes)) | ||
for i, _ := range nodes { | ||
node := nodes[i] | ||
go func() { | ||
defer wg.Done() | ||
defer GinkgoRecover() | ||
Byf("Check %s failing state is kept", node) | ||
enactmentConditionsStatusEventually(node).Should( | ||
SatisfyAny( | ||
matchConditionsFrom(enactmentconditions.SetFailedToConfigure), | ||
matchConditionsFrom(enactmentconditions.SetConfigurationAborted), | ||
), "should consistently keep failing or aborted conditions at enactments") | ||
}() | ||
} | ||
wg.Wait() | ||
|
||
By("Check policy is at degraded state") | ||
waitForDegradedTestPolicy() | ||
|
||
By("Check there is one failing enactment and the rest are aborted") | ||
checkEnactmentCounts(TestPolicy) | ||
|
||
By("Check that the enactment stays in failing or aborted state") | ||
var wg sync.WaitGroup | ||
By("Check that the enactments stay in failing or aborted state") | ||
wg.Add(len(nodes)) | ||
for i, _ := range nodes { | ||
node := nodes[i] | ||
|
@@ -142,8 +156,30 @@ var _ = Describe("[rfe_id:3503][crit:medium][vendor:[email protected]][level:com | |
} | ||
wg.Wait() | ||
|
||
By("Check there is still one failing enactment and the rest are aborted") | ||
By("Check there is up to maxUnavailable failing enactments and the rest are aborted") | ||
checkEnactmentCounts(TestPolicy) | ||
}) | ||
|
||
It("should mark policy as Degraded as soon as first enactment fails", func() { | ||
failingEnactmentsCount := func(policy string) int { | ||
failingConditions := 0 | ||
for _, node := range nodes { | ||
conditionList := enactmentConditionsStatus(node, TestPolicy) | ||
found, _ := matchConditionsFrom(enactmentconditions.SetFailedToConfigure).Match(conditionList) | ||
if found { | ||
failingConditions++ | ||
} | ||
} | ||
return failingConditions | ||
} | ||
|
||
By("Waiting for first enactment to fail") | ||
Eventually(func() int { | ||
return failingEnactmentsCount(TestPolicy) | ||
}).Should(BeNumerically(">=", 1)) | ||
|
||
By("Checking the policy is marked as Degraded") | ||
Expect(policyConditionsStatus(TestPolicy)).Should(containPolicyDegraded(), "policy should be marked as Degraded") | ||
}) | ||
}) | ||
}) |