Merge lp:~stylesen/lava-scheduler/multinode into lp:lava-scheduler/multinode

Proposed by Senthil Kumaran S
Status: Merged
Approved by: Neil Williams
Approved revision: 278
Merged at revision: 278
Proposed branch: lp:~stylesen/lava-scheduler/multinode
Merge into: lp:lava-scheduler/multinode
Diff against target: 55 lines (+22/-1)
2 files modified
lava_scheduler_app/models.py (+2/-1)
lava_scheduler_app/utils.py (+20/-0)
To merge this branch: bzr merge lp:~stylesen/lava-scheduler/multinode
Reviewer Review Type Date Requested Status
Neil Williams Approve
Linaro Automation & Validation Pending
Review via email: mp+180797@code.launchpad.net

Description of the change

Handle submissions to localhost in MultiNode - https://cards.linaro.org/browse/LAVA-611

To post a comment you must log in.
Revision history for this message
Neil Williams (codehelp) wrote :

There are secondary issues here. See the test on multinode.v.l.o with this patch applied:
http://multinode.validation.linaro.org/scheduler/job/2305/log_file

The definition still shows localhost, the logfile also shows localhost but the link to the results bundle does work.
  <LAVA_DISPATCHER>2013-08-19 10:39:57 AM INFO: Dashboard : http://localhost/dashboard/permalink/bundle/b61368265dd6f9929a7de6fceff2a04ac2ffc1e2/

So the effect of the patch is correct but the resulting output is confusing. It may be best to do the substitution in the Job Definition so that the output is consistent.

review: Needs Information
Revision history for this message
Senthil Kumaran S (stylesen) wrote :

Hi Neil,

On Monday 19 August 2013 04:13 PM, Neil Williams wrote:
> There are secondary issues here. See the test on multinode.v.l.o with this patch applied:
> http://multinode.validation.linaro.org/scheduler/job/2305/log_file
>
> The definition still shows localhost, the logfile also shows localhost but the link to the results bundle does work.
> <LAVA_DISPATCHER>2013-08-19 10:39:57 AM INFO: Dashboard : http://localhost/dashboard/permalink/bundle/b61368265dd6f9929a7de6fceff2a04ac2ffc1e2/
>
> So the effect of the patch is correct but the resulting output is confusing. It may be best to do the substitution in the Job Definition so that the output is consistent.

My patch applies only to multinode job files. I haven't attempted to
change it for single node job files! I shall fix it and request a review
shortly.

Thank You.
--
Senthil Kumaran
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

278. By Senthil Kumaran S

Rewrite hostname in case of localhost/127.0.0.* provided in submit_results*
for multinode and singlenode in a clean way.

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

On Monday 19 August 2013 04:13 PM, Neil Williams wrote:
> There are secondary issues here. See the test on multinode.v.l.o with this patch applied:
> http://multinode.validation.linaro.org/scheduler/job/2305/log_file
>
> The definition still shows localhost, the logfile also shows localhost but the link to the results bundle does work.
> <LAVA_DISPATCHER>2013-08-19 10:39:57 AM INFO: Dashboard : http://localhost/dashboard/permalink/bundle/b61368265dd6f9929a7de6fceff2a04ac2ffc1e2/
>
> So the effect of the patch is correct but the resulting output is confusing. It may be best to do the substitution in the Job Definition so that the output is consistent.

I fixed this and re-requested a review.

Thank You.
--
Senthil Kumaran
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

Revision history for this message
Neil Williams (codehelp) wrote :

Tested and approved, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_scheduler_app/models.py'
2--- lava_scheduler_app/models.py 2013-08-16 07:59:57 +0000
3+++ lava_scheduler_app/models.py 2013-08-19 11:59:29 +0000
4@@ -512,6 +512,7 @@
5 bundle_stream.is_public)
6 server = action['parameters']['server']
7 parsed_server = urlparse.urlsplit(server)
8+ action["parameters"]["server"] = utils.rewrite_hostname(server)
9 if parsed_server.hostname is None:
10 raise ValueError("invalid server: %s" % server)
11
12@@ -558,7 +559,7 @@
13
14 else:
15 job = TestJob(
16- definition=json_data, submitter=submitter,
17+ definition=simplejson.dumps(job_data), submitter=submitter,
18 requested_device=target, requested_device_type=device_type,
19 description=job_name, health_check=health_check, user=user,
20 group=group, is_public=is_public, priority=priority)
21
22=== modified file 'lava_scheduler_app/utils.py'
23--- lava_scheduler_app/utils.py 2013-08-19 11:00:08 +0000
24+++ lava_scheduler_app/utils.py 2013-08-19 11:59:29 +0000
25@@ -17,10 +17,30 @@
26 # You should have received a copy of the GNU Affero General Public License
27 # along with LAVA Scheduler. If not, see <http://www.gnu.org/licenses/>.
28
29+import re
30 import copy
31+import socket
32+import urlparse
33 import simplejson
34
35
36+def rewrite_hostname(result_url):
37+ """If URL has hostname value as localhost/127.0.0.*, change it to the
38+ actual server FQDN.
39+
40+ Returns the RESULT_URL (string) re-written with hostname.
41+
42+ See https://cards.linaro.org/browse/LAVA-611
43+ """
44+ host = urlparse.urlparse(result_url).netloc
45+ if host == "localhost":
46+ result_url = result_url.replace("localhost", socket.getfqdn())
47+ elif host.startswith("127.0.0"):
48+ ip_pat = r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
49+ result_url = re.sub(ip_pat, socket.getfqdn(), result_url)
50+ return result_url
51+
52+
53 def split_multi_job(json_jobdata, target_group):
54 node_json = {}
55 all_nodes = {}

Subscribers

People subscribed via source and target branches

to status/vote changes: