Use hostname in Nodepool requests

Rather than identifying a Nodepool request as originating from
'zuul', identify it with the hostname of the zuul scheduler.  This
way the operator of a site with multiple zuuls can identify whence
requests originated.

Change-Id: I69aaca90d2bc3fac5fe55cdd9c57d724f6e103b4
This commit is contained in:
James E. Blair 2017-02-19 15:33:55 -08:00
parent 4d263eb38c
commit 8b2a14704f
4 changed files with 7 additions and 3 deletions

View File

@ -37,6 +37,7 @@ class TestNodepool(BaseTestCase):
self.zk = zuul.zk.ZooKeeper()
self.zk.connect(self.zk_config)
self.hostname = 'nodepool-test-hostname'
self.provisioned_requests = []
# This class implements the scheduler methods zuul.nodepool

View File

@ -472,7 +472,8 @@ class NodeSet(object):
class NodeRequest(object):
"""A request for a set of nodes."""
def __init__(self, build_set, job, nodeset):
def __init__(self, requestor, build_set, job, nodeset):
self.requestor = requestor
self.build_set = build_set
self.job = job
self.nodeset = nodeset
@ -507,7 +508,7 @@ class NodeRequest(object):
d = {}
nodes = [n.image for n in self.nodeset.getNodes()]
d['node_types'] = nodes
d['requestor'] = 'zuul' # TODOv3(jeblair): better descriptor
d['requestor'] = self.requestor
d['state'] = self.state
d['state_time'] = self.state_time
return d

View File

@ -26,7 +26,7 @@ class Nodepool(object):
# Create a copy of the nodeset to represent the actual nodes
# returned by nodepool.
nodeset = job.nodeset.copy()
req = model.NodeRequest(build_set, job, nodeset)
req = model.NodeRequest(self.sched.hostname, build_set, job, nodeset)
self.requests[req.uid] = req
self.sched.zk.submitNodeRequest(req, self._updateNodeRequest)

View File

@ -22,6 +22,7 @@ import os
import pickle
import six
from six.moves import queue as Queue
import socket
import sys
import threading
import time
@ -256,6 +257,7 @@ class Scheduler(threading.Thread):
def __init__(self, config, testonly=False):
threading.Thread.__init__(self)
self.daemon = True
self.hostname = socket.gethostname()
self.wake_event = threading.Event()
self.layout_lock = threading.Lock()
self.run_handler_lock = threading.Lock()