Commit graph

1320 commits

Author SHA1 Message Date
mcilwain
2aa897e698 Remove unnecessary generic type arguments
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175155365
2017-11-21 18:17:31 -05:00
larryruili
8dcc2d6833 Chain ICANN report upload after staging
This converts the upload task from a cron job to a task chained after staging.
This ensures the upload job only occurs when its dependencies are met, and
provides a faster turnaround time to verify both the staging and upload jobs
are complete.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175045489
2017-11-21 18:16:08 -05:00
jianglai
a6f0ab1429 Collect proxy backend metrics
The metrics are collected in a new handler (BackendMetricsHandler), which gets outbound FullHttpRequest and inbound FullHttpResponse. All metrics collected here are backend metrics, i. e. metrics about connection between the proxy and GAE. They also corresponds to the metrics that we are correctly collection from the [] proxy, minus a few that are related to quota management, which are yet to be implemented.

This CL also removed some unnecessary steps to write the frontend protocol name and client hash certificate into backend channel attributes. Instead, BackendMetricsHandler will read these information from the frontend channel attributes directly. This is because backend channel is established after frontend channel, and reading frontend channel attributes from backend handlers always works. On the other hand, there is no easy way to guarantee that the backend channel attributes are writable from frontend handlers, because the channel itself may not have been fully established.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174513334
2017-11-07 17:43:25 -05:00
mountford
5b8ee87ecc Initial, easy changes to support later addition of RDAP metrics
I split this out to avoid having a giant CL that changes everything. The actual
metrics will follow later.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174356874
2017-11-07 17:39:05 -05:00
mountford
c126c05810 Link RDAP syntax page to Github RDAP user's guide
It has been decided that we will link the RDAP help pages, not to local HTML copies, but to the Github documentation.

A typo and word order error in the Github version of the user's guide are also
corrected.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174350665
2017-11-07 17:37:35 -05:00
larryruili
eff2266e35 Add apache beam to registry and open source
This is the initial commit of the new billing system, rewritten as an Apache
Beam pipeline. This contains a basic end-to-end pipeline as proof of concept,
and boilerplate for GenerateInvoicesAction, which will eventually be our
automated invoice generation endpoint.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174184171
2017-11-07 17:36:07 -05:00
jianglai
d3254eaaeb Add a convenience method to clear all registered metrics
Also making these methods public so that other test methods can use them.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174074038
2017-11-07 17:34:36 -05:00
jianglai
b0e062d725 Set HTTP header when processing logout request
The proxy can then use this information to terminate client connection. This is conformant to RFC 5734 which requires the server to disconnect upon responding to EPP logout request:

https://tools.ietf.org/html/rfc5734#section-2

We cannot set "Connection: close" because it is stripped away by App Engine:

https://cloud.google.com/appengine/docs/standard/java/how-requests-are-handled#headers_removed

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173904515
2017-11-07 17:30:13 -05:00
larryruili
abf877f5ae Update appengine-testing open source build to 1.9.58
The original impetus for this came from Kokoro build ID 57aa1042-65aa-46eb-9364-23e2bd17b2fd, where cron/TldFanoutActionTest.testSuccess_returnHttpResponse failed due to some strange nondeterminism in the fake task queue. This test isn't flaky in our build, so we assume it's been fixed in later implementations of appengine-testing.

This also adds a domain-registry-maven mirror for truth8 and clarifies the documentation for adding new libraries.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173587282
2017-11-07 17:27:12 -05:00
larryruili
486c348a00 Add reporting cron jobs to production
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173569808
2017-11-07 17:25:46 -05:00
mountford
11a218f9c3 Derive RDAP link paths from the received query
The former method -- a config string -- was cumbersome, as each Nomulus system would have to configure the link base to its own URL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173567021
2017-11-07 17:24:20 -05:00
mountford
74873f90c8 Order RDAP domain searches by TLD in domain name order
I am not happy that another index is required, but the Pantheon console shows that domain indexes are much smaller than the other indexes (because there are fewer domains), so it's not adding an appreciable amount of storage space.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173561771
2017-11-07 17:21:26 -05:00
jianglai
4a5b9fc288 Add a convenient method to DistributionMetricSubject
Currently to assert that a given Metric<Distribution> as a certain distribution for some labels, the caller needs to manually create an ImmutableDistribution and pass it to #hasValueForLabels method. With this change, an ImmutableSet of data points can be passed to #hasDataSetForLabels method.

