Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: site_config/config_default.py

Issue 1688043003: Move master_port_alts from 40000 to 25000 so they don't overlap with ephemeral ports (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Raise an exception if asked to compose a port outside the range Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « scripts/tools/unittests/mastermap_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Seeds a number of variables defined in chromium_config.py. 5 """Seeds a number of variables defined in chromium_config.py.
6 6
7 The recommended way is to fork this file and use a custom DEPS forked from 7 The recommended way is to fork this file and use a custom DEPS forked from
8 config/XXX/DEPS with the right configuration data.""" 8 config/XXX/DEPS with the right configuration data."""
9 9
10 import os 10 import os
11 import re 11 import re
12 import socket 12 import socket
13 13
14 14
15 SERVICE_ACCOUNTS_PATH = '/creds/service_accounts' 15 SERVICE_ACCOUNTS_PATH = '/creds/service_accounts'
16 16
17 17
18 class classproperty(object): 18 class classproperty(object):
19 """A decorator that allows is_production_host to only to be defined once.""" 19 """A decorator that allows is_production_host to only to be defined once."""
20 def __init__(self, getter): 20 def __init__(self, getter):
21 self.getter = getter 21 self.getter = getter
22 def __get__(self, instance, owner): 22 def __get__(self, instance, owner):
23 return self.getter(owner) 23 return self.getter(owner)
24 24
25 25
26 class PortRange(object):
27 def __init__(self, start, end):
28 self.start = start
29 self.end = end
30
31 def compose_port(self, offset):
32 ret = self.start + offset
33 if not self.contains(ret):
34 raise ValueError("Port offset %d must fit within range %d-%d" % (
35 offset, self.start, self.end))
36 return ret
37
38 def contains(self, port):
39 return port >= self.start and port <= self.end
40
41 def offset_of(self, port):
42 return port - self.start
43
44
26 class Master(object): 45 class Master(object):
27 # Repository URLs used by the SVNPoller and 'gclient config'. 46 # Repository URLs used by the SVNPoller and 'gclient config'.
28 server_url = 'http://src.chromium.org' 47 server_url = 'http://src.chromium.org'
29 repo_root = '/svn' 48 repo_root = '/svn'
30 git_server_url = 'https://chromium.googlesource.com' 49 git_server_url = 'https://chromium.googlesource.com'
31 50
32 # External repos. 51 # External repos.
33 googlecode_url = 'http://%s.googlecode.com/svn' 52 googlecode_url = 'http://%s.googlecode.com/svn'
34 sourceforge_url = 'https://svn.code.sf.net/p/%(repo)s/code' 53 sourceforge_url = 'https://svn.code.sf.net/p/%(repo)s/code'
35 googlecode_revlinktmpl = 'https://code.google.com/p/%s/source/browse?r=%s' 54 googlecode_revlinktmpl = 'https://code.google.com/p/%s/source/browse?r=%s'
(...skipping 28 matching lines...) Expand all
64 git_internal_server_url = None 83 git_internal_server_url = None
65 syzygy_internal_url = None 84 syzygy_internal_url = None
66 v8_internal_url = None 85 v8_internal_url = None
67 86
68 87
69 class Base(object): 88 class Base(object):
70 """Master base template. 89 """Master base template.
71 Contains stubs for variables that all masters must define.""" 90 Contains stubs for variables that all masters must define."""
72 91
73 # Base service offset for 'master_port' 92 # Base service offset for 'master_port'
74 MASTER_PORT = 2 93 MASTER_PORT_RANGE = PortRange(20000, 24999)
75 # Base service offset for 'slave_port' 94 # Base service offset for 'slave_port'
76 SLAVE_PORT = 3 95 SLAVE_PORT_RANGE = PortRange(30000, 34999)
77 # Base service offset for 'master_port_alt' 96 # Base service offset for 'master_port_alt'
78 MASTER_PORT_ALT = 4 97 MASTER_PORT_ALT_RANGE = PortRange(25000, 29999)
79 # Base service offset for 'try_job_port' 98 # Base service offset for 'try_job_port'
80 TRY_JOB_PORT = 5 99 TRY_JOB_PORT_RANGE = PortRange(50000, 54999)
81 100
82 # A BuildBucket bucket to poll. 101 # A BuildBucket bucket to poll.
83 buildbucket_bucket = None 102 buildbucket_bucket = None
84 103
85 # Master address. You should probably copy this file in another svn repo 104 # Master address. You should probably copy this file in another svn repo
86 # so you can override this value on both the slaves and the master. 105 # so you can override this value on both the slaves and the master.
87 master_host = 'localhost' 106 master_host = 'localhost'
88 @classproperty 107 @classproperty
89 def current_host(cls): 108 def current_host(cls):
90 return socket.getfqdn() 109 return socket.getfqdn()
91 @classproperty 110 @classproperty
92 def in_production(cls): 111 def in_production(cls):
93 return re.match(r'master.*\.golo\.chromium\.org', cls.current_host) 112 return re.match(r'master.*\.golo\.chromium\.org', cls.current_host)
94 # Only report that we are running on a master if the master_host (even when 113 # Only report that we are running on a master if the master_host (even when
95 # master_host is overridden by a subclass) is the same as the current host. 114 # master_host is overridden by a subclass) is the same as the current host.
96 @classproperty 115 @classproperty
97 def is_production_host(cls): 116 def is_production_host(cls):
98 return cls.current_host == cls.master_host 117 return cls.current_host == cls.master_host
99 118
100 # 'from:' field for emails sent from the server. 119 # 'from:' field for emails sent from the server.
101 from_address = 'nobody@example.com' 120 from_address = 'nobody@example.com'
102 # Additional email addresses to send gatekeeper (automatic tree closage) 121 # Additional email addresses to send gatekeeper (automatic tree closage)
103 # notifications. Unnecessary for experimental masters and try servers. 122 # notifications. Unnecessary for experimental masters and try servers.
104 tree_closing_notification_recipients = [] 123 tree_closing_notification_recipients = []
105 124
106 @classproperty 125 @classproperty
107 def master_port(cls): 126 def master_port(cls):
108 return cls._compose_port(cls.MASTER_PORT) 127 return cls._compose_port(cls.MASTER_PORT_RANGE)
109 128
110 @classproperty 129 @classproperty
111 def slave_port(cls): 130 def slave_port(cls):
112 # Which port slaves use to connect to the master. 131 # Which port slaves use to connect to the master.
113 return cls._compose_port(cls.SLAVE_PORT) 132 return cls._compose_port(cls.SLAVE_PORT_RANGE)
114 133
115 @classproperty 134 @classproperty
116 def master_port_alt(cls): 135 def master_port_alt(cls):
117 # The alternate read-only page. Optional. 136 # The alternate read-only page. Optional.
118 return cls._compose_port(cls.MASTER_PORT_ALT) 137 return cls._compose_port(cls.MASTER_PORT_ALT_RANGE)
119 138
120 @classproperty 139 @classproperty
121 def try_job_port(cls): 140 def try_job_port(cls):
122 return cls._compose_port(cls.TRY_JOB_PORT) 141 return cls._compose_port(cls.TRY_JOB_PORT_RANGE)
123 142
124 @classmethod 143 @classmethod
125 def _compose_port(cls, service): 144 def _compose_port(cls, service_range):
126 """Returns: The port number for 'service' from the master's static config. 145 """Returns: The port number for 'service' from the master's static config.
127 146
128 Port numbers are mapped of the form: 147 Port numbers are mapped of the form:
129 XYYZZ 148 offset + YYZZ
130 || \__The last two digits identify the master, e.g. master.chromium 149 | | \__The last two digits identify the master, e.g.
131 |\____The second and third digits identify the master host, e.g. 150 | | master.chromium
132 | master1.golo 151 | \____The second and third digits identify the master host, e.g.
133 \_____The first digit identifies the port type, e.g. master_port 152 | master1.golo
153 \_____________The offset determines the port type, eg. master_port. It
154 comes from the service_range.
134 155
135 If any configuration is missing (incremental migration), this method will 156 If any configuration is missing (incremental migration), this method will
136 return '0' for that query, indicating no port. 157 return '0' for that query, indicating no port.
137 """ 158 """
138 return ( 159 return service_range.compose_port(
139 (service * 10000) + # X
140 (cls.master_port_base * 100) + # YY 160 (cls.master_port_base * 100) + # YY
141 cls.master_port_id) # ZZ 161 cls.master_port_id) # ZZ
142 162
143 service_account_file = None 163 service_account_file = None
144 164
145 @classproperty 165 @classproperty
146 def service_account_path(cls): 166 def service_account_path(cls):
147 if cls.service_account_file is None: 167 if cls.service_account_file is None:
148 return None 168 return None
149 return os.path.join(SERVICE_ACCOUNTS_PATH, cls.service_account_file) 169 return os.path.join(SERVICE_ACCOUNTS_PATH, cls.service_account_file)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 tree_status_url = base_app_url + '/status' 241 tree_status_url = base_app_url + '/status'
222 store_revisions_url = base_app_url + '/revisions' 242 store_revisions_url = base_app_url + '/revisions'
223 last_good_url = base_app_url + '/lkgr' 243 last_good_url = base_app_url + '/lkgr'
224 244
225 class ChromiumOSBase2a(Master2a): 245 class ChromiumOSBase2a(Master2a):
226 """Base class for ChromiumOS masters""" 246 """Base class for ChromiumOS masters"""
227 base_app_url = 'https://chromiumos-status.appspot.com' 247 base_app_url = 'https://chromiumos-status.appspot.com'
228 tree_status_url = base_app_url + '/status' 248 tree_status_url = base_app_url + '/status'
229 store_revisions_url = base_app_url + '/revisions' 249 store_revisions_url = base_app_url + '/revisions'
230 last_good_url = base_app_url + '/lkgr' 250 last_good_url = base_app_url + '/lkgr'
OLDNEW
« no previous file with comments | « scripts/tools/unittests/mastermap_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698