From dfd5d094bfde86b8595d8938ab0a7a82225f61b9 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Tue, 12 Mar 2024 13:39:55 +0100 Subject: [PATCH] backend: print user SSH instructions before the build starts Fix #3180 --- .../copr_backend/background_worker_build.py | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/backend/copr_backend/background_worker_build.py b/backend/copr_backend/background_worker_build.py index 5bda806db..9f76bf956 100644 --- a/backend/copr_backend/background_worker_build.py +++ b/backend/copr_backend/background_worker_build.py @@ -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): @@ -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. @@ -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: