From 5f472413c93008929d895ab2ccd024af4d8da6bc Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Mon, 7 Sep 2020 12:48:11 +0200 Subject: [PATCH] drop host versions --- cli/koji_cli/commands.py | 14 +------------- docs/schema.sql | 3 +-- hub/kojihub.py | 22 ++++++++-------------- koji/daemon.py | 6 ++---- tests/test_hub/test_get_host.py | 8 ++++---- www/kojiweb/api.chtml | 2 +- www/kojiweb/hostinfo.chtml | 3 --- www/kojiweb/index.py | 1 - 8 files changed, 17 insertions(+), 42 deletions(-) diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index ff51f70e..8a0b8874 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -2843,7 +2843,6 @@ def anon_handle_list_hosts(goptions, session, args): parser.add_option("--quiet", action="store_true", default=goptions.quiet, help=_("Do not print header information")) parser.add_option("--show-channels", action="store_true", help=_("Show host's channels")) - parser.add_option("--show-version", action="store_true", help=_("Show host's' version")) (options, args) = parser.parse_args(args) opts = {} ensure_connection(session) @@ -2897,24 +2896,14 @@ def anon_handle_list_hosts(goptions, session, args): if not options.quiet: hdr = "{hostname:<{longest_host}} Enb Rdy Load/Cap Arches Last Update".format( longest_host=longest_host, hostname='Hostname') - if options.show_version: - hdr += " Version" if options.show_channels: - hdr += " Channels" + hdr += " Channels" print(hdr) mask = "%%(name)-%ss %%(enabled)-3s %%(ready)-3s %%(task_load)4.1f/%%(capacity)-4.1f " \ "%%(arches)-16s %%(update)-19s" % longest_host - if options.show_version: - mask += " %(version)-10s" if options.show_channels: mask += " %(channels)s" for host in hosts: - if host.get('version') is None: - # hub doesn't support it, so we don't know the version - host['version'] = 'not supported' - elif not host.get('version'): - # hub supports it, but builder doesn't report - host['version'] = '-' print(mask % host) @@ -3341,7 +3330,6 @@ def anon_handle_hostinfo(goptions, session, args): print("%s%s" % (" " * 9, line)) else: print("Comment:") - print('Version: %s' % info['version']) print("Enabled: %s" % (info['enabled'] and 'yes' or 'no')) print("Ready: %s" % (info['ready'] and 'yes' or 'no')) update = session.getLastHostUpdate(info['id']) diff --git a/docs/schema.sql b/docs/schema.sql index 574e5be4..3fbcd27c 100644 --- a/docs/schema.sql +++ b/docs/schema.sql @@ -156,8 +156,7 @@ CREATE TABLE host ( user_id INTEGER NOT NULL REFERENCES users (id), name VARCHAR(128) UNIQUE NOT NULL, task_load FLOAT CHECK (NOT task_load < 0) NOT NULL DEFAULT 0.0, - ready BOOLEAN NOT NULL DEFAULT 'false', - version VARCHAR(10) NOT NULL DEFAULT '' + ready BOOLEAN NOT NULL DEFAULT 'false' ) WITHOUT OIDS; CREATE TABLE host_config ( diff --git a/hub/kojihub.py b/hub/kojihub.py index 71216270..aa18a8d9 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -5190,7 +5190,6 @@ def get_host(hostInfo, strict=False, event=None): - comment - ready - enabled - - version """ tables = ['host_config'] joins = ['host ON host.id = host_config.host_id'] @@ -5200,7 +5199,6 @@ def get_host(hostInfo, strict=False, event=None): 'host.name': 'name', 'host.ready': 'ready', 'host.task_load': 'task_load', - 'host.version': 'version', 'host_config.arches': 'arches', 'host_config.capacity': 'capacity', 'host_config.description': 'description', @@ -12487,7 +12485,6 @@ class RootExports(object): 'host.name': 'name', 'host.ready': 'ready', 'host.task_load': 'task_load', - 'host.version': 'version', 'host_config.arches': 'arches', 'host_config.capacity': 'capacity', 'host_config.description': 'description', @@ -13450,17 +13447,14 @@ class Host(object): task['alert'] = True return tasks - def updateHost(self, task_load, ready, resources=None): + def updateHost(self, task_load, ready): host_data = get_host(self.id) - if task_load != host_data['task_load'] or \ - ready != host_data['ready'] or \ - resources and resources.get('version') and host_data['version'] != resources['version']: + if task_load != host_data['task_load'] or ready != host_data['ready']: + c = context.cnx.cursor() id = self.id - update = UpdateProcessor('host', clauses=['id=%(id)s'], values=locals()) - update.set(task_load=task_load, ready=ready) - if resources and 'version' in resources: - update.set(version=resources['version']) - update.execute() + q = """UPDATE host SET task_load=%(task_load)s,ready=%(ready)s WHERE id=%(id)s""" + c.execute(q, locals()) + context.commit_pending = True def getLoadData(self): """Get load balancing data @@ -13538,10 +13532,10 @@ class HostExports(object): host.verify() return host.id - def updateHost(self, task_load, ready, resources=None): + def updateHost(self, task_load, ready): host = Host() host.verify() - host.updateHost(task_load, ready, resources=resources) + host.updateHost(task_load, ready) def getLoadData(self): host = Host() diff --git a/koji/daemon.py b/koji/daemon.py index 39ccc887..fea59701 100644 --- a/koji/daemon.py +++ b/koji/daemon.py @@ -633,8 +633,7 @@ class TaskManager(object): for task_id in self.pids: self.cleanupTask(task_id) self.session.host.freeTasks(to_list(self.tasks.keys())) - self.session.host.updateHost(task_load=0.0, ready=False, - resources={'version': koji.__version__}) + self.session.host.updateHost(task_load=0.0, ready=False) def updateBuildroots(self, nolocal=False): """Handle buildroot cleanup/maintenance @@ -892,8 +891,7 @@ class TaskManager(object): def getNextTask(self): self.ready = self.readyForTask() - self.session.host.updateHost(self.task_load, self.ready, - resources={'version': koji.__version__}) + self.session.host.updateHost(self.task_load, self.ready) if not self.ready: self.logger.info("Not ready for task") return False diff --git a/tests/test_hub/test_get_host.py b/tests/test_hub/test_get_host.py index e5149408..7bf38d01 100644 --- a/tests/test_hub/test_get_host.py +++ b/tests/test_hub/test_get_host.py @@ -33,11 +33,11 @@ class TestSetHostEnabled(unittest.TestCase): self.assertEqual(len(self.queries), 1) query = self.queries[0] columns = ['host.id', 'host.user_id', 'host.name', 'host.ready', - 'host.task_load', 'host.version', 'host_config.arches', + 'host.task_load', 'host_config.arches', 'host_config.capacity', 'host_config.description', 'host_config.comment', 'host_config.enabled'] joins = ['host ON host.id = host_config.host_id'] - aliases = ['id', 'user_id', 'name', 'ready', 'task_load', 'version', + aliases = ['id', 'user_id', 'name', 'ready', 'task_load', 'arches', 'capacity', 'description', 'comment', 'enabled'] clauses = ['(host_config.active = TRUE)', 'host.name = %(hostInfo)s'] values = {'hostInfo': 'hostname'} @@ -54,11 +54,11 @@ class TestSetHostEnabled(unittest.TestCase): self.assertEqual(len(self.queries), 1) query = self.queries[0] columns = ['host.id', 'host.user_id', 'host.name', 'host.ready', - 'host.task_load', 'host.version', 'host_config.arches', + 'host.task_load', 'host_config.arches', 'host_config.capacity', 'host_config.description', 'host_config.comment', 'host_config.enabled'] joins = ['host ON host.id = host_config.host_id'] - aliases = ['id', 'user_id', 'name', 'ready', 'task_load', 'version', + aliases = ['id', 'user_id', 'name', 'ready', 'task_load', 'arches', 'capacity', 'description', 'comment', 'enabled'] clauses = ['(host_config.create_event <= 345 AND ( host_config.revoke_event IS NULL OR 345 < host_config.revoke_event ))', 'host.id = %(hostInfo)i'] diff --git a/www/kojiweb/api.chtml b/www/kojiweb/api.chtml index 729d4888..1a23dbf5 100644 --- a/www/kojiweb/api.chtml +++ b/www/kojiweb/api.chtml @@ -1,7 +1,7 @@ #include "includes/header.chtml" #import koji -

API reference (API version: $api_version, hub version: $koji_version, web version: $koji.__version__)

+

API reference (hub version: $koji_version, web version: $koji.__version__)