Investigate why EE Review Apps are not cleaned up properly.

I've seen several things that are suspicious in https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/80298313:

$ delete
Error: forwarding ports: error upgrading connection: error dialing backend: ssh: rejected: connect failed (Connection refused)
$ cleanup
error: You must provide one or more resources by argument or filename.
Example resource specifications include:
   '-f rsrc.yaml'
   '--filename=rsrc.json'
   '<resource> <name>'
   '<resource>'
  • delete fails because of a Connection refused error...
  • cleanup failed, most probably because we have
function cleanup() {
  kubectl get ingress,configmap,all -n "$KUBE_NAMESPACE" \
    -o jsonpath='{range .items[*]}{.kind}{" "}{.metadata.name}{"\n"}{end}' \
    | grep "CI_ENVIRONMENT_SLUG" \
    | xargs -n2 kubectl delete -n "$KUBE_NAMESPACE" \
    || true
}

Note grep "CI_ENVIRONMENT_SLUG" which should be grep "$CI_ENVIRONMENT_SLUG" ($ is missing!)

Edited by Rémy Coutable