mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
e2e: stop controller if context cancelled
This commit is contained in:
parent
e15d5b9da9
commit
ad0bc4857b
@ -355,9 +355,10 @@ func (j *TestJig) WaitForEndpointOnNode(ctx context.Context, nodeName string) er
|
|||||||
|
|
||||||
// waitForAvailableEndpoint waits for at least 1 endpoint to be available till timeout
|
// waitForAvailableEndpoint waits for at least 1 endpoint to be available till timeout
|
||||||
func (j *TestJig) waitForAvailableEndpoint(ctx context.Context, timeout time.Duration) error {
|
func (j *TestJig) waitForAvailableEndpoint(ctx context.Context, timeout time.Duration) error {
|
||||||
|
ctx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
|
defer cancel()
|
||||||
//Wait for endpoints to be created, this may take longer time if service backing pods are taking longer time to run
|
//Wait for endpoints to be created, this may take longer time if service backing pods are taking longer time to run
|
||||||
endpointSelector := fields.OneTermEqualSelector("metadata.name", j.Name)
|
endpointSelector := fields.OneTermEqualSelector("metadata.name", j.Name)
|
||||||
stopCh := make(chan struct{})
|
|
||||||
endpointAvailable := false
|
endpointAvailable := false
|
||||||
endpointSliceAvailable := false
|
endpointSliceAvailable := false
|
||||||
|
|
||||||
@ -393,11 +394,8 @@ func (j *TestJig) waitForAvailableEndpoint(ctx context.Context, timeout time.Dur
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
defer func() {
|
|
||||||
close(stopCh)
|
|
||||||
}()
|
|
||||||
|
|
||||||
go controller.Run(stopCh)
|
go controller.Run(ctx.Done())
|
||||||
|
|
||||||
var esController cache.Controller
|
var esController cache.Controller
|
||||||
_, esController = cache.NewInformer(
|
_, esController = cache.NewInformer(
|
||||||
@ -438,9 +436,9 @@ func (j *TestJig) waitForAvailableEndpoint(ctx context.Context, timeout time.Dur
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
go esController.Run(stopCh)
|
go esController.Run(ctx.Done())
|
||||||
|
|
||||||
err := wait.PollUntilContextTimeout(ctx, 1*time.Second, timeout, false, func(ctx context.Context) (bool, error) {
|
err := wait.PollUntilContextCancel(ctx, 1*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||||
return endpointAvailable && endpointSliceAvailable, nil
|
return endpointAvailable && endpointSliceAvailable, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user