Skip to content

Commit

Permalink
Merge pull request kubernetes#2819 from aledbf/logs
Browse files Browse the repository at this point in the history
Catch errors waiting for controller deployment
  • Loading branch information
k8s-ci-robot authored Jul 20, 2018
2 parents 9bf919a + 2f70c35 commit e211101
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
16 changes: 2 additions & 14 deletions test/e2e/framework/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,10 @@ func (f *Framework) ExecCommand(pod *v1.Pod, command string) (string, error) {

// NewIngressController deploys a new NGINX Ingress controller in a namespace
func (f *Framework) NewIngressController(namespace string) error {
var (
execOut bytes.Buffer
execErr bytes.Buffer
)

cmd := exec.Command("./wait-for-nginx.sh", namespace)
cmd.Stdout = &execOut
cmd.Stderr = &execErr

err := cmd.Run()
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("could not execute: %v", err)
}

if execErr.Len() > 0 {
return fmt.Errorf("stderr: %v", execErr.String())
return fmt.Errorf("Unexpected error waiting for ingress controller deployment: %v.\nLogs:\n%v", err, string(out))
}

return nil
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/wait-for-nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ export NAMESPACE=$1

echo "deploying NGINX Ingress controller in namespace $NAMESPACE"

function on_exit {
local error_code="$?"

test $error_code == 0 && return;

echo "Obtaining ingress controller pod logs..."
kubectl logs -l app=ingress-nginx -n $NAMESPACE
}
trap on_exit EXIT

sed "s@\${NAMESPACE}@${NAMESPACE}@" $DIR/../manifests/ingress-controller/mandatory.yaml | kubectl apply --namespace=$NAMESPACE -f -
cat $DIR/../manifests/ingress-controller/service-nodeport.yaml | kubectl apply --namespace=$NAMESPACE -f -

Expand Down

0 comments on commit e211101

Please sign in to comment.