Web terminal not working with group cluster

Summary

Kubernetes web terminal cannot be accessed if the cluster is a group level cluster

Steps to reproduce

  1. Add a Kubernetes cluster to a group
  2. Deploy to Kubernetes in a project inside that group
  3. Go to the project page > Operations > Environments

What is the current bug behavior?

The Terminal button in the environments list is disabled:

image

The terminal button in the environment detail view is active, but the terminal itself shows "Connection failure":

image

What is the expected correct behavior?

Web terminals should work exactly the same like when the cluster is added to the project directly.

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:         Ubuntu 16.04
Current User:   git
Using RVM:      no
Ruby Version:   2.5.3p105
Gem Version:    2.7.6
Bundler Version:1.17.3
Rake Version:   12.3.2
Redis Version:  3.2.12
Git Version:    2.18.1
Sidekiq Version:5.2.5
Go Version:     unknown

Results of GitLab application Check

Expand for output related to the GitLab application check
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 9.0.0 ? ... OK (9.0.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK

Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 5/2 ... yes 4/3 ... yes 5/8 ... yes 18/10 ... yes 5/11 ... yes 4/13 ... yes 18/14 ... yes 18/17 ... yes 4/18 ... yes 4/19 ... yes 18/21 ... yes 18/22 ... yes 18/23 ... yes 35/26 ... yes 2/30 ... yes 35/32 ... yes 5/37 ... yes 18/44 ... yes 4/46 ... yes 38/48 ... yes 39/49 ... yes 39/50 ... yes 5/51 ... yes 46/52 ... yes 5/53 ... yes 4/54 ... yes 46/55 ... yes 4/62 ... yes 5/63 ... yes 4/64 ... yes 18/65 ... yes 18/66 ... yes 5/67 ... yes 39/68 ... yes 5/69 ... yes 38/71 ... yes 49/72 ... yes 50/73 ... yes 5/74 ... yes 51/75 ... yes 18/76 ... yes 18/77 ... yes 2/78 ... yes 38/79 ... yes 39/80 ... yes 5/81 ... yes 18/82 ... yes 39/83 ... yes 39/84 ... yes 54/85 ... yes 54/86 ... yes 5/87 ... yes 57/88 ... yes 4/89 ... yes 38/90 ... yes 18/91 ... yes 5/92 ... yes 4/93 ... yes 5/94 ... yes 5/95 ... yes 18/96 ... yes 5/97 ... yes 21/98 ... yes 5/99 ... yes 59/100 ... yes 35/101 ... yes 5/102 ... yes 2/103 ... yes 5/104 ... yes 57/108 ... yes 65/109 ... yes 57/110 ... yes 18/111 ... yes 5/112 ... yes 5/113 ... yes 5/115 ... yes 5/116 ... yes 38/117 ... yes 5/118 ... yes 38/119 ... yes 38/120 ... yes 54/124 ... yes 8/125 ... yes 4/126 ... yes 40/127 ... yes 4/128 ... yes 5/129 ... yes 5/130 ... yes 38/131 ... yes 38/132 ... yes 5/133 ... yes 38/134 ... yes 39/135 ... yes 39/136 ... yes 5/137 ... yes 39/138 ... yes 5/139 ... yes 2/140 ... yes 2/141 ... yes 5/142 ... yes 39/143 ... yes 98/144 ... yes 59/145 ... yes 5/147 ... yes 5/148 ... yes 102/149 ... yes 5/150 ... yes 98/151 ... yes 5/153 ... yes 51/154 ... yes 109/155 ... yes 111/158 ... yes 111/160 ... yes 4/162 ... yes 4/163 ... yes 111/164 ... yes 4/165 ... yes 4/166 ... yes 5/167 ... yes 57/168 ... yes 118/170 ... yes 118/171 ... yes 118/172 ... yes 98/173 ... yes 39/175 ... yes 4/176 ... yes 5/177 ... yes 4/178 ... yes 51/180 ... yes 4/181 ... yes 113/182 ... yes 18/183 ... yes 5/184 ... yes 113/185 ... yes 5/186 ... yes 98/187 ... yes 4/189 ... yes 18/190 ... yes 131/192 ... yes 131/193 ... yes 131/194 ... yes 5/195 ... yes 98/196 ... yes 2/197 ... yes 131/198 ... yes 131/199 ... yes 2/200 ... yes 131/201 ... yes 5/202 ... yes 136/203 ... yes 136/205 ... yes 5/206 ... yes 5/207 ... yes 5/209 ... yes 131/210 ... yes 5/212 ... yes 113/213 ... yes 131/214 ... yes 5/215 ... yes 5/216 ... yes 5/217 ... yes 113/218 ... yes 5/219 ... yes 39/221 ... yes 5/222 ... yes 77/223 ... yes 2/224 ... yes 142/225 ... yes 18/228 ... yes 18/229 ... yes 98/231 ... yes 99/232 ... yes 146/233 ... yes 147/234 ... yes 39/237 ... yes 146/238 ... yes 146/239 ... yes 109/240 ... yes 4/241 ... yes 4/242 ... yes 5/243 ... yes 39/244 ... yes 142/245 ... yes 18/246 ... yes 4/247 ... yes 142/248 ... yes 5/249 ... yes 5/250 ... yes 77/251 ... yes 5/252 ... yes 5/253 ... yes 158/254 ... yes 39/255 ... yes 147/256 ... yes 59/257 ... yes 5/258 ... yes 5/259 ... yes 5/260 ... yes 5/262 ... yes 59/263 ... yes 5/264 ... yes 18/265 ... yes 147/267 ... yes 159/269 ... yes 159/270 ... yes 77/271 ... yes 5/272 ... yes 5/273 ... yes 5/275 ... yes 162/277 ... yes 147/278 ... yes 5/279 ... yes 159/281 ... yes 147/282 ... yes 159/283 ... yes 159/284 ... yes 5/285 ... yes 59/286 ... yes 39/287 ... yes 147/288 ... yes 59/289 ... yes 59/290 ... yes 2/291 ... yes 18/293 ... yes 165/294 ... yes 165/295 ... yes 165/296 ... yes 165/297 ... yes 165/298 ... yes 147/299 ... yes 166/300 ... yes 18/301 ... yes 147/302 ... yes 39/304 ... yes 18/305 ... yes 59/306 ... yes 59/307 ... yes 168/308 ... yes 2/309 ... yes 169/310 ... yes 5/311 ... yes 169/312 ... yes 2/313 ... yes 166/315 ... yes 175/316 ... yes 176/317 ... yes 2/318 ... yes 18/319 ... yes 2/320 ... yes 179/321 ... yes 59/324 ... yes 21/326 ... yes 177/327 ... yes 5/329 ... yes 175/330 ... yes 21/331 ... yes 179/333 ... yes 131/334 ... yes 179/335 ... yes 175/336 ... yes 51/337 ... yes 51/341 ... yes 113/342 ... yes 2/343 ... yes 99/344 ... yes 51/345 ... yes 18/346 ... yes 5/347 ... yes 2/348 ... yes 2/349 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.5.3) Git version >= 2.18.0 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 93

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

I traced down the problem to this line, where project is falsy so the function returns immediately.