Also switched to use expectThrow backport from JUnit 4.13.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173544521
2017-11-07 17:17:14 -05:00
larryruili
4a9b8b918a Fix reporting module parameters and yearMonth usage
This is a final refactor to address Nick's comments in [] where YearMonth really should be injected as a Joda type instead of a raw string, and the HTTP parameters should be separate from the default-provided dependencies.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173539965
2017-11-07 17:15:47 -05:00
mcilwain
d22986a0a3 Use compound return statements for greater readability
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173451653
2017-11-07 17:12:57 -05:00
mcilwain
eed2e0c45f Remove unnecessary explicit generic type declarations
They can be inferred correctly even in Java 7, and display as
compiler warnings in IntelliJ.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173451087
2017-11-07 17:11:29 -05:00
mcilwain
0fdc189e9c Fix missing commas/ambiguous newline in CSS
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173445863
2017-11-07 17:10:02 -05:00
mcilwain
3a0c84e0ee Remove unnecessary Boolean boxing/unboxing
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173443024
2017-11-07 17:08:35 -05:00
mcilwain
c24d5b8a88 Increase the frontend service idle timeout from 10 to 30 minutes
This should help reduce the occurrence of requests taking a long time
to process because a new instance is being spun up. We might consider
increasing this further to 60 minutes in the future if necessary.

This also increases the number of frontend instances on production to 8
from 6, since it appears like the issue we were attempting to mitigate
with that change is now fixed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173440059
2017-11-07 17:07:10 -05:00
jianglai
0573560a6c Change MetricsRegistryImpl constructor to "@VisibleForTesting public".
This enables registry isolation in tests.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173426040
2017-11-07 17:02:44 -05:00
mcilwain
51326a1a5c Remove unnecessary return in void function
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173415021
2017-11-07 16:58:26 -05:00
mcilwain
ec5c9e4474 Use getDeclaredConstructor() so exception checking isn't bypassed
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173412751
2017-11-07 16:55:28 -05:00
mcilwain
113c5af2a5 Remove unnecessary boxing/unboxing in double/long conversion
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173411150
2017-11-07 16:54:02 -05:00
mcilwain
7951799595 Add validation to ROID suffixes
I could've sworn we were already doing this, but apparently not? Anyway,
ROID suffixes have a number of requirements on them that weren't being
enforced, so this enforces them. All existing production data is compliant
with these requirements; the only existing bad data we have is in alpha and
sandbox.

ROID suffixes are now required to match the regex ^[A-Z0-9_]{1,8}$

See also https://tools.ietf.org/html/rfc5730

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173400001
2017-11-07 16:51:06 -05:00
larryruili
2f539d6008 Add reporting retry, emailing and better logging
This change:
- Adds retries to the staging action
- Emails domain-registry-eng@ upon completion of either action
- Simplifies logging to be more useful

TODO: fix up Module @Inject naming conventions and yearMonth injection

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173294822
2017-11-07 16:46:48 -05:00
mcilwain
62dcf2f1a7 Temporarily tune down production frontend instances to 6
We'll revert this once the stuck instance issue in Java 8 is fixed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173183426
2017-10-24 16:53:47 -04:00
mountford
4267fa7e48 Return proper RDAP error messages when invalid IP addresses are specified
We were relying on Dagger to validate the IP address, but that resulted in 500 errors when the IP address was not valid, which is undesirable. Instead, accept the parameters as strings, then convert them to IP addresses and throw a proper error when conversion fails.

