From cc95d679bdde99e016b98b979115ae297e92f2ba Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 28 Feb 2018 10:05:37 +1100 Subject: [PATCH] Revert "Add /label-list to the webapp" This reverts commit b7378892502836f257456cd277190ee75a7ca75f. As discussed in [1] the label list is intended to provide a list of available labels so users don't have to dig into configuration files to determine what is available to run jobs on. As written it possibly misses nodes without a min-ready or in-use nodes, so an alternative implementation is probably called for. This is also currently returns values in a plain list, rather than a list of dicts, which prevents some de-deuplication refactoring. Thus remove it for now, pending some more work. [1] http://lists.zuul-ci.org/pipermail/zuul-discuss/2018-February/000039.html Change-Id: Ic88da24dd5d140697d4af8e6f5ee0936c44f59c5 --- nodepool/status.py | 16 ---------------- nodepool/tests/test_webapp.py | 21 --------------------- nodepool/webapp.py | 6 ------ 3 files changed, 43 deletions(-) diff --git a/nodepool/status.py b/nodepool/status.py index 719275d3a..942dac447 100755 --- a/nodepool/status.py +++ b/nodepool/status.py @@ -135,22 +135,6 @@ def node_list(zk, node_id=None, detail=False, format='pretty'): raise ValueError('Unknown format "%s"' % format) -def label_list(zk, format='pretty'): - labels = set() - for node in zk.nodeIterator(): - labels.add(node.type) - if format == 'pretty': - t = PrettyTable(["Label", ]) - t.align = 'l' - for label in labels: - t.add_row(label) - return str(t) - elif format == 'json': - return json.dumps(list(labels)) - else: - raise ValueError('Unknown format "%s"' % format) - - def dib_image_list(zk, format='pretty'): headers_table = OrderedDict([ ("id", "ID"), diff --git a/nodepool/tests/test_webapp.py b/nodepool/tests/test_webapp.py index a4f64f66a..1c79784d6 100644 --- a/nodepool/tests/test_webapp.py +++ b/nodepool/tests/test_webapp.py @@ -147,27 +147,6 @@ class TestWebApp(tests.DBTestCase): objs = json.loads(data.decode('utf8')) self.assertEqual(0, len(objs), objs) - def test_label_list_json(self): - configfile = self.setup_config('node.yaml') - pool = self.useNodepool(configfile, watermark_sleep=1) - self.useBuilder(configfile) - pool.start() - webapp = self.useWebApp(pool, port=0) - webapp.start() - port = webapp.server.socket.getsockname()[1] - - self.waitForImage('fake-provider', 'fake-image') - self.waitForNodes('fake-label') - - req = request.Request( - "http://localhost:%s/label-list.json" % port) - f = request.urlopen(req) - self.assertEqual(f.info().get('Content-Type'), - 'application/json') - data = f.read() - objs = json.loads(data.decode('utf8')) - self.assertEqual(['fake-label'], objs) - def test_request_list_json(self): configfile = self.setup_config('node.yaml') pool = self.useNodepool(configfile, watermark_sleep=1) diff --git a/nodepool/webapp.py b/nodepool/webapp.py index 9bb479614..99978de8a 100644 --- a/nodepool/webapp.py +++ b/nodepool/webapp.py @@ -104,12 +104,6 @@ class WebApp(threading.Thread): output = status.node_list(self.nodepool.getZK(), format='json', node_id=params.get('node_id')) - elif path == '/label-list': - output = status.label_list(self.nodepool.getZK(), - format='pretty') - elif path == '/label-list.json': - output = status.label_list(self.nodepool.getZK(), - format='json') elif path == '/request-list': output = status.request_list(self.nodepool.getZK(), format='pretty')