Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend: print user SSH instructions before the build starts #3184

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions backend/copr_backend/background_worker_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ def _setup_for_user_ssh(self):
return
self._alloc_root_ssh_connection()
self._deploy_user_ssh()
self._log_user_ssh_instructions()
self._set_default_expiration()

def _alloc_root_ssh_connection(self):
Expand All @@ -815,6 +816,18 @@ def _alloc_root_ssh_connection(self):
log=self.log,
)

def _log_user_ssh_instructions(self):
expiration = datetime.fromtimestamp(
self.job.started_on + USER_SSH_DEFAULT_EXPIRATION)

self.log.info("The owner of this build can connect using:")
self.log.info("ssh root@%s", self.host.hostname)
self.log.info("Unless you connect to the builder and prolong its "
"expiration, it will be shut-down in %s",
expiration.strftime("%Y-%m-%d %H:%M"))
self.log.info("After connecting, run `copr-builder help' for "
"complete instructions")

def _deploy_user_ssh(self):
"""
Deploy user public key to the builder, so that they can connect via SSH.
Expand Down Expand Up @@ -873,14 +886,7 @@ def _keep_alive_for_user_ssh(self):

# Highlight this portion of the log because it is the only part of
# the backend.log that is directly for the end users
self.log.info("\n\nKeeping builder alive for user SSH")
self.log.info("The owner of this build can connect using:")
self.log.info("ssh root@%s", self.host.hostname)
self.log.info("Unless you connect to the builder and prolong its "
"expiration, it will be shut-down in %s",
default.strftime("%Y-%m-%d %H:%M"))
self.log.info("After connecting, run `copr-builder help' for "
"complete instructions\n\n")
self.log.info("Keeping builder alive for user SSH")

def _keep_alive():
while True:
Expand Down