Adding a deploy key when there is a `Maximum allowed lifetime for SSH keys` results in a jumbled and (slightly) duplicated error message
Summary
Under the following conditions:
- There is a
Maximum allowed lifetime for SSH keys
set on the instance - Attempting to add a deploy key into a project.
We receive a strange jumbled and (slightly) duplicated error message:
Key has no expiration date but an expiration date is required for SSH keys on this instance. Contact the instance administrator., Deploy keys
projects deploy key key has no expiration date but an expiration date is required for SSH keys on this instance. Contact the instance administrator.
Steps to reproduce
- Set a
Maximum allowed lifetime for SSH keys
underadmin/application_settings/general
- Attempt to add a deploy key to a project.
- Observe error message.
What is the current bug behavior?
The error message is very strange.
What is the expected correct behavior?
The error message is clear on what the issue is. For example:
Deploy keys have no expiration date but an expiration date is required for SSH keys on this instance. Contact the instance administrator.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Ubuntu 20.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.7.5p203 Gem Version: 3.1.6 Bundler Version:2.3.15 Rake Version: 13.0.6 Redis Version: 6.2.7 Sidekiq Version:6.4.2 Go Version: unknown GitLab information Version: 15.4.2-ee Revision: 4eacd5378ab Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 12.10 URL: https://example.gitlab.com HTTP Clone URL: https://example.gitlab.com/some-group/some-project.git SSH Clone URL: git@example.gitlab.com:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.10.0 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
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 >= 14.10.0 ? ... OK (14.10.0) 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 (cluster/worker) ... 1/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 ...
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 Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither initscript nor systemd units) Projects have namespace: ... 2/1 ... yes 12/2 ... yes 12/3 ... yes 12/4 ... yes 13/5 ... yes 13/6 ... yes 14/7 ... yes 14/8 ... yes 14/9 ... yes 15/10 ... yes 15/11 ... yes 29/12 ... yes 31/13 ... yes 35/14 ... yes 1/17 ... yes 1/18 ... yes 42/19 ... yes 1/21 ... yes 26/22 ... yes 1/23 ... yes 1/24 ... yes 1/25 ... yes 1/26 ... yes 1/27 ... yes 1/28 ... yes 1/29 ... yes 69/30 ... yes 1/31 ... yes 1/32 ... yes 1/33 ... yes 1/35 ... yes 84/36 ... yes 1/37 ... yes 1/38 ... yes 1/39 ... yes 1/40 ... yes 1/41 ... yes 12/42 ... yes 1/43 ... yes 1/44 ... yes 95/45 ... yes 95/46 ... yes 1/47 ... yes 1/48 ... yes Redis version >= 6.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.5) Git user has default SSH configuration? ... yes Active users: ... 17 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-8.x or OpenSearch version 1.x ... skipped (Advanced Search is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
It seems accepts_nested_attributes_for :deploy_key
in DeployKeysProject
is triggering validate
again. We should remove it if unnecessary.