Skip to content

Commit

Permalink
address comments and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Grubenmann committed Feb 24, 2023
1 parent 6883d74 commit be1722c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
9 changes: 9 additions & 0 deletions renku/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,15 @@ def __init__(self):
super(SSHNotFoundError, self).__init__(msg)


class SSHNotSetupError(RenkuException):
"""Raised when SSH client is not installed on the system."""

def __init__(self):
"""Build a custom message."""
msg = "SSH is not set up correctly, use 'renku session ssh-setup' to set it up."
super(SSHNotSetupError, self).__init__(msg)


class ObjectNotFoundError(RenkuException):
"""Raised when an object is not found in the storage."""

Expand Down
2 changes: 1 addition & 1 deletion renku/core/session/renkulab.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def pre_start_checks(self, ssh: bool = False, **kwargs):

if not system_config.is_configured:
if communication.confirm(
"Your system is not set up for SSH connections to Renku. Would you like to set it up?"
"Your system is not set up for SSH connections to Renkulab. Would you like to set it up?"
):
ssh_setup()
else:
Expand Down
3 changes: 3 additions & 0 deletions renku/core/util/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ def setup_session_keys(self):
project_context.ssh_authorized_keys_path.parent.mkdir(parents=True, exist_ok=True)
project_context.ssh_authorized_keys_path.touch(mode=0o600, exist_ok=True)

if not self.public_key_string:
raise errors.SSHNotSetupError()

if self.public_key_string in project_context.ssh_authorized_keys_path.read_text():
return

Expand Down
4 changes: 2 additions & 2 deletions renku/ui/cli/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@
.. code-block:: console
$ renku session start -p renkulab --ssh
Your system is not set up for SSH connections to Renku. Would you like to set it up? [y/N]: y
Your system is not set up for SSH connections to Renkulab. Would you like to set it up? [y/N]: y
[...]
SSH connection successfully configured, use 'ssh renkulab.io-myproject-sessionid' to connect.
Session sessionid successfully started, use 'renku session open --ssh sessionid' or 'ssh sessionid' to connect to it
This will create SSH keys for you and setup SSH configuration for connecting to the renku deployment.
You can then use the SSH connection name (``ssh renkulab.io-myproject-sessionid`` in the example)
Expand Down
2 changes: 0 additions & 2 deletions tests/cli/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def test_session_ssh_setup(runner, project, dummy_session_provider, fake_home):
with patch("renku.core.util.ssh.get_renku_url", lambda: "https://renkulab.io/"):
result = runner.invoke(cli, ["session", "ssh-setup"])
assert 0 == result.exit_code, format_result_exception(result)
assert 2 == len(result.output.splitlines())
assert "Generating keys" in result.output
assert "Writing SSH config" in result.output

Expand All @@ -104,6 +103,5 @@ def test_session_ssh_setup(runner, project, dummy_session_provider, fake_home):
result = runner.invoke(cli, ["session", "ssh-setup", "-k", str(private_path), "--force"])
assert 0 == result.exit_code, format_result_exception(result)

assert 2 == len(result.output.splitlines())
assert "Linking existing keys" in result.output
assert "Writing SSH config" in result.output

0 comments on commit be1722c

Please sign in to comment.