Review App debugging sometimes fail because multiple Unicorn pods exist
As can be seen in https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/256164155:
** Waiting till 'unicorn' pod is ready **
Running 'kubectl get pods -n review-apps-ce --field-selector=status.phase=Running -lapp=unicorn,release=review-fj-navbar-ajbxag --no-headers -o=custom-columns=NAME:.metadata.name'
The pod name is 'review-fj-navbar-ajbxag-unicorn-658dfcc8cf-kfv74
review-fj-navbar-ajbxag-unicorn-658dfcc8cf-xzg4r'.
Logs tail of the review-fj-navbar-ajbxag-unicorn-658dfcc8cf-kfv74
review-fj-navbar-ajbxag-unicorn-658dfcc8cf-xzg4r pod...
Error from server (NotFound): pods "review-fj-navbar-ajbxag-unicorn-658dfcc8cf-kfv74\nreview-fj-navbar-ajbxag-unicorn-658dfcc8cf-xzg4r" not found
Here we can see that the pod name is "review-fj-navbar-ajbxag-unicorn-658dfcc8cf-kfv74 review-fj-navbar-ajbxag-unicorn-658dfcc8cf-xzg4r" which actually includes two pods' names.
By adding a tail -n 1
we can grab the latest deployed pod, e.g.:
› kubectl get pods -n review-apps-ce --field-selector=status.phase=Running -lapp=unicorn,release=review-fj-navbar-ajbxag
NAME READY STATUS RESTARTS AGE
review-fj-navbar-ajbxag-unicorn-658dfcc8cf-lvsqs 2/2 Running 0 16h
review-fj-navbar-ajbxag-unicorn-658dfcc8cf-sxczb 2/2 Running 0 11h
› kubectl get pods -n review-apps-ce --field-selector=status.phase=Running -lapp=unicorn,release=review-fj-navbar-ajbxag --no-headers -o=custom-columns=NAME:.metadata.name | tail -n 1
review-fj-navbar-ajbxag-unicorn-658dfcc8cf-sxczb