gitlab-tools icon indicating copy to clipboard operation
gitlab-tools copied to clipboard

Refactor fingerprint check to use ssh info from gitlab project instead of hardcoded one in config

Open Salamek opened this issue 1 year ago • 3 comments

Issue

Currently when checking fingerprint, we use GITLAB_SSH config option with hostname:port of gitlab SSH server, but gitlab API actually returns a ssh URI for created/existing project. Issue is that project creation is handled in async task (celery) and no user interaction is possible, that means that mirror has to already exist in database when task is triggered...

Salamek avatar Nov 19 '22 22:11 Salamek

Hello @Salamek ,

I suppose the error I am getting whenever I try to update any of the existing configuration is related to this.

gitlab-tools-gitlab-tools-1  | [app] [2023-04-02 01:35:02,180] ERROR in app: Exception on /fingerprint/fingerprint-check [POST]
gitlab-tools-gitlab-tools-1  | [app] Traceback (most recent call last):
gitlab-tools-gitlab-tools-1  | [app]   File "/opt/gitlab-tools/venv/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
gitlab-tools-gitlab-tools-1  | [app]     response = self.full_dispatch_request()
gitlab-tools-gitlab-tools-1  | [app]   File "/opt/gitlab-tools/venv/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
gitlab-tools-gitlab-tools-1  | [app]     rv = self.handle_user_exception(e)
gitlab-tools-gitlab-tools-1  | [app]   File "/opt/gitlab-tools/venv/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
gitlab-tools-gitlab-tools-1  | [app]     reraise(exc_type, exc_value, tb)
gitlab-tools-gitlab-tools-1  | [app]   File "/opt/gitlab-tools/venv/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
gitlab-tools-gitlab-tools-1  | [app]     raise value
gitlab-tools-gitlab-tools-1  | [app]   File "/opt/gitlab-tools/venv/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
gitlab-tools-gitlab-tools-1  | [app]     rv = self.dispatch_request()
gitlab-tools-gitlab-tools-1  | [app]   File "/opt/gitlab-tools/venv/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
gitlab-tools-gitlab-tools-1  | [app]     return self.view_functions[rule.endpoint](**req.view_args)
gitlab-tools-gitlab-tools-1  | [app]   File "/opt/gitlab-tools/venv/lib/python3.9/site-packages/flask_login/utils.py", line 272, in decorated_view
gitlab-tools-gitlab-tools-1  | [app]     return func(*args, **kwargs)
gitlab-tools-gitlab-tools-1  | [app]   File "./gitlab_tools/views/fingerprint/index.py", line 163, in check_hostname_fingerprint
gitlab-tools-gitlab-tools-1  | [app]     return check_fingerprint_hostname(hostname)
gitlab-tools-gitlab-tools-1  | [app]   File "./gitlab_tools/views/fingerprint/index.py", line 39, in check_fingerprint_hostname
gitlab-tools-gitlab-tools-1  | [app]     found, remote_server_key = check_hostname(hostname, known_hosts_path)
gitlab-tools-gitlab-tools-1  | [app]   File "./gitlab_tools/tools/fingerprint.py", line 31, in check_hostname
gitlab-tools-gitlab-tools-1  | [app]     remote_server_key = get_remote_server_key_for_hostname(hostname)
gitlab-tools-gitlab-tools-1  | [app]   File "./gitlab_tools/tools/fingerprint.py", line 12, in get_remote_server_key_for_hostname
gitlab-tools-gitlab-tools-1  | [app]     return get_remote_server_key(hostname)
gitlab-tools-gitlab-tools-1  | [app]   File "./gitlab_tools/tools/crypto.py", line 72, in get_remote_server_key
gitlab-tools-gitlab-tools-1  | [app]     my_socket.connect((ip, port))
gitlab-tools-gitlab-tools-1  | [app] socket.gaierror: [Errno -2] Name or service not known

Is there any workaround for this?

cenk1cenk2 avatar Apr 01 '23 23:04 cenk1cenk2

@cenk1cenk2 did you set

GITLAB_SSH = 'gitlab.your-domain.com:22'

in your /etc/gitlab-tools/config.yml ? as is mentioned in 1.3 release notes?

Salamek avatar Apr 02 '23 12:04 Salamek

Yeah, sorry I suppose I have missed one and failed to read the release note since directly updated to 1.4.4.

Sorry for taking your time the reply but I really do appreciate it!

Have a very nice day @Salamek!

cenk1cenk2 avatar Apr 02 '23 13:04 cenk1cenk2