Граф коммитов

1541 Коммитов

Автор SHA1 Сообщение Дата
Jonathan Amsterdam bc42b7ce3c internal/postgres: lock latest-version changes by module path
Use Postgres advisory locks (see
https://www.postgresql.org/docs/11/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS)
to prevent more than one transaction from thinking it is the latest
version of a particular module.

Change-Id: Ie928dac240b6e8679b41434b2433f89fcb2f49ae
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/760100
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-06-04 02:18:45 +00:00
Jonathan Amsterdam ba4f3b3e6d internal/postgres: makeValidUnicode only copies if necessary
Avoid copying a string if it's already valid unicode.

This saves memory, which may matter. See bug for context.

Updates b/158067614.

Change-Id: I402b7823cba240e593fe1b094f4f85a9cf5eeec2
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/762241
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-06-04 02:18:16 +00:00
Jonathan Amsterdam d1b4cbad38 internal/{log,worker}: label fetch log messages with module@version
- Make it possible to add a label to a context, so it appears in all log messages.
- Add the module and version as a label when fetching.

This will make it easy to find all log messages related to the fetch
of a single module.

Change-Id: I6c564b6aa58a494180d61168e739ef62dd67a64c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/760101
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-06-04 00:01:50 +00:00
Julie Qiu 375894fde3 internal/middleware: change experiment query param behavior
Previously, setting an experiment with the experiment query param
required the flag to be present in the experiments table.

Feature flags can now be set with the experiment query param without
first being added to the database.

Change-Id: Ia24862f2e05414547b5f2dfb96561af49b568835
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/760279
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Andrew Bonventre <andybons@google.com>
2020-06-02 21:04:04 +00:00
Andrew Bonventre bd43c94d8d all: add initial side navigation UI experiment
This change implements the beginnings of a sticky navigation
component on documentation pages.

It is only implemented for wide (desktop) viewports and has no
JavaScript to show selection while scrolling. That will come
in later changes as the hierarchy gets fleshed out.

This also slightly adjusts the amount of space given between
the site header and an element scrolled into view by an anchor.

Updates b/148095016

Change-Id: Id213f1dcb7a2600d5c64bf955c79e0bbc55581db
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/745552
Reviewed-by: Alexander Rakoczy <rakoczy@google.com>
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
2020-06-02 16:31:09 +00:00
Jonathan Amsterdam 079d64eb20 internal/postgres: move latest-version insertions last
Reorganize the code of saveModule so that all changes that assume
we have the latest version happen at the end.

Change-Id: I53b261f1fc24bd48001542b4f0e1d6bbc5f75d29
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/760099
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-06-02 15:45:26 +00:00
Jonathan Amsterdam e66341ffa9 internal/database: Transact supports any isolation level
- Add an arg to Transact for the isolation level
- Remove TransactSerializable

This makes it possible to use other levels, and makes it easier to see
which level is being used for each transaction.

Change-Id: Iba5e2920b4139e5e2f0f8c6b331a658d7c84f60f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/758942
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-06-02 15:12:19 +00:00
Julie Qiu 7557ba4892 internal/queue: pass experiments explictly to InMemoryQueue
Rather than reading experiments from the context, the experiment set for
an InMemoryQueue is now pass in as an argument. This makes it more
explicit what experiments are being set.

Change-Id: Ib68f567ea5b7ff0fc2157ad2713c76d33827c442
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/759927
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-02 15:09:31 +00:00
Julie Qiu 0bbc5df5bf cmd,internal: move taskIDChangeInterval to config
At the moment, taskIDChangeInterval is a hardcoded value in
internal/queue. However, we will soon have two task queues running,
which require different change intervals, so this value is now set in
internal/config.

Additionally, the taskIDChangeInterval for the worker is changed to 3
hours.

Change-Id: I498abefce6543005463be7da99a5a778f3a6e973
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/758919
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-02 00:27:30 +00:00
Jonathan Amsterdam 1d5b18fc5d internal/postgres: ensure doc HTML is valid UTF-8
We've seen documentation that is not valid UTF-8
(github.com/xuender/oil/math). That results in a DB error when written
to a TEXT column.  Make the documentation valid before writing to the
DB.

Change-Id: Ib2ccdd1dfb3b66af9d444b81216f561a8d906d8a
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/757995
Reviewed-by: Julie Qiu <julieqiu@google.com>
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
2020-06-01 13:40:36 +00:00
Julie Qiu 23f4a4a759 all: run prettier on markdown files
./all.bash prettier now runs on files with a .md file extension. Several
existing .md files are formatted.

Change-Id: Id083a932cdd5db105ae7494b71bcad340b080132
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/756682
Reviewed-by: Andrew Bonventre <andybons@google.com>
2020-05-29 14:48:09 +00:00
Julie Qiu 773ca32944 internal/worker/testdata: delete
The contents of this directory are not being used.

Change-Id: I0660f09ba8bd481afa806ad67b0c889d8f055ec7
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/756689
Reviewed-by: Jonathan Amsterdam <jba@google.com>
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
2020-05-29 13:21:57 +00:00
Julie Qiu 2b04dfc463 .prettierignore: add
A .prettierignore is added so that content/static/js/*.min.js files are
ignored when running prettier.

Change-Id: I13738e03a1681475dd3d767258aefcaec73c99d5
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/756683
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-28 22:00:27 +00:00
Jonathan Amsterdam 993cd6f4be internal/source: update tests
Running with `go test -record` revealed some 404s (pages that used to
exist but no longer do). I replaced them with similar pages.

Change-Id: I6903229e8221923e22338bdae3f112308aecd19e
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/756267
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-28 20:39:25 +00:00
Julie Qiu 825ac73645 internal/postgres: add requeue limit for large modules
Our requeue logic is such that large modules (ones with > 1500 packages)
are requeued last, since they can take a long time to reprocess.
However, with large modules, it's possible that the modules that are
queued do not finish processing before the dedupe period for Cloud Tasks
is up, causing the queue to be backed-up with duplicate modules.

A limit of is now added so that at most 100 large modules can be added
to the queue at once.

Change-Id: I0d2a9b709b9a9972b609e9c3af125d58d37f4488
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/755584
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-28 18:43:04 +00:00
Julie Qiu b92b3aeb6b internal/frontend: check for underlying serverError in serveError
At the moment, all errors for servePackagePageNew will return a 500,
because of derrors.Wrap. This is fixed by checking to see if the
err passed to serveError is of type serverError, and if so, return the
status code of the underlying serverError. Regardless of the error
type, the full error will be logged.

Change-Id: I502b174e1efb9f856f17ffb3614fedc909ef162c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/754806
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-28 15:39:25 +00:00
Julie Qiu 97312c3aed devtools: fix references to scripts
In commit 947bb6d235, scripts was renamed
to devtools. There are some lingering references to scripts, which are now fixed.

Change-Id: Icca8b2fa05694fd546c141d045acd13c7679048f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/753924
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-26 23:06:21 +00:00
Julie Qiu 3045c218ae cmd,internal/teeproxy: add
A teeproxy service is add to tee traffic from godoc.org.
23683d71bb

These requests are used to collect data about requests to godoc.org, and
ensure that all incoming traffic to godoc.org can be handled
appropriately by pkg.go.dev.

Updates b/157405502

Change-Id: Ia696457a3867ba0cc883c6ebfd38b45d671e160f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/754075
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-26 23:05:30 +00:00
Julie Qiu 234ba8e22b interanl/postgres: truncate version_map in tests
Change-Id: I9d4ce4d77eef215aa213b8bce126d813ca3ccfc9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/753603
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-26 22:51:29 +00:00
Julie Qiu 78a0a6e89f internal/postgres: read GoModPath from version_mp
Change-Id: Ib73ccb8d505143825ffb267ede9589693d0613d0
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/753602
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-26 22:51:23 +00:00
Julie Qiu 2cfca4659c cmd,internal/queue: pass experiments to InMemoryQueue
At the moment, experiment flags won't be set after they are passed from
a service to the InMemoryQueue. Experiments with a rollout > 0 are now
set when initiating the InMemoryQueue for local development with
cmd/frontend and cmd/worker.

Change-Id: I209024e8281b735d37b4e76d81b4b05ff500e7c3
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/753601
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-26 22:51:16 +00:00
Jonathan Amsterdam 79aa726c0e internal/middleware: record metrics for requests accepted by quota
Record metrics for requests that are allowed because they are on the
list of accepted URLs.

Change-Id: I25d9f72cb92430854a8903444a21bc64785941b1
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/754550
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-26 22:28:35 +00:00
Andrew Bonventre 5ab9d78a3e all: clean up some issues noticed by Lighthouse
+ Update the title suffix from go.dev to pkg.go.dev and some
  incorrect usages
+ Add a meta description for SEO purposes
+ Lazy-load images in the footer (requires setting heights and
  widths for both images because otherwise loading could cause
  reflow
  (see https://web.dev/native-lazy-loading/)
+ Use rel=noopener in places where it is not present or
  where it was redundant with noreferrer. Both are not needed
  (see https://web.dev/external-anchors-use-rel-noopener/)

Change-Id: I46767bd67e6db01c4d5921926381d5b32a89f018
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/752824
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Alexander Rakoczy <rakoczy@google.com>
2020-05-26 17:21:35 +00:00
Andrew Bonventre dec9db9ed0 content/static: rearrange loading order of scripts plus cleanup
+ Load all JavaScript files at the end of the page so that DOM
  parsing won’t be blocked by script execution.
+ Extract out Google Tag Manager script tag and place init logic in
  a separate file instead of using an inscrutable, minified inline
  script.
+ Add the JavaScript compilation script.
+ Update license headers to have a range so that multiple licenses
  are not included in the minified source when only the date is
  different.
+ Update the prettier config to avoid arrow parentheses unless they
  are needed to match existing style.

Change-Id: I7331ee7fab04eb2ff45b5f59928b3e5817d35813
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/752822
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Alexander Rakoczy <rakoczy@google.com>
2020-05-26 17:03:21 +00:00
Jonathan Amsterdam 9a1fb33cac internal/database: correctly wrap bulk statement errors
Wrap DB errors in BulkInsert and BulkUpdate, instead of hiding them.

This will allow TransactSerializable to retry the transaction; now it
is just failing.

Also, log the number of retries so we can get a sense of how congested
we are.

Change-Id: Ice538c5c4de56d88c89ec7a290767c0d5c0b9e39
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/752351
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-26 14:43:40 +00:00
Jonathan Amsterdam 2bfe1fcb1f cmd/frontend: accept only GET requests
Reject with 405 any POST, HEAD, DELETE, etc.

Fixes b/157405356.

Change-Id: I7792d85a43b5de80c43b1f847b9e2267a0b8942d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/754540
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-26 14:41:02 +00:00
Julie Qiu 6a808dff54 internal/postgres: fix requeue bug
There was a bug in the requeue logic that caused all modules to be
requeued when next_processed_at < NOW. This is now fixed so that only
module version states with status=0 or status >= 500 is picked up.

Fixes b/157403463

Change-Id: Ieffde87362c2cd05391780a20dba9647884c99a8
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/754074
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-26 13:01:33 +00:00
Julie Qiu 9ac9110cce all: add updates to roadmap
README.md and CONTRIBUTING.md are updated to discuss upcoming design
changes.

Change-Id: If9835bffbf1533d4f7c02e3c66fc8ed07b2a17cf
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/750822
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-26 12:12:07 +00:00
Julie Qiu 947bb6d235 devtools: renamed from scripts
Change-Id: I1bf0f8a3297b2a83bb6515db25cb04e1b67220d0
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/752611
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-21 19:10:19 +00:00
Jonathan Amsterdam daf67561f6 internal/postgres: run DeleteModule in a transaction
It consists of three separate statements which should happen together.

Change-Id: I8a51dc34fd85e701996bc490932840052bd31162
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/752310
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-21 16:54:35 +00:00
Jonathan Amsterdam 60ecfcd207 internal/frontend: fix compile issue
Change-Id: Ic164943de6b9c9309f5c4250ae6ea13cca9d8f03
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/752311
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-21 16:45:25 +00:00
Julie Qiu 05841d46f0 internal/{frontend,worker}: insert GoModPath for VersionMap
FetchAndUpdateState in internal/frontend and internal/worker now
insert the GoModPath field on VersionMap.

Updates golang/go#36811
Updates golang/go#37002
Updates golang/go#37106

Change-Id: Idfce6d685d24d915608acc1748a84b9db5312ae4
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/751270
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-21 16:09:50 +00:00
Julie Qiu a5b5fa45df internal/postgres: populate version_map.go_mod_path
The version_map.go_mod_path column is now populated in
UpsertVersionMap.

Updates golang/go#36811
Updates golang/go#37002
Updates golang/go#37106

Change-Id: I4e474d28bee67caf7625045082df46f93394f3f6
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/751269
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-21 16:09:44 +00:00
Julie Qiu 4eab8a341e migrations: add version_map.go_mod_path column
This column will be used to display the canonical module path when a
frontend fetch results in fetching an alternative module path.

Updates golang/go#36811
Updates golang/go#37002
Updates golang/go#37106

Change-Id: Ie8ee6ba64ea799d264c1079c345e37d2e073da38
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/751268
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-21 16:09:37 +00:00
Jonathan Amsterdam 78e81b4117 internal/database: log isolation level
Change-Id: Ibd8d29e91b47e37419e5f76c122d6ac73f6989f9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/750957
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-21 16:07:40 +00:00
Jonathan Amsterdam 29e65a8224 internal/postgres: insert module with serializable transaction
If an experiment flag is set, use a serializable transaction
to insert a module.

Change-Id: Ieca2d5ce68f456d48e69b9de6fc3714a130cbca3
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/750955
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-21 16:06:32 +00:00
Jonathan Amsterdam 1c2626f119 internal/database: DB.Transact uses current context
Use the context passed to Transact for the transaction.

Previously, we used the background context, because that is what
sql.DB.Begin does. But we should use the argument context.

This is a behavior change, but it should be unnoticeable. All our
transaction functions use the same context we pass to Transact, so the
only difference this CL makes is that the DB calls in Transact itself,
like BeginTx, Commit and Rollback, now have the potential to fail
because the context is done. In practice that shouldn't matter.

Change-Id: I5eeff51bcd28cb877e5288b83d9e08fa3d249482
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/750953
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-21 16:06:22 +00:00
Jonathan Amsterdam a924a4ce83 internal/database: support serializable transactions
Add DB.TransactSerializable, which executes a transaction with
serializable isolation. Although serializable transactions are more
expensive, they reduce the risk for anomalies, like the constraint
violations we sometimes see.

This CL does not change any existing behavior. In particular, the
DB.Transact method, despite calling sql.DB.BeginTx instead of
sql.DB.Begin, uses the background context exactly as Begin does
(source:
https://github.com/golang/go/blob/go1.14.3/src/database/sql/sql.go#L1689).

Change-Id: Iab9c99ca35de9ef884b149a3b39ecac3300ecac0
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/750952
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-21 16:06:11 +00:00
Jonathan Amsterdam 216e30b8a7 internal/frontend: use new model tables to build package pages
Use the results of postgres.GetDirectoryNew to build
package pages.

Change-Id: Iff812416f4fb879baa16536639a80810fc1248b2
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/747780
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-21 16:00:46 +00:00
Andrew Bonventre dc3877069a internal/frontend, content/static/html: use GTM only
This change removes Google Analytics in favor of just Google
Tag Manager since you can use the latter to send page view data
to the former.

Additionally, adds Google Tag Manager’s debugging view CSS domain
to the content security policy.

Only renders GTM resources when not in development mode.

Change-Id: I54149c378f7226e24d836c730a8fed641d9bcb54
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/751128
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-20 22:27:41 +00:00
Andrew Bonventre 88b406e53e cmd/frontend, internal/frontend: add local development mode
This change replaces the reloadTemplates field with a more general
devMode that will allow for changes to ease ergonomics when
developing locally.

Change-Id: I87132830f51070cfc3905cf739d87ddc35f2f42b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/751682
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-20 22:07:23 +00:00
Jonathan Amsterdam 942ef56a42 internal/postgres: return error from Transact
Somehow we lost the error return from the Transact call in saveModule.
This restores it.

Change-Id: I5d0f2d86ccc78a7506307e1d13a475930e36afa5
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/750954
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-20 19:37:15 +00:00
Jonathan Amsterdam a7ed1b9d88 many: use nil instead of empty slice
It's more idiomatic in Go to use nil rather than an empty slice, in
situations where either works.

Change-Id: I1f85ba39772b873b7b35ca35837fecddd3c33ba0
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/750950
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-20 16:00:14 +00:00
Jonathan Amsterdam ed005bec92 internal/worker: remove fetch timeout and detached context
Now that we are using basic scaling, we can use a longer timeout for
all requests, including fetches. So the special fetch timeout, and the
detached context and tracing that went with it, are no longer necessary.

We still enforce a timeout on requests via middleware.Timeout, using a value
that comes from GO_DISCOVERY_WORKER_TIMEOUT_MINUTES.

Updates b/141406364.

Change-Id: I39266a3f08b1f7e2fea3fdbec05bf092ea974d9b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/750119
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-19 15:43:05 +00:00
Jonathan Amsterdam ecc8a1931e internal/sample: fix SourceInfo
Construct the sample SourceInfo from the given module path, not
the global one.

Change-Id: I2d61d0b234c591a2a6fb03bfbf329549cc0df507
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/750122
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-18 21:26:12 +00:00
Jonathan Amsterdam 5a8a561170 internal/frontend: support stdlib shortcuts
If the URL path doesn't match anything, but it could be in the
standard library (e.g. "json", "http"), then look for a unique
standard library path that ends with the given path, and redirect to
that.

Updates b/149933479.

Change-Id: I0d7c16620c1d0f7c8326302bac1c1423daccfd21
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/747788
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-18 16:23:08 +00:00
Jonathan Amsterdam 5940769e5d internal/frontend: factor out test server creation
Create test servers, their handlers, and middleware in
a single function.

Also factor out adding experiments to a context.

Change-Id: I1a4046e1d190ed7c5f3fe3d12b999bc947821b5c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/747787
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-18 16:14:37 +00:00
Jonathan Amsterdam 2ce2836650 internal: add GetStdlibPaths to datasource
Updates b/149933479.

Change-Id: I8c34d62ce216aaa30c79b171981bd190de2eb936
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/747786
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-18 16:14:27 +00:00
Jonathan Amsterdam f648800004 internal/stdlib: clarify doc comment for Contains
Change-Id: Ic17226b2ae53e17ed96ee288e29306845252b3e8
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/747785
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-18 16:14:14 +00:00
Jonathan Amsterdam c4fb18e370 internal/postgres: add a method for stdlib shortcuts
Add GetStdlibPaths, which finds all paths in the standard library
that end in a given suffix.

The goal is to redirect stdlib paths like, e.g. "http" to "net/http".

Updates b/149933479.

Change-Id: Ib79d55ebb52f1203d8e68f52f6ed8c05db786dfa
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/747784
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-18 16:14:08 +00:00