e2e: the vault addon was incorrectly using StdoutPipe
The documentation [1] mentions that `StdoutPipe` should not be used
along with `Run`:
"Wait will close the pipe after seeing the command exit, so most callers
need not close the pipe themselves. It is thus incorrect to call Wait
before all reads from the pipe have completed. For the same reason, it
is incorrect to call Run when using StdoutPipe. See the example for
idiomatic usage."
It seems we are using `Run`, meaning that the StdoutPipe gets closed
when `Run` returns (because `Run` calls `Wait` and closes the StdoutPipe
before returning).
To reproduce:
git fetch fa4c2cfcad79f0a8a806b71caefbf96b049533c5
git checkout fa4c2cfcad79f0a8a806b71caefbf96b049533c5
go test -tags=e2e_test ./test/e2e -- -test.outputdir=$PWD/_bin/artifacts \
-ginkgo.junit-report=junit__01.xml -ginkgo.flake-attempts=1 \
-test.timeout=24h -ginkgo.v -test.v -ginkgo.randomize-all \
-ginkgo.progress -ginkgo.trace -ginkgo.slow-spec-threshold=300s \
--repo-root=/home/mvalais/code/cert-manager \
--report-dir=/home/mvalais/code/cert-manager/_bin/artifacts \
--acme-dns-server=10.0.0.16 --acme-ingress-ip=10.0.0.15 \
--acme-gateway-ip=10.0.0.14 \
--ingress-controller-domain=ingress-nginx.http01.example.com \
--gateway-domain=gateway.http01.example.com \
--feature-gates="" \
--ginkgo.focus=".*should be ready with a valid serviceAccountRef"
Result:
error install helm chart: cmd.Run: exit status 1: io.Copy: write /dev/stdout: copy_file_range: use of closed file
Signed-off-by: Maël Valais <mael@vls.dev>
This commit is contained in:
parent
57113668e0
commit
ba0bb5d503
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package chart
|
package chart
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -164,16 +165,12 @@ func (c *Chart) runInstall() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd := c.buildHelmCmd(args...)
|
cmd := c.buildHelmCmd(args...)
|
||||||
cmd.Stdout = nil
|
stdoutBuf := &bytes.Buffer{}
|
||||||
out, err := cmd.StdoutPipe()
|
cmd.Stdout = stdoutBuf
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer out.Close()
|
|
||||||
|
|
||||||
err = cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, err2 := io.Copy(os.Stdout, out)
|
_, err2 := io.Copy(os.Stdout, stdoutBuf)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
return fmt.Errorf("cmd.Run: %v: io.Copy: %v", err, err2)
|
return fmt.Errorf("cmd.Run: %v: io.Copy: %v", err, err2)
|
||||||
}
|
}
|
||||||
@ -197,19 +194,15 @@ func (c *Chart) buildHelmCmd(args ...string) *exec.Cmd {
|
|||||||
|
|
||||||
func (c *Chart) getHelmVersion() (string, error) {
|
func (c *Chart) getHelmVersion() (string, error) {
|
||||||
cmd := c.buildHelmCmd("version", "--template", "{{.Client.Version}}")
|
cmd := c.buildHelmCmd("version", "--template", "{{.Client.Version}}")
|
||||||
cmd.Stdout = nil
|
stdoutBuf := &bytes.Buffer{}
|
||||||
out, err := cmd.StdoutPipe()
|
cmd.Stdout = stdoutBuf
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer out.Close()
|
|
||||||
|
|
||||||
err = cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
outBytes, err := io.ReadAll(out)
|
outBytes, err := io.ReadAll(stdoutBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -220,16 +213,12 @@ func (c *Chart) getHelmVersion() (string, error) {
|
|||||||
// Deprovision the deployed instance of tiller-deploy
|
// Deprovision the deployed instance of tiller-deploy
|
||||||
func (c *Chart) Deprovision() error {
|
func (c *Chart) Deprovision() error {
|
||||||
cmd := c.buildHelmCmd("delete", "--namespace", c.Namespace, c.ReleaseName)
|
cmd := c.buildHelmCmd("delete", "--namespace", c.Namespace, c.ReleaseName)
|
||||||
cmd.Stdout = nil
|
stdoutBuf := &bytes.Buffer{}
|
||||||
out, err := cmd.StdoutPipe()
|
cmd.Stdout = stdoutBuf
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer out.Close()
|
|
||||||
|
|
||||||
err = cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, err2 := io.Copy(os.Stdout, out)
|
_, err2 := io.Copy(os.Stdout, stdoutBuf)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
return fmt.Errorf("cmd.Run: %v: io.Copy: %v", err, err2)
|
return fmt.Errorf("cmd.Run: %v: io.Copy: %v", err, err2)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user