Also fixes an improperly specified test.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173172516
2017-10-24 16:53:47 -04:00
mountford
52fd9d8c4e Correctly order RDAP domain searches by nameserver
Usually, the correct order happens automatically, because we are searching on either the key or a specific field like fullyQualifiedDomainName, and the results come back in that order. But when searching by nameserver, where we split the query into multiple "IN" chunks, we have to assemble the result set and order after the fact.

The tests didn't pick up the problem, because the domains and hosts were created in alphabetical order, so it happened to work anyway. The tests have now been changed to create things in reverse order, to test the reordering. Also, the previous arbitrary limit of 1000 nameservers in the intermediate query has been reduced to 300, because we now loop through all nameservers no matter what, rather than stopping when we collect enough domains, so there's more of a penalty for having way too many nameservers.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173163121
2017-10-24 16:53:47 -04:00
mcilwain
1790914058 Add Runnable overrides to ease use of Java 8 language features
Runnable and Callable are both @FunctionalInterfaces. The difference is
that Callable requires a return value whereas Runnable does not, so in
situations where we don't care about a return value, rather than having to
add an unnecessary 'return null;' at the end of the lambda, we can simply
use a non-returning Runnable instead.

Unfortunately, owing to legacy reasons, Runnable is not declared to throw
checked exceptions whereas Callable is, so in situations where checked
exceptions are thrown we still need to have a 'return null;' call at the
end.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172935400
2017-10-24 16:53:47 -04:00
guyben
d577a281b8 Add stackdriver metrics to publishDnsUpdates
Adding the following metrics:

- how long does an update take, per TLD
- number of domains published, per TLD
- number of hosts published, per TLD

All are distributions.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172933834
2017-10-24 16:53:47 -04:00
jianglai
c702b4486c Use standard java thread factory instead of the AppEngine flavor
With Java 8 in GAE standard environment, we can now use standard java thread factory to run the metric reporter in the background in daemon mode, which would not interfere with basic scaling idle timeout as App Engine thread would.

Because the thread is not created by ThreadManager, no App Engine APIs can be called from it. We therefore use GoogleCredential instead of AppIdentityCredential as HttpRequestInitializer, and NetHttpTransport instead of UlrFetchTransport as HttpTransport.

MetricReporter is lazy injected because it depends on jsonCredential retrieved from CloudKms, which is not available in a test environment, causing FrontendServletTest and BackendServletTest to fail.

Some minor re-formatting with google-java-format on edited files.

Lastly removed moe comments in import statement, which makes the linter unhappy.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172896227
2017-10-24 16:53:47 -04:00
mcilwain
b01fa6b4c9 Use more efficient logging statements
The infofmt versions only perform string concatenation if info logging
is turned on, rather than doing so all of the time.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172889338
2017-10-24 16:53:47 -04:00
guyben
15e03a8b1a Count EppResources that don't have an "old enough" revision
DeleteOldCommitLogs uses the revisions of EPP resources to know which commit logs are still in use.

This means that if the revision list of some EPP resources is corrupt in any way, we might delete commit logs that are still needed.

Here we add a basic sanity check for the revision list: we check it has at least one revision older than the "threshold", where the "threshold" is the oldest date we need to be able to recreate using the commit logs.

If we find an error, we log it (and increment a counter). There's nothing we can to do fix it thought.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172780418
2017-10-24 16:53:47 -04:00
mountford
ac822053cc Change behavior when searching contacts by name
We no longer find contacts by name if the request is not authorized to see the name.

Several changes cascade from this. Previously, the code assumed that deleted contacts might still have full names, and therefore be searchable. This is not possible in all cases, because Datastore doesn't have the right index to find deleted contacts by name with a matching registrar. However, luckily, this situation can never occur, because contacts always have their name fields nulled out when they are deleted.

So instead, we simply ignore deleted records when searching by name, knowing that none can ever match.

