Catch errors waiting for controller deployment
This commit is contained in:
parent
9bf919a43b
commit
2f70c351cb
2 changed files with 12 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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 -
|
||||
|
||||
|
|
Loading…
Reference in a new issue