mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
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:
commit
c5abe615eb
@ -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)
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user