Merge pull request #128021 from toVersus/fix/flaky-restart-check

[Sidecar Containers] Check for restarts without being affected by container startup order
This commit is contained in:
Kubernetes Prow Robot 2024-10-14 07:56:21 +01:00 committed by GitHub
commit c5abe615eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 21 deletions

View File

@ -179,24 +179,6 @@ func (o containerOutputList) StartsBefore(lhs, rhs string) error {
return nil
}
// DoesntStartAfter returns an error if lhs started after rhs
func (o containerOutputList) DoesntStartAfter(lhs, rhs string) error {
rhsStart := o.findIndex(rhs, "Starting", 0)
if rhsStart == -1 {
return fmt.Errorf("couldn't find that %s ever started, got\n%v", rhs, o)
}
// this works even for the same names (restart case)
lhsStart := o.findIndex(lhs, "Started", rhsStart+1)
if lhsStart != -1 {
return fmt.Errorf("expected %s to not start after %s, got\n%v", lhs, rhs, o)
}
return nil
}
// ExitsBefore returns an error if lhs did not end before rhs
func (o containerOutputList) ExitsBefore(lhs, rhs string) error {
lhsExit := o.findIndex(lhs, "Exiting", 0)

View File

@ -1631,7 +1631,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
results = parseOutput(context.TODO(), f, podSpec)
})
ginkgo.It("should not restart a restartable init container", func() {
framework.ExpectNoError(results.DoesntStartAfter(restartableInit1, regular1))
framework.ExpectNoError(results.HasNotRestarted(restartableInit1))
})
ginkgo.It("should run a regular container to completion", func() {
framework.ExpectNoError(results.Exits(regular1))
@ -2033,7 +2033,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
results = parseOutput(context.TODO(), f, podSpec)
})
ginkgo.It("should not restart a restartable init container", func() {
framework.ExpectNoError(results.DoesntStartAfter(restartableInit1, regular1))
framework.ExpectNoError(results.HasNotRestarted(restartableInit1))
})
ginkgo.It("should run a regular container to completion", func() {
framework.ExpectNoError(results.Exits(regular1))
@ -2454,7 +2454,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
})
ginkgo.It("should not restart a restartable init container", func() {
framework.ExpectNoError(results.DoesntStartAfter(restartableInit1, regular1))
framework.ExpectNoError(results.HasNotRestarted(restartableInit1))
})
// this test case is different from restartPolicy=Never
ginkgo.It("should start a regular container", func() {