Can't create a project as admin with upcoming subscription expiration
### Summary
When trying to create a new project in the personal namespace as instance admin, I get a 500 response screen. As normal user, it works fine. The logs suggest, that it has to do with the banner for subscription expiration.
### Steps to reproduce
* GitLab Self-Hosted Premium (deployed as single-server docker container)
* Subscription expires in less than 14 days
* being an instance admin
* try to create a new project (route `/projects/new`)
* getting error 500
### What is the current *bug* behavior?
500 error page
### What is the expected *correct* behavior?
Being able to do the project creation workflow
### Relevant logs and/or screenshots
`==> /var/log/gitlab/gitlab-rails/production.log <==`
```
Completed 500 Internal Server Error in 528ms (ActiveRecord: 38.6ms | Elasticsearch: 0.0ms | Allocations: 343745)
```
`==> /var/log/gitlab/gitlab-rails/production.log <==`
```
ActionView::Template::Error (Project#closest_gitlab_subscription delegated to namespace.closest_gitlab_subscription, but namespace is nil: #<Project id: >>):
21: - if subscribable.block_changes?
22: = link_to _('Upgrade your plan'), upgrade_subscription_path, class: 'btn gl-button btn-primary', data: { track_event: 'click_text', track_label: 'subscribable_action', track_property: 'upgrade' }
23: - else
24: = link_to _('Renew subscription'), renew_subscription_path, class: 'btn gl-button btn-primary gl-mr-3 gl-mb-2', data: { track_event: 'click_text', track_label: 'subscribable_action', track_property: 'renew' }
25: = link_to _('That is ok, I do not want to renew'), '#', data: { track_event: 'click_text', track_label: 'subscribable_action', track_property: 'thats_ok' }, 'aria-label' => 'Dismiss', class: 'btn gl-button btn-info btn-info-secondary js-close gl-mb-2'
ee/app/models/ee/project.rb:202:in `rescue in closest_gitlab_subscription'
ee/app/models/ee/project.rb:202:in `closest_gitlab_subscription'
ee/app/helpers/ee/subscribable_banner_helper.rb:61:in `decorated_subscription'
ee/app/helpers/ee/subscribable_banner_helper.rb:25:in `renew_subscription_path'
ee/app/views/layouts/header/_ee_subscribable_banner.html.haml:24
app/helpers/application_helper.rb:17:in `render_if_exists'
app/views/layouts/_page.html.haml:18
app/views/layouts/application.html.haml:13
app/controllers/application_controller.rb:125:in `render'
ee/lib/gitlab/ip_address_state.rb:10:in `with'
ee/app/controllers/ee/application_controller.rb:44:in `set_current_ip_address'
app/controllers/application_controller.rb:482:in `set_current_admin'
lib/gitlab/session.rb:11:in `with_session'
app/controllers/application_controller.rb:473:in `set_session_storage'
lib/gitlab/i18n.rb:73:in `with_locale'
lib/gitlab/i18n.rb:79:in `with_user_locale'
app/controllers/application_controller.rb:467:in `set_locale'
lib/gitlab/error_tracking.rb:52:in `with_context'
app/controllers/application_controller.rb:532:in `sentry_context'
app/controllers/application_controller.rb:460:in `block in set_current_context'
lib/gitlab/application_context.rb:56:in `block in use'
lib/gitlab/application_context.rb:56:in `use'
lib/gitlab/application_context.rb:22:in `with_context'
app/controllers/application_controller.rb:451:in `set_current_context'
lib/gitlab/metrics/elasticsearch_rack_middleware.rb:16:in `call'
lib/gitlab/middleware/rails_queue_duration.rb:33:in `call'
lib/gitlab/metrics/rack_middleware.rb:16:in `block in call'
lib/gitlab/metrics/transaction.rb:56:in `run'
lib/gitlab/metrics/rack_middleware.rb:16:in `call'
lib/gitlab/request_profiler/middleware.rb:17:in `call'
lib/gitlab/jira/middleware.rb:19:in `call'
lib/gitlab/middleware/go.rb:20:in `call'
lib/gitlab/etag_caching/middleware.rb:21:in `call'
lib/gitlab/middleware/multipart.rb:172:in `call'
lib/gitlab/middleware/read_only/controller.rb:50:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/same_site_cookies.rb:27:in `call'
lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'
lib/gitlab/middleware/request_context.rb:21:in `call'
config/initializers/fix_local_cache_middleware.rb:11:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:76:in `call'
lib/gitlab/middleware/release_env.rb:12:in `call'
```
`==> /var/log/gitlab/gitlab-rails/production_json.log <==`
```
{"method":"GET","path":"/projects/new","format":"html","controller":"ProjectsController","action":"new","status":500,"time":"2021-02-23T10:03:50.921Z","params":[],"remote_ip":"CENSORED","user_id":2,"username":"CENSORED","ua":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0","correlation_id":"CENSORED","meta.user":"CENSORED","meta.caller_id":"ProjectsController#new","meta.remote_ip":"CENSORED","meta.feature_category":"projects","redis_calls":12,"redis_duration_s":0.002895,"redis_read_bytes":3698,"redis_write_bytes":1457,"redis_cache_calls":11,"redis_cache_duration_s":0.002468,"redis_cache_read_bytes":3515,"redis_cache_write_bytes":522,"redis_shared_state_calls":1,"redis_shared_state_duration_s":0.000427,"redis_shared_state_read_bytes":183,"redis_shared_state_write_bytes":935,"db_count":22,"db_write_count":0,"db_cached_count":7,"cpu_s":0.497815,"queue_duration_s":0.005783,"exception.class":"ActionView::Template::Error","exception.message":"Project#closest_gitlab_subscription delegated to namespace.closest_gitlab_subscription, but namespace is nil: #<Project id: >>","exception.backtrace":["ee/app/models/ee/project.rb:202:in `rescue in closest_gitlab_subscription'","ee/app/models/ee/project.rb:202:in `closest_gitlab_subscription'","ee/app/helpers/ee/subscribable_banner_helper.rb:61:in `decorated_subscription'","ee/app/helpers/ee/subscribable_banner_helper.rb:25:in `renew_subscription_path'","ee/app/views/layouts/header/_ee_subscribable_banner.html.haml:24","app/helpers/application_helper.rb:17:in `render_if_exists'","app/views/layouts/_page.html.haml:18","app/views/layouts/application.html.haml:13","app/controllers/application_controller.rb:125:in `render'","ee/lib/gitlab/ip_address_state.rb:10:in `with'","ee/app/controllers/ee/application_controller.rb:44:in `set_current_ip_address'","app/controllers/application_controller.rb:482:in `set_current_admin'","lib/gitlab/session.rb:11:in `with_session'","app/controllers/application_controller.rb:473:in `set_session_storage'","lib/gitlab/i18n.rb:73:in `with_locale'","lib/gitlab/i18n.rb:79:in `with_user_locale'","app/controllers/application_controller.rb:467:in `set_locale'","lib/gitlab/error_tracking.rb:52:in `with_context'","app/controllers/application_controller.rb:532:in `sentry_context'","app/controllers/application_controller.rb:460:in `block in set_current_context'","lib/gitlab/application_context.rb:56:in `block in use'","lib/gitlab/application_context.rb:56:in `use'","lib/gitlab/application_context.rb:22:in `with_context'","app/controllers/application_controller.rb:451:in `set_current_context'","lib/gitlab/metrics/elasticsearch_rack_middleware.rb:16:in `call'","lib/gitlab/middleware/rails_queue_duration.rb:33:in `call'","lib/gitlab/metrics/rack_middleware.rb:16:in `block in call'","lib/gitlab/metrics/transaction.rb:56:in `run'","lib/gitlab/metrics/rack_middleware.rb:16:in `call'","lib/gitlab/request_profiler/middleware.rb:17:in `call'","lib/gitlab/jira/middleware.rb:19:in `call'","lib/gitlab/middleware/go.rb:20:in `call'","lib/gitlab/etag_caching/middleware.rb:21:in `call'","lib/gitlab/middleware/multipart.rb:172:in `call'","lib/gitlab/middleware/read_only/controller.rb:50:in `call'","lib/gitlab/middleware/read_only.rb:18:in `call'","lib/gitlab/middleware/same_site_cookies.rb:27:in `call'","lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'","lib/gitlab/middleware/basic_health_check.rb:25:in `call'","lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'","lib/gitlab/middleware/request_context.rb:21:in `call'","config/initializers/fix_local_cache_middleware.rb:11:in `call'","lib/gitlab/metrics/requests_rack_middleware.rb:76:in `call'","lib/gitlab/middleware/release_env.rb:12:in `call'"],"db_duration_s":0.03865,"view_duration_s":0.0,"duration_s":0.52838}
```
#### Results of GitLab environment info
<details>
<summary>Expand for output related to GitLab environment info</summary>
<pre>
System information
System:
Proxy: HTTPS_PROXY: http://172.17.0.1:3128/
HTTP_PROXY: http://172.17.0.1:3128/
http_proxy: http://172.17.0.1:3128
https_proxy: http://172.17.0.1:3128
Current User: git
Using RVM: no
Ruby Version: 2.7.2p137
Gem Version: 3.1.4
Bundler Version:2.1.4
Rake Version: 13.0.3
Redis Version: 6.0.10
Git Version: 2.29.0
Sidekiq Version:5.2.9
Go Version: unknown
GitLab information
Version: 13.9.0-ee
Revision: a1a60e9f753
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 12.5
URL: https://CENSORED
HTTP Clone URL: https://CENSORED/some-group/some-project.git
SSH Clone URL: ssh://git@CENSORED:8022/some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: yes
Using Omniauth: yes
Omniauth Providers: openid_connect
GitLab Shell
Version: 13.16.1
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Git: /opt/gitlab/embedded/bin/git
</pre>
</details>
#### Results of GitLab application Check
<!-- Input any relevant GitLab application check information if needed. -->
<details>
<summary>Expand for output related to the GitLab application check</summary>
<pre>
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 13.16.1 ? ... OK (13.16.1)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Internal API available: OK
Redis available via internal API: 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: ... Checking Reply by email ...
IMAP server credentials are correct? ... Checking incoming-premium
yes
Init.d configured correctly? ... skipped
MailRoom running? ... skipped
Checking Reply by email ... Finished
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
User output sanitized. Found 100 users of 100 limit.
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: ...
2/1 ... yes
2/2 ... yes
13/3 ... yes
14/5 ... yes
18/7 ... yes
19/8 ... yes
23/10 ... yes
24/11 ... yes
25/12 ... yes
25/13 ... yes
25/14 ... yes
26/15 ... yes
27/16 ... yes
28/17 ... yes
21/18 ... yes
21/19 ... yes
21/20 ... yes
30/21 ... yes
2/22 ... yes
2/23 ... yes
32/24 ... yes
32/25 ... yes
35/26 ... yes
2/27 ... yes
36/28 ... yes
36/29 ... yes
48/30 ... yes
49/31 ... yes
50/32 ... yes
50/33 ... yes
50/34 ... yes
52/35 ... yes
21/38 ... yes
59/39 ... yes
59/41 ... yes
59/42 ... yes
60/43 ... yes
16/44 ... yes
59/45 ... yes
59/46 ... yes
68/47 ... yes
71/48 ... yes
72/49 ... yes
75/51 ... yes
74/52 ... yes
74/53 ... yes
79/56 ... yes
74/57 ... yes
15/58 ... yes
85/60 ... yes
57/61 ... yes
58/62 ... yes
88/63 ... yes
84/64 ... yes
74/65 ... yes
73/66 ... yes
98/67 ... yes
2/69 ... yes
98/70 ... yes
93/71 ... yes
2/72 ... yes
15/73 ... yes
103/74 ... yes
103/75 ... yes
60/76 ... yes
98/77 ... yes
98/78 ... yes
98/82 ... yes
115/83 ... yes
98/84 ... yes
119/86 ... yes
120/87 ... yes
120/88 ... yes
98/89 ... yes
98/90 ... yes
98/92 ... yes
98/93 ... yes
98/94 ... yes
123/96 ... yes
93/99 ... yes
93/101 ... yes
57/102 ... yes
93/106 ... yes
69/107 ... yes
93/108 ... yes
93/109 ... yes
63/110 ... yes
134/111 ... yes
93/112 ... yes
138/113 ... yes
151/114 ... yes
Redis version >= 4.0.0? ... yes
Ruby version >= 2.7.2 ? ... yes (2.7.2)
Git version >= 2.29.0 ? ... yes (2.29.0)
Git user has default SSH configuration? ... yes
Active users: ... 67
Is authorized keys file accessible? ... yes
GitLab configured to store new projects in hashed storage? ... yes
All projects are in hashed storage? ... yes
Elasticsearch version 7.x (6.4 - 6.x deprecated to be removed in 13.8)? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
</pre>
</details>
## Workarounds
See https://docs.gitlab.com/ee/administration/feature_flags.html for feature flags administration
Disable the feature by executing the following in your Rails console
```
Feature.disable(:subscribable_license_banner)
```
https://gitlab.com/gitlab-org/gitlab/-/issues/322546#note_521014277
issue