blob: e5c5bd1e4be6c841a94e27eb5cb8124cb19fae3e [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001# Copyright 2016 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style
3# license that can be found in the LICENSE file or at
4# https://developers.google.com/open-source/licenses/bsd
5
6"""Defines settings for monorail."""
7from __future__ import print_function
8from __future__ import division
9from __future__ import absolute_import
10
11import os
12import re
13
14from google.appengine.api import app_identity
15
16from framework import framework_constants
17from proto import project_pb2
18from proto import site_pb2
19
20
21# This file is divided into the following parts:
22# 1. Settings you must edit before deploying your site.
23# 2. Settings you would edit on certain occasions while maintaining your site.
24# 3. Settings enable specific features.
25# 4. Settings that you can usually leave as-is.
26
27# TODO(jrobbins): Store these settings in the database and implement
28# servlets for domain admins to edit them without needing to redeploy the
29# app.
30
31
32####
33# Part 1: settings that you must edit before deploying your site.
34
35# Email address that is offered to users who might need help using the tool.
36feedback_email = 'jrobbins+monorail.feedback@chromium.org'
37
38# For debugging when running in staging: send all outbound
39# email to this address rather than to the actual address that
40# it would normally be sent to.
41send_all_email_to = 'monorail-staging-emails+all+%(user)s+%(domain)s@google.com'
42
43# For debugging when running the server locally: send all outbound
44# email to this address rather than to the actual address that
45# it would normally be sent to.
46send_local_email_to = (
47 send_all_email_to or
48 'monorail-staging-emails+dev+%(user)s+%(domain)s@google.com')
49
50# User to send emails from Monorail as. The reply_to sections of emails will be
51# set to appspotmail addresses.
52# Note: If configuring a new monorail instance without DNS records and reserved
53# email addresses then setting these values to
54# 'reply@${app_id}.appspotmail.com' and 'noreply@{app_id}.appspotmail.com'
55# is likely the best option.
56send_email_as_format = 'monorail@%(domain)s'
57send_noreply_email_as_format = 'monorail+noreply@%(domain)s'
58
59# The default is to look for a database named "monorail" in replicas
60# named "replica-00" .. "replica-09"
61# Replica names for -prod, -staging, and -dev may diverge if replicas ever fail.
62# In such cases the db_replica_names list can be overwritten in Part 5.
63db_database_name = 'monorail'
64db_primary_name = 'primary'
65db_replica_prefix = 'replica'
66db_region = 'us-central1'
67
68# The default connection pool size for mysql connections.
69db_cnxn_pool_size = 20
70
71# The number of logical database shards used. Each replica is complete copy
72# of the primary, so any replica DB can answer queries about any logical shard.
73num_logical_shards = 10
74
75# "Learn more" link for the site home page
76learn_more_link = None
77
78# Site name, displayed above the search box on the site home page.
79site_name = 'Monorail'
80
81# Who is allowed to create new projects? Set to ANYONE or ADMIN_ONLY.
82project_creation_restriction = site_pb2.UserTypeRestriction.ADMIN_ONLY
83
84# Default access level when creating a new project.
85default_access_level = project_pb2.ProjectAccess.ANYONE
86
87# Possible access levels to offer when creating a new project.
88allowed_access_levels = [
89 project_pb2.ProjectAccess.ANYONE,
90 project_pb2.ProjectAccess.MEMBERS_ONLY]
91
92# Who is allowed to create user groups? Set to ANYONE or ADMIN_ONLY.
93group_creation_restriction = site_pb2.UserTypeRestriction.ADMIN_ONLY
94
95# Who is allowed to create hotlists? Set to ANYONE or ADMIN_ONLY.
96hotlist_creation_restriction = site_pb2.UserTypeRestriction.ANYONE
97
98# Text that mentions these words as shorthand host names will be autolinked
99# regardless of the lack of "https://" or ".com".
100autolink_shorthand_hosts = [
101 'go', 'g', 'shortn', 'who', 'teams',
102 ]
103autolink_numeric_shorthand_hosts = [
104 'b', 't', 'o', 'omg', 'cl', 'cr',
105 ]
106
107
108# We only allow self-service account linking invites when the child account is
109# linking to a parent account in an allowed domain.
110linkable_domains = {
111 # Child account domain: [parent account domains]
112 'chromium.org': ['google.com'],
113 'google.com': ['chromium.org'],
114 # TODO(jrobbins): webrtc.org, etc.
115}
116
117
118####
119# Part 2: Settings you would edit on certain occasions.
120
121# Read-only mode prevents changes while we make server-side changes.
122read_only = False
123
124# Timestamp used to notify users when the read only mode or other status
125# described in the banner message takes effect. It is
126# expressed as a tuple of ints: (year, month, day[, hour[, minute[, second]]])
127# e.g. (2009, 3, 20, 21, 45) represents March 20 2009 9:45PM UTC.
128banner_time = None
129
130# Display a site maintenance banner on every monorail page.
131banner_message = ''
132
133# User accounts with email addresses at these domains are all banned.
134banned_user_domains = []
135
136# We use this for specifying cloud task parent
137CLOUD_TASKS_REGION = 'us-central1'
138
139# We only send subscription notifications to users who have visited the
140# site in the last 6 months.
141subscription_timeout_secs = 180 * framework_constants.SECS_PER_DAY
142
143# Location of GCS spam classification staging trainer. Whenever the training
144# code is changed, this should be updated to point to the new package.
145trainer_staging = ('gs://monorail-staging-mlengine/spam_trainer_1517870972/'
146 'packages/befc9b29d9beb7e89d509bd1e9866183c138e3a32317cc'
147 'e253342ac9f8e7c375/trainer-0.1.tar.gz')
148
149# Location of GCS spam classification prod trainer. Whenever the training
150# code is changed, this should be updated to point to the new package.
151trainer_prod = ('gs://monorail-prod-mlengine/spam_trainer_1521755738/packages/'
152 '3339dfcb5d7b6c9d714fb9b332fd72d05823e9a1850ceaf16533a6124bcad'
153 '6fd/trainer-0.1.tar.gz')
154####
155# Part 3: Settings that enable specific features
156
157# Enables "My projects" drop down menu
158enable_my_projects_menu = True
159
160# Enables stars in the UI for projects
161enable_project_stars = True
162
163# Enables stars in the UI for users
164enable_user_stars = True
165
166# Enable quick edit mode in issue peek dialog and show dialog on hover
167enable_quick_edit = True
168
169
170####
171# Part 4: Settings that you can usually leave as-is.
172
173# local_mode makes the server slower and more dynamic for easier debugging.
174# E.g., template files are reloaded on each request.
175local_mode = os.environ['SERVER_SOFTWARE'].startswith('Development')
176unit_test_mode = os.environ['SERVER_SOFTWARE'].startswith('test')
177
178# If we assume 1KB each, then this would be 400 MB for this cache in frontends
179# that have only 1024 MB total.
180issue_cache_max_size = 400 * 1000
181
182# If we assume 1KB each, then this would be 400 MB for this cache in frontends
183# that have only 1024 MB total.
184comment_cache_max_size = 400 * 1000
185
186# 150K users should be enough for all the frequent daily users plus the
187# occasional users that are mentioned on any popular pages.
188user_cache_max_size = 150 * 1000
189
190# Normally we use the default namespace, but during development it is
191# sometimes useful to run a tainted version on staging that has a separate
192# memcache namespace. E.g., os.environ.get('CURRENT_VERSION_ID')
193memcache_namespace = None # Should be None when committed.
194redis_namespace = None
195
196# Default Redis host and port
197redis_host = 'localhost'
198redis_port = '6379'
199
200# Recompute derived issue fields via work items rather than while
201# the user is waiting for a page to load.
202recompute_derived_fields_in_worker = True
203
204# The issue search SQL queries have a LIMIT clause with this amount.
205search_limit_per_shard = 10 * 1000 # This is more than all open in chromium.
206
207# The GAE search feature is slow, so don't request too many results.
208# This limit is approximately the most results that we can get from
209# the fulltext engine in 1s. If we reach this limit in any shard,
210# the user will see a message explaining that results were capped.
211fulltext_limit_per_shard = 1 * 2000
212
213# Retrieve at most this many issues from the DB when showing an issue grid.
214max_issues_in_grid = 6000
215# This is the most tiles that we show in grid view. If the number of results
216# is larger than this, we display IDs instead.
217max_tiles_in_grid = 1000
218
219# Maximum number of project results to display on a single pagination page
220max_project_search_results_per_page = 100
221
222# Maximum number of results per pagination page, regardless of what
223# the user specified in their request. This exists to prevent someone
224# from doing a DoS attack that makes our servers do a huge amount of work.
225max_artifact_search_results_per_page = 1000
226
227# Maximum number of comments to display on a single pagination page
228max_comments_per_page = 500
229
230# Max number of issue starrers to notify via email. Issues with more
231# that this many starrers will only notify the last N of them after a
232# comment from a project member.
233max_starrers_to_notify = 4000
234
235# In projects that have more than this many issues the next and prev
236# links on the issue detail page will not be shown when the user comes
237# directly to an issue without specifying any query terms.
238threshold_to_suppress_prev_next = 10000
239
240# Format string for the name of the FTS index shards for issues.
241search_index_name_format = 'issues%02d'
242
243# Name of the FTS index for projects (not sharded).
244project_search_index_name = 'projects'
245
246# Each backend has this many seconds to respond, otherwise frontend gives up
247# on that shard.
248backend_deadline = 45
249
250# If the initial call to a backend fails, try again this many times.
251# Initial backend calls are failfast, meaning that they fail immediately rather
252# than queue behind other requests. The last 2 retries will wait in queue.
253backend_retries = 3
254
255# Do various extra logging at INFO level.
256enable_profiler_logging = True
257
258# Mail sending domain. Normally set this to None and it will be computed
259# automatically from your AppEngine APP_ID. But, it can be overridden below.
260mail_domain = None
261
262# URL format to browse source code revisions. This can be overridden
263# in specific projects by setting project.revision_url_format.
264# The format string may include "{revnum}" for the revision number.
265revision_url_format = 'https://crrev.com/{revnum}'
266
267# Users with emails in the "priviledged" domains do NOT get any advantage
268# but they do default their preference to show unobscured email addresses.
269priviledged_user_domains = [
270 'google.com', 'chromium.org', 'webrtc.org',
271 ]
272
273# Branded domains: Any UI GET to a project listed below on prod or staging
274# should have the specified host, otherwise it will be redirected such that
275# the specified host is used.
276branded_domains = {} # defaults to empty for localhost
277branded_domains_dev = {
278 'fuchsia': 'bugs-dev.fuchsia.dev',
279 '*': 'bugs-dev.chromium.org',
280}
281branded_domains_staging = {
282 'fuchsia': 'bugs-staging.fuchsia.dev',
283 '*': 'bugs-staging.chromium.org',
284}
285branded_domains_prod = {
286 'fuchsia': 'bugs.fuchsia.dev',
287 '*': 'bugs.chromium.org',
288}
289
290# The site home page will immediately redirect to a default project for these
291# domains, if the project can be viewed. Structure is {hostport: project_name}.
292domain_to_default_project = {} # defaults to empty for localhost
293domain_to_default_project_dev = {'bugs-dev.fuchsia.dev': 'fuchsia'}
294domain_to_default_project_staging = {'bugs-staging.fuchsia.dev': 'fuchsia'}
295domain_to_default_project_prod = {'bugs.fuchsia.dev': 'fuchsia'}
296
297
298# Names of projects on code.google.com which we allow cross-linking to.
299recognized_codesite_projects = [
300 'chromium-os',
301 'chrome-os-partner',
302]
303
304####
305# Part 5: Instance-specific settings that override lines above.
306# This ID is for -staging and other misc deployments. Prod is defined below.
307analytics_id = 'UA-55762617-20'
308
309if unit_test_mode:
310 db_cloud_project = '' # No real database is used during unit testing.
311 app_id = ''
312else:
313 app_id = app_identity.get_application_id()
314
315 if app_id == 'monorail-staging':
316 site_name = 'Monorail Staging'
317 banner_message = 'This staging site does not send emails.'
318 # The Google Cloud SQL databases to use.
319 db_cloud_project = app_id
320 branded_domains = branded_domains_staging
321 domain_to_default_project = domain_to_default_project_staging
322 # For each of these redis_hosts, they must match the corresponding
323 # HOST address of the redis instance for the environment. You can use
324 # the following command to find it.
325 # ```
326 # gcloud redis instances list --project monorail-staging \
327 # --region us-central1
328 # ````
329 redis_host = '10.228.109.51'
330
331 elif app_id == 'monorail-dev':
332 site_name = 'Monorail Dev'
333 banner_message = 'This dev site does not send emails.'
334 # The Google Cloud SQL databases to use.
335 db_cloud_project = app_id
336 branded_domains = branded_domains_dev
337 domain_to_default_project = domain_to_default_project_dev
338 # See comment above on how to find this address.
339 redis_host = '10.150.170.251'
340 # Use replicas created when testing the restore procedures on 2021-02-24
341 db_replica_prefix = 'replica-2'
342
343 elif app_id == 'monorail-prod':
344 send_all_email_to = None # Deliver it to the intended users.
345 # The Google Cloud SQL databases to use.
346 db_cloud_project = app_id
347 analytics_id = 'UA-55762617-14'
348 branded_domains = branded_domains_prod
349 domain_to_default_project = domain_to_default_project_prod
350 # See comment above on how to find this address.
351 redis_host = '10.190.48.180'
352
353if local_mode:
354 site_name = 'Monorail Local'
355 num_logical_shards = 10
356 redis_host = 'localhost'
357 # Run cloud tasks emulator at port 9090
358 CLOUD_TASKS_EMULATOR_ADDRESS = '127.0.0.1:9090'
359
360# Combine the customized info above to make the name of the primary DB instance.
361db_instance = db_cloud_project + ':' + db_region + ':' + db_primary_name
362
363# Combine the customized info above to make the names of the replica DB
364# instances.
365db_replica_names = ['{}-{:02d}'.format(db_replica_prefix, i) for i in range(10)]
366
367# Format string for the name of the physical database replicas.
368physical_db_name_format = (db_cloud_project + ':' + db_region + ':%s')
369
370# preferred domains to display
371preferred_domains = {
372 'monorail-prod.appspot.com': 'bugs.chromium.org',
373 'monorail-staging.appspot.com': 'bugs-staging.chromium.org',
374 'monorail-dev.appspot.com': 'bugs-dev.chromium.org'}
375
376# Borg robot service account
377borg_service_account = 'chrome-infra-prod-borg@system.gserviceaccount.com'
378
379# Prediction API params.
380classifier_project_id = 'project-id-testing-only'
381
382# Necessary for tests.
383if 'APPLICATION_ID' not in os.environ:
384 os.environ['APPLICATION_ID'] = 'testing-app'
385
386if local_mode:
387 # There is no local stub for ML Engine.
388 classifier_project_id = 'monorail-staging'
389else:
390 classifier_project_id = app_identity.get_application_id()
391
392classifier_model_id = '20170302'
393
394# Number of distinct users who have to flag an issue before it
395# is automatically removed as spam.
396# Currently effectively disabled.
397spam_flag_thresh = 1000
398
399# If the classifier's confidence is less than this value, the
400# item will show up in the spam moderation queue for manual
401# review.
402classifier_moderation_thresh = 1.0
403
404# If the classifier's confidence is greater than this value,
405# and the label is 'spam', the item will automatically be created
406# with is_spam=True, and will be filtered out from search results.
407classifier_spam_thresh = 0.995
408
409# Users with email addresses ending with these will not be subject to
410# spam filtering.
411spam_allowlisted_suffixes = (
412 '@chromium.org',
413 '.gserviceaccount.com',
414 '@google.com',
415 '@webrtc.org',
416)
417
418# New issues filed by these users in these groups
419# automatically get the Restrict-View-Google label.
420restrict_new_issues_user_groups = [
421 'chromeos-all@google.com',
422 'chromeos-acl@google.com',
423 'chromeos-fte-tvc@google.com',
424 'chromeos-fte-tvc@chromium.org',
425 'create-team@google.com',
426 'test-corp-mode@google.com',
427]
428
429# Users in these groups see a "corp mode" warning dialog when commenting
430# on public issues, informing them that their comments are public by default.
431public_issue_notice_user_groups = [
432 'chromeos-all@google.com',
433 'chromeos-acl@google.com',
434 'chromeos-fte-tvc@google.com',
435 'chromeos-fte-tvc@chromium.org',
436 'create-team@google.com',
437 'test-corp-mode@google.com',
438 'tq-team@google.com',
439]
440
441full_emails_perm_groups = [
442 # Synced group that gives members permission to view the full
443 # emails of all users.
444 'monorail-display-names-perm@google.com',
445 # Native Monorail group that gives service account members permission
446 # to view full emails of all users.
447 'display-names-perm-sa@bugs.chromium.org'
448]
449
450# These email suffixes are allowed to create new alert bugs via email.
451alert_allowlisted_suffixes = ('@google.com',)
452
453# The person who is notified if there is an unexpected problem in the alert
454# pipeline.
455alert_escalation_email = 'zhangtiff@google.com'
456
457# Bugs autogenerated from alert emails are created through this account.
458alert_service_account = 'chrome-trooper-alerts@google.com'
459
460# The number of hash buckets to use when vectorizing text from Issues and
461# Comments. This should be the same value that the model was trained with.
462spam_feature_hashes = 500
463
464# The number of features to use when vectorizing text from Issues and
465# Comments. This should be the same value that the model was trained with.
466component_features = 5000
467
468# The name of the spam model in ML Engine.
469spam_model_name = 'spam_only_words'
470
471# The name of the component model in ML Engine
472component_model_name = 'component_top_words'
473
474# The name of the gcs bucket containing component predicition trainer code.
475component_ml_bucket = classifier_project_id + '-mlengine'
476
477ratelimiting_enabled = True
478
479# Requests that hit ratelimiting_cost_thresh_sec get one extra count
480# added to their bucket at the end of the request for each additional
481# multiple of this latency.
482ratelimiting_ms_per_count = 1000
483
484api_ratelimiting_enabled = True
485
486# When we post an auto-ping comment, it is posted by this user @ the preferred
487# domain name. E.g., 'monorail@bugs.chromium.org'.
488date_action_ping_author = 'monorail'
489
490# Hard-coding this so that we don't rely on sys.maxint, which could
491# potentially differ. It is equal to the maximum unsigned 32 bit integer,
492# because the `int(10) unsigned` column type in MySQL is 32 bits.
493maximum_snapshot_period_end = 4294967295
494
495# The maximum number of rows chart queries can scan.
496chart_query_max_rows = 10000
497
498# Client ID to use for loading the Google API client, gapi.js.
499if app_identity.get_application_id() == 'monorail-prod':
500 gapi_client_id = (
501 '679746765624-tqaakho939p2mc7eb65t4ecrj3gj08rt.apps.googleusercontent.com')
502else:
503 gapi_client_id = (
504 '52759169022-6918fl1hd1qoul985cs1ohgedeb8c9a0.apps.googleusercontent.com')
505
506# The pub/sub topic on which to publish issue update messages.
507if local_mode:
508 # In local dev, send issue updates to the monorail-dev project.
509 # There also exists a pubsub emulator we could potentially use in the future:
510 # https://cloud.google.com/pubsub/docs/emulator
511 pubsub_project = 'monorail-dev'
512else:
513 pubsub_project = app_identity.get_application_id()
514
515pubsub_topic_id = 'projects/%s/topics/issue-updates' % pubsub_project
516
517# All users in the following domains will have API access.
518# Important: the @ symbol must be included.
519api_allowed_email_domains = ('@google.com')