Skip to content

Commit c5abe61

Browse files
authored
Merge pull request kubernetes#128021 from toVersus/fix/flaky-restart-check
[Sidecar Containers] Check for restarts without being affected by container startup order
2 parents 5b1a4ca + 04c6d93 commit c5abe61

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

test/e2e_node/container_lifecycle_pod_construction.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,6 @@ func (o containerOutputList) StartsBefore(lhs, rhs string) error {
179179
return nil
180180
}
181181

182-
// DoesntStartAfter returns an error if lhs started after rhs
183-
func (o containerOutputList) DoesntStartAfter(lhs, rhs string) error {
184-
rhsStart := o.findIndex(rhs, "Starting", 0)
185-
186-
if rhsStart == -1 {
187-
return fmt.Errorf("couldn't find that %s ever started, got\n%v", rhs, o)
188-
}
189-
190-
// this works even for the same names (restart case)
191-
lhsStart := o.findIndex(lhs, "Started", rhsStart+1)
192-
193-
if lhsStart != -1 {
194-
return fmt.Errorf("expected %s to not start after %s, got\n%v", lhs, rhs, o)
195-
}
196-
197-
return nil
198-
}
199-
200182
// ExitsBefore returns an error if lhs did not end before rhs
201183
func (o containerOutputList) ExitsBefore(lhs, rhs string) error {
202184
lhsExit := o.findIndex(lhs, "Exiting", 0)

test/e2e_node/container_lifecycle_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
16311631
results = parseOutput(context.TODO(), f, podSpec)
16321632
})
16331633
ginkgo.It("should not restart a restartable init container", func() {
1634-
framework.ExpectNoError(results.DoesntStartAfter(restartableInit1, regular1))
1634+
framework.ExpectNoError(results.HasNotRestarted(restartableInit1))
16351635
})
16361636
ginkgo.It("should run a regular container to completion", func() {
16371637
framework.ExpectNoError(results.Exits(regular1))
@@ -2033,7 +2033,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
20332033
results = parseOutput(context.TODO(), f, podSpec)
20342034
})
20352035
ginkgo.It("should not restart a restartable init container", func() {
2036-
framework.ExpectNoError(results.DoesntStartAfter(restartableInit1, regular1))
2036+
framework.ExpectNoError(results.HasNotRestarted(restartableInit1))
20372037
})
20382038
ginkgo.It("should run a regular container to completion", func() {
20392039
framework.ExpectNoError(results.Exits(regular1))
@@ -2454,7 +2454,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
24542454
})
24552455

24562456
ginkgo.It("should not restart a restartable init container", func() {
2457-
framework.ExpectNoError(results.DoesntStartAfter(restartableInit1, regular1))
2457+
framework.ExpectNoError(results.HasNotRestarted(restartableInit1))
24582458
})
24592459
// this test case is different from restartPolicy=Never
24602460
ginkgo.It("should start a regular container", func() {

0 commit comments

Comments
 (0)