Skip to content

Commit 7a7a598

Browse files
committed
Merge branch '0.9.x' of github.com:pricingassistant/mrq into 0.9.x
* '0.9.x' of github.com:pricingassistant/mrq: update known queues when requeuing jobs fix makefile add minified js add external ip on dashboard add external ip in config don't search entire queue fix runtime error in get_worker_report Correctly patch HTTPConnection.request for Python 3.6 (#184) add task to repopulate known queues
2 parents 0503a0f + b8d7112 commit 7a7a598

11 files changed

Lines changed: 75 additions & 10 deletions

File tree

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ clean:
4444
find . -path ./venv -prune -o -name "*.pyc" -exec rm {} \;
4545
find . -name __pycache__ | xargs rm -r
4646

47+
build_dashboard:
48+
cd mrq/dashboard/static && npm install && mkdir -p bin && npm run build
49+
4750
dashboard:
4851
python mrq/dashboard/app.py
4952

mrq/basetasks/cleaning.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ def run(self, params):
8888
Queue(str(queue)).add_to_known_queues()
8989

9090

91+
class PopulateKnownQueues(Task):
92+
93+
"""
94+
Populates the known queues in Redis.
95+
"""
96+
97+
def run(self, params):
98+
99+
queues = Queue.all()
100+
for queue in queues:
101+
Queue(queue, add_to_known_queues=True)
102+
103+
91104
class CleanKnownQueues(Task):
92105

93106
"""
@@ -123,8 +136,9 @@ def run(self, params):
123136
q = Queue(queue, add_to_known_queues=False)
124137
size = q.size()
125138
if check_mongo:
126-
size += connections.mongodb_jobs.mrq_jobs.count({"queue": queue})
127-
if size == 0:
139+
has_job = connections.mongodb_jobs.mrq_jobs.find_one({"queue": queue})
140+
141+
if size == 0 or has_job is None:
128142
removed_queues.append(queue)
129143
print("Removing empty queue '%s' from known queues ..." % queue)
130144
if not pretend:

mrq/basetasks/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ def perform_action(self, action, query, destination_queue):
134134
"_id": {"$in": jobs_by_queue[queue]}
135135
}, {"$set": updates}, multi=True)
136136

137+
if destination_queue is None:
138+
Queue.ensure_known_queues(jobs_by_queue.iterkeys())
139+
140+
if destination_queue is not None:
141+
Queue.ensure_known_queues([destination_queue])
142+
137143
print(stats)
138144

139145
return stats

mrq/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,13 @@ def add_parser_args(parser, config_type):
454454
type=str,
455455
help='Overwrite the local IP, to be displayed in the dashboard.')
456456

457+
parser.add_argument(
458+
'--external_ip',
459+
default=None,
460+
action="store",
461+
type=str,
462+
help='Overwrite the external IP, to be displayed in the dashboard.')
463+
457464
parser.add_argument(
458465
'--max_latency',
459466
default=1.,

mrq/dashboard/static/bin/0.bundle.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mrq/dashboard/static/js/views/workers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ define(["jquery", "underscore", "views/generic/datatablepage", "models", "moment
5858
"sType":"string",
5959
"sWidth":"150px",
6060
"mData":function(source, type/*, val*/) {
61-
return "<a href='/#jobs?worker="+source._id+"'>"+source.name+"</a><br/><small>"+source.config.local_ip + " " + source._id+"</small>";
61+
return "<a href='/#jobs?worker="+source._id+"'>"+source.name+"</a><br/><small>"+ (source.config.external_ip || source.config.local_ip) + " " + source._id+"</small>";
6262
}
6363
},
6464
{

mrq/dashboard/static/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"name": "mrq-dashboard",
33
"version": "0.9.1",
44
"description": "PricingAssistant MRQ dashboard",
5-
"dependencies": {
6-
},
5+
"dependencies": {},
76
"engines": {
87
"node": "^7.5.0"
98
},

mrq/monkey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def makefile(self, *args, **kwargs):
304304
newsock = self._obj.makefile(*args, **kwargs)
305305
return mrq_wrapped_socket(newsock, self._parent_connection)
306306

307-
def request(old_method, self, method, url, body=None, headers=None):
307+
def request(old_method, self, method, url, body=None, headers=None, *args, **kwargs):
308308

309309
if headers is None:
310310
headers = {}

mrq/queue.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import sys
1212
from future import standard_library
13+
from itertools import chain
1314

1415
PY3 = sys.version_info > (3,)
1516
standard_library.install_aliases()
@@ -119,6 +120,13 @@ def get_retry_queue(self):
119120
""" Return the name of the queue where retried jobs will be queued """
120121
return self.id
121122

123+
@classmethod
124+
def ensure_known_queues(cls, queues):
125+
""" List all previously known queues """
126+
now = time.time()
127+
params = chain.from_iterable((now, queue) for queue in queues)
128+
context.connections.redis.zadd(Queue.redis_key_known_queues(), *params)
129+
122130
def add_to_known_queues(self, timestamp=None):
123131
""" Adds this queue to the shared list of known queues """
124132
now = timestamp or time.time()

mrq/worker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def get_worker_report(self, with_memory=False):
208208
its jobs. """
209209

210210
greenlets = []
211-
for greenlet in self.gevent_pool:
211+
for greenlet in list(self.gevent_pool):
212212
g = {}
213213
short_stack = []
214214
stack = traceback.format_stack(greenlet.gr_frame)
@@ -263,6 +263,7 @@ def get_worker_report(self, with_memory=False):
263263
"scheduler",
264264
"name",
265265
"local_ip",
266+
"external_ip",
266267
"agent_id",
267268
"worker_group",
268269
"worker_profile"

0 commit comments

Comments
 (0)