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

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: Fix mastermap.py 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 return self.start + offset
33
34 def contains(self, port):
dnj (Google) 2016/02/12 01:10:06 Maybe use this in "compose_port" to assert that th
dsansome 2016/02/12 02:29:13 Done.
35 return port >= self.start and port <= self.end
36
37 def offset_of(self, port):
38 return port - self.start
39
40
26 class Master(object): 41 class Master(object):
27 # Repository URLs used by the SVNPoller and 'gclient config'. 42 # Repository URLs used by the SVNPoller and 'gclient config'.
28 server_url = 'http://src.chromium.org' 43 server_url = 'http://src.chromium.org'
29 repo_root = '/svn' 44 repo_root = '/svn'
30 git_server_url = 'https://chromium.googlesource.com' 45 git_server_url = 'https://chromium.googlesource.com'
31 46
32 # External repos. 47 # External repos.
33 googlecode_url = 'http://%s.googlecode.com/svn' 48 googlecode_url = 'http://%s.googlecode.com/svn'
34 sourceforge_url = 'https://svn.code.sf.net/p/%(repo)s/code' 49 sourceforge_url = 'https://svn.code.sf.net/p/%(repo)s/code'
35 googlecode_revlinktmpl = 'https://code.google.com/p/%s/source/browse?r=%s' 50 googlecode_revlinktmpl = 'https://code.google.com/p/%s/source/browse?r=%s'
(...skipping 28 matching lines...) Expand all
64 git_internal_server_url = None 79 git_internal_server_url = None
65 syzygy_internal_url = None 80 syzygy_internal_url = None
66 v8_internal_url = None 81 v8_internal_url = None
67 82
68 83
69 class Base(object): 84 class Base(object):
70 """Master base template. 85 """Master base template.
71 Contains stubs for variables that all masters must define.""" 86 Contains stubs for variables that all masters must define."""
72 87
73 # Base service offset for 'master_port' 88 # Base service offset for 'master_port'
74 MASTER_PORT = 2 89 MASTER_PORT_RANGE = PortRange(20000, 24999)
75 # Base service offset for 'slave_port' 90 # Base service offset for 'slave_port'
76 SLAVE_PORT = 3 91 SLAVE_PORT_RANGE = PortRange(30000, 34999)
77 # Base service offset for 'master_port_alt' 92 # Base service offset for 'master_port_alt'
78 MASTER_PORT_ALT = 4 93 MASTER_PORT_ALT_RANGE = PortRange(25000, 29999)
79 # Base service offset for 'try_job_port' 94 # Base service offset for 'try_job_port'
80 TRY_JOB_PORT = 5 95 TRY_JOB_PORT_RANGE = PortRange(50000, 54999)
81 96
82 # A BuildBucket bucket to poll. 97 # A BuildBucket bucket to poll.
83 buildbucket_bucket = None 98 buildbucket_bucket = None
84 99
85 # Master address. You should probably copy this file in another svn repo 100 # 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. 101 # so you can override this value on both the slaves and the master.
87 master_host = 'localhost' 102 master_host = 'localhost'
88 @classproperty 103 @classproperty
89 def current_host(cls): 104 def current_host(cls):
90 return socket.getfqdn() 105 return socket.getfqdn()
91 @classproperty 106 @classproperty
92 def in_production(cls): 107 def in_production(cls):
93 return re.match(r'master.*\.golo\.chromium\.org', cls.current_host) 108 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 109 # 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. 110 # master_host is overridden by a subclass) is the same as the current host.
96 @classproperty 111 @classproperty
97 def is_production_host(cls): 112 def is_production_host(cls):
98 return cls.current_host == cls.master_host 113 return cls.current_host == cls.master_host
99 114
100 # 'from:' field for emails sent from the server. 115 # 'from:' field for emails sent from the server.
101 from_address = 'nobody@example.com' 116 from_address = 'nobody@example.com'
102 # Additional email addresses to send gatekeeper (automatic tree closage) 117 # Additional email addresses to send gatekeeper (automatic tree closage)
103 # notifications. Unnecessary for experimental masters and try servers. 118 # notifications. Unnecessary for experimental masters and try servers.
104 tree_closing_notification_recipients = [] 119 tree_closing_notification_recipients = []
105 120
106 @classproperty 121 @classproperty
107 def master_port(cls): 122 def master_port(cls):
108 return cls._compose_port(cls.MASTER_PORT) 123 return cls._compose_port(cls.MASTER_PORT_RANGE)
109 124
110 @classproperty 125 @classproperty
111 def slave_port(cls): 126 def slave_port(cls):
112 # Which port slaves use to connect to the master. 127 # Which port slaves use to connect to the master.
113 return cls._compose_port(cls.SLAVE_PORT) 128 return cls._compose_port(cls.SLAVE_PORT_RANGE)
114 129
115 @classproperty 130 @classproperty
116 def master_port_alt(cls): 131 def master_port_alt(cls):
117 # The alternate read-only page. Optional. 132 # The alternate read-only page. Optional.
118 return cls._compose_port(cls.MASTER_PORT_ALT) 133 return cls._compose_port(cls.MASTER_PORT_ALT_RANGE)
119 134
120 @classproperty 135 @classproperty
121 def try_job_port(cls): 136 def try_job_port(cls):
122 return cls._compose_port(cls.TRY_JOB_PORT) 137 return cls._compose_port(cls.TRY_JOB_PORT_RANGE)
123 138
124 @classmethod 139 @classmethod
125 def _compose_port(cls, service): 140 def _compose_port(cls, service_range):
126 """Returns: The port number for 'service' from the master's static config. 141 """Returns: The port number for 'service' from the master's static config.
127 142
128 Port numbers are mapped of the form: 143 Port numbers are mapped of the form:
129 XYYZZ 144 offset + YYZZ
130 || \__The last two digits identify the master, e.g. master.chromium 145 | | \__The last two digits identify the master, e.g.
131 |\____The second and third digits identify the master host, e.g. 146 | | master.chromium
132 | master1.golo 147 | \____The second and third digits identify the master host, e.g.
133 \_____The first digit identifies the port type, e.g. master_port 148 | master1.golo
149 \_____________The offset determines the port type, eg. master_port. It
150 comes from the service_range.
134 151
135 If any configuration is missing (incremental migration), this method will 152 If any configuration is missing (incremental migration), this method will
136 return '0' for that query, indicating no port. 153 return '0' for that query, indicating no port.
137 """ 154 """
138 return ( 155 return service_range.compose_port(
139 (service * 10000) + # X
140 (cls.master_port_base * 100) + # YY 156 (cls.master_port_base * 100) + # YY
141 cls.master_port_id) # ZZ 157 cls.master_port_id) # ZZ
142 158
143 service_account_file = None 159 service_account_file = None
144 160
145 @classproperty 161 @classproperty
146 def service_account_path(cls): 162 def service_account_path(cls):
147 if cls.service_account_file is None: 163 if cls.service_account_file is None:
148 return None 164 return None
149 return os.path.join(SERVICE_ACCOUNTS_PATH, cls.service_account_file) 165 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' 237 tree_status_url = base_app_url + '/status'
222 store_revisions_url = base_app_url + '/revisions' 238 store_revisions_url = base_app_url + '/revisions'
223 last_good_url = base_app_url + '/lkgr' 239 last_good_url = base_app_url + '/lkgr'
224 240
225 class ChromiumOSBase2a(Master2a): 241 class ChromiumOSBase2a(Master2a):
226 """Base class for ChromiumOS masters""" 242 """Base class for ChromiumOS masters"""
227 base_app_url = 'https://chromiumos-status.appspot.com' 243 base_app_url = 'https://chromiumos-status.appspot.com'
228 tree_status_url = base_app_url + '/status' 244 tree_status_url = base_app_url + '/status'
229 store_revisions_url = base_app_url + '/revisions' 245 store_revisions_url = base_app_url + '/revisions'
230 last_good_url = base_app_url + '/lkgr' 246 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