The tests were then changed so that deleted records look the way the really will, meaning devoid of personal information.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172776926
2017-10-24 16:53:47 -04:00
mcilwain
4828417c73 Convert domain label list code to use Java 8 streams features
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172774927
2017-10-24 16:53:47 -04:00
larryruili
f1c76d035f Prepare ICANN reporting for production
This originally started as a small change, but quickly grew into a major refactor as I realized the original parameter structure wasn't conducive to a cron task and manual re-runs.

The changes are as follows:
1. Adds DNS metrics to activity reports, thanks to Nick's work with the Zoneman Dremel -> #plx workflow.
2. Surrounds registrar names in transactions reports with quotes, to escape possible commas.
3. Factors out the report generation logic into IcannReportingStager.
4. Assigns default values to the three main parameters
  - yearMonth defaults to the previous month
  - subdir defaults to "icann/monthly/yearMonth", i.e. "gs://domain-registry-reporting/icann/monthly/yyyy-MM"
  - reportType defaults to both reports
5. Adds "Total" row generation logic to transactions reports
  - This was a previously overlooked requirement.
6. Adds "MANIFEST.txt" generation and upload logic.
  - The MANIFEST lists out which files need to be uploaded in the subdirectory.
7. Increases urlfetch timeout from 5s to 10s in backend tasks.
  - Backend tasks should be more latency tolerant anyway, and this reduces the number of incorrect timeouts we see for services like Bigquery which might take some time to respond.

TESTED=Extensive testing in alpha, and ran FOSS test.
TODO: send out an e-mail for report generation and upload, and add reporting to cron.xml

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172738344
2017-10-24 16:53:47 -04:00
guyben
06f0ec4f2f Remove reference to TLD in Locks' ResourceName
The TLD is added separately to the lock (the lock is unique per
TLD-ResourceName pair), so there's no need to add it to the resourceName.

The current status is that the TLD was included twice in the lockId. After the fix - it'll only be included once.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172659986
2017-10-24 16:53:47 -04:00
mcilwain
e62e1af863 Rename ClaimsCheckFlow to DomainClaimsCheckFlow
This way it is consistent with the rest of our domain-related flows, which
consistently use the Domain* prefix. Note that claims checks are just a
special case of domain checks anyway, which run under DomainCheckFlow. This
will make dashboards looking at domain commands "just work" with a regexp of
Domain.*, without having to special-case in ClaimsCheck.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172608964
2017-10-24 16:53:47 -04:00
guyben
77ee3e3544 Add metric for lock contention
Also - remove logging from TransactNew, to prevent double logging on transient
failures (TransactNew retries on failure)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172500772
2017-10-24 16:53:47 -04:00
mountford
108deb7f9d Fix NPE in GetHistoryEntriesCommand
The code was not checking the value returned by getTrid() to make sure it was
not null.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172384499
2017-10-24 16:53:47 -04:00
guyben
af99f64b88 Convert CreateCdnsTld into a ConfirmingCommand
This will result is a prompt like

Creating TLD with:
  projectId= domain-registry-alpha
  description= some description
  dnsName= mytld.
  name= mytld.
  nameServerSet= cloud-dns-registry-test
Perform this command? (y/N):

before actually performing the command, and adds a --force flag to bypass the
prompt.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172369944
2017-10-24 16:53:47 -04:00
mountford
03087ddc85 Add RDAP support for deleted domains and filtering by registrar
This CL adds the functionality for domain searches. Entities and nameservers have already been handled by previous CLs.

