port forward util returns before port forward is available for use
jbohanon opened this issue · comments
Gloo Edge Product
Open Source
Gloo Edge Version
v1.17.0
Kubernetes Version
All
Describe the bug
The utility to create a port forward, when started, does not wait until the port forward is available for use. This can cause a race condition in tests which expect to be able to make requests against the forwarded port immediately upon Start
returning.
Expected Behavior
Start
should not return without an error until the port is reachable
Steps to reproduce the bug
Set up a test that creates a port forward using
portFwd := portforward.NewPortForwarder(
portforward.WithDeployment(proxyName, namespace),
portforward.WithPorts(19000, 19000),
)
err = portFwd.Start(ctx)
Expect(err).NotTo(HaveOccurred())
defer func() {
portFwd.Close()
portFwd.WaitForStop()
}()
then immediately try a request against the forwarded port. It is possible that it will work appropriately, but it will be flaky at best since the port is not guaranteed to be available yet
Additional Environment Detail
No response
Additional Context
https://github.com/solo-io/solo-projects/pull/5973/files#r1560360903