From 1e7209b72fdf8aef7534c7326b9253ff75c04c3b Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Fri, 6 Nov 2015 19:19:55 -0500 Subject: [PATCH 1/2] UPSTREAM: 16969: nsenter file writer mangles newlines Results in secret content being incorrect, service account ca.crt has \n instead of actual newlines. --- .../src/k8s.io/kubernetes/pkg/util/io/writer.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/io/writer.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/io/writer.go index 7e0217266b24..3046c4d9b26e 100644 --- a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/io/writer.go +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/io/writer.go @@ -17,6 +17,7 @@ limitations under the License. package io import ( + "bytes" "fmt" "io/ioutil" "os" @@ -49,6 +50,7 @@ func (writer *StdWriter) WriteFile(filename string, data []byte, perm os.FileMod type NsenterWriter struct { } +// TODO: should take a writer, not []byte func (writer *NsenterWriter) WriteFile(filename string, data []byte, perm os.FileMode) error { cmd := "nsenter" base_args := []string{ @@ -56,10 +58,11 @@ func (writer *NsenterWriter) WriteFile(filename string, data []byte, perm os.Fil "--", } - echo_args := append(base_args, "sh", "-c", - fmt.Sprintf("echo %q | cat > %s", data, filename)) + echo_args := append(base_args, "sh", "-c", fmt.Sprintf("cat > %s", filename)) glog.V(5).Infof("Command to write data to file: %v %v", cmd, echo_args) - outputBytes, err := exec.Command(cmd, echo_args...).CombinedOutput() + command := exec.Command(cmd, echo_args...) + command.Stdin = bytes.NewBuffer(data) + outputBytes, err := command.CombinedOutput() if err != nil { glog.Errorf("Output from writing to %q: %v", filename, string(outputBytes)) return err From b2e0262337026b6577f8a42aa05f1b1eda64ba13 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Sat, 7 Nov 2015 10:51:25 -0600 Subject: [PATCH 2/2] Make auth-in-container tests cause test failure again --- test/end-to-end/core.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/end-to-end/core.sh b/test/end-to-end/core.sh index 9d671b5b0f67..2ae7154048e7 100755 --- a/test/end-to-end/core.sh +++ b/test/end-to-end/core.sh @@ -138,8 +138,6 @@ oc project test oc whoami echo "[INFO] Running a CLI command in a container using the service account" -echo "[INFO] WARNING: Tests are set to not fail, dockererized container is writing an invalid ca.crt" -set +e oc policy add-role-to-user view -z default out=$(oc run cli-with-token --attach --env=POD_NAMESPACE=test --image=openshift/origin:${TAG} --restart=Never -- cli status --loglevel=4 2>&1) echo $out @@ -154,7 +152,6 @@ out=$(oc run kubectl-with-token --attach --env=POD_NAMESPACE=test --image=opensh echo $out [ "$(echo $out | grep 'Using in-cluster configuration')" ] [ "$(echo $out | grep 'kubectl-with-token')" ] -set -e echo "[INFO] Streaming the logs from a deployment twice..." oc create -f test/fixtures/failing-dc.yaml