Deleted items can only be seen by admins, and by registrars viewing their own deleted items.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172097922
2017-10-24 16:53:47 -04:00
mountford
048ae4b4ba Add term to contact index
RDAP searches for contacts with a specific desired registrar need an additional
index term. The tests were not extensive enough to catch this particular case.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172013843
2017-10-24 16:53:47 -04:00
mmuller
bf818a0139 Translate multi-part TLD zone names
Convert periods to hyphens in multi-part TLDs when using them as a zone name
(cloud-dns doesn't allow periods in zone names).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172007089
2017-10-24 16:53:47 -04:00
mountford
7e85ae9964 Fix problem with RDAP help information
Soon this will be rewritten with much more complete information. But this fixes
an obviously wrong bit in the meantime.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172004672
2017-10-24 16:53:47 -04:00
mcilwain
05f6ad80ab Format some imports using fix_imports.py
Unfortunately this tool isn't smart enough to deal with the assertThat
situation (which has two static imports of a function with the same name).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172000753
2017-10-24 16:53:47 -04:00
mountford
326cf698e0 Don't validate RDAP nameserver names using validateDomainName
The nameserver may be external, in which case its TLD will not appear in our
list of valid TLDs, and the search will be rejected erroneously.

Tests for letter case canonicalizations also added at reviewer's suggestion.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171985702
2017-10-24 16:53:47 -04:00
mountford
9d1eb0d429 Set content type for RDAP responses before setting the payload
Also sets the charset to UTF8 explicitly, to avoid confusion, and removes apparently unneeded Truth8 include.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171963981
2017-10-24 16:53:47 -04:00
mcilwain
c0f8da0c6e Switch from Guava Optionals to Java 8 Optionals
This was a surprisingly involved change. Some of the difficulties included
java.util.Optional purposely not being Serializable (so I had to move a
few Optionals in mapreduce classes to @Nullable) and having to add the Truth
Java8 extension library for assertion support.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171863777
2017-10-24 16:53:47 -04:00
nickfelt
184b2b56ac Persist transferredRegistrationExpirationTime (exDate) on TransferData
This CL adds transferredRegistrationExpirationTime as a TransferData field
persisted to Datastore.  It's only relevant for domains, and it represents the
registration expiration time resulting from the approval of the most recent
transfer request.  For pending transfers, we assume the transfer will be
server-approved, and thus in DomainTransferRequestFlow we set this field to the
existing computed value serverApproveNewExpirationTime, which is what we use
for setting up the server-approve autorenew billing event and poll message.
In DomainTransferApproveFlow we overwrite this field with the freshly computed
newExpirationTime, whereas in DomainTransferCancel/RejectFlow (and in the
implicit cancel of DomainDeleteFlow during a pending transfer) we null it out.

There are two key benefits to having this field, which are described in more
detail in b/36405140.

1) b/25084229 - it allows storage of a frozen value to back the "exDate" field
   of DomainTransferResponse, which we can use to fix various errors with how
   exDate display currently works.

2) b/36354434 - it allows DomainResource.cloneProjectedAtTime() to just directly
   set the registrationExpirationTime to this value, without computing it de
   novo, which reduces duplicated logic and ensures that the new expiration time
   matches the autorenew child objects.

This CL only starts writing the field on TransferData as persisted directly on
the DomainResource itself.  We'll then want to backfill the field for at
least pending transfers, whether expired or not (so we can do (2) above), but
I think we might as well backfill it for all pending and approved transfers
so that we also fix (1) even for historical transfers.  And then we can start
actually reading the field for both purposes.  (Note that for (1), this will
only fix synchronous transfer responses served via DomainTransferQueryFlow,
not async transfer responses served via poll messages, since these have already
been persisted with a potentially bad exDate, but I don't think it's worth a
backfill for those).

One last naming note: I chose the verbose transferredRegistrationExpirationTime
rather than the extendedRegistrationExpirationTime of DomainTransferResponse
because (as is the case in autorenew grace, or for a superuser transfer) the
new registration time isn't necessarily extended at all; it may be the same as
the pre-transfer expiration time.  Also, including "registration" helps clarify
w.r.t. pendingTransferExpirationTime which refers confusingly to the expiry of
the transfer itself, rather than the domain registration.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171858083
2017-10-24 16:53:47 -04:00