From 267c657a6c0206580eefb8c4dca6da99b86c7c25 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 4 Feb 2025 11:46:31 +0000 Subject: [PATCH] jobs: Drop the control connection Signed-off-by: Michael Tremer --- src/web/__init__.py | 2 -- src/web/jobs.py | 55 --------------------------------------------- 2 files changed, 57 deletions(-) diff --git a/src/web/__init__.py b/src/web/__init__.py index 65d3f8f4..f341c911 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -114,8 +114,6 @@ class Application(tornado.web.Application): (r"/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/abort", jobs.AbortHandler), (r"/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/log", jobs.LogHandler), (r"/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/retry", jobs.RetryHandler), - (r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})", - jobs.APIv1ControlHandler), (r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})", jobs.APIv1IndexHandler), (r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/crashed", jobs.APIv1CrashedHandler), diff --git a/src/web/jobs.py b/src/web/jobs.py index 05f69ffc..6c609a40 100644 --- a/src/web/jobs.py +++ b/src/web/jobs.py @@ -10,61 +10,6 @@ from . import base # Setup logging log = logging.getLogger("pbs.web.jobs") -class APIv1ControlHandler(base.APIMixin, base.BackendMixin, tornado.websocket.WebSocketHandler): - """ - Builders connect to this handler when they are running a build. - - We can pass information about this build around in real time. - """ - # Don't allow users to authenticate - allow_users = False - - @base.negotiate - async def open(self, job_id): - self.job = await self.backend.jobs.get_by_uuid(job_id) - if not self.job: - raise tornado.web.HTTPError(404, "Could not find job %s" % job_id) - - # Check permissions - if not self.job.has_perm(self.current_user): - raise tornado.web.HTTPError(403, "%s cannot control job %s" \ - % (self.current_user, self.job)) - - # Consider the job connected - self.job.connected(self) - - # Open a new log stream - self.logstream = self.backend.logstreams.open(self.job) - - def on_close(self): - # Drop the connection to the builder - self.job.disconnected() - - # Close the logstream - self.logstream.close() - - async def on_message(self, message): - message = self._decode_json_message(message) - - # Get message type & data - type = message.get("type") - data = message.get("data") - - # Handle log messages - if type == "log": - await self._handle_log(**data) - - # Unknown message - else: - log.warning("Received a message of an unknown type: %s" % t) - - async def _handle_log(self, timestamp=None, level=None, message=None, **kwargs): - """ - Called when a new log message has been received - """ - await self.logstream.message(timestamp, level, message) - - class APIv1IndexHandler(base.APIMixin, tornado.web.RequestHandler): @base.negotiate async def post(self, uuid): -- 2.47.3