Commit graph

1124 commits

Author SHA1 Message Date
larryruili
3d5a6b808c Change loadActiveApplicationsByDomainName to non-transactional
We can easily end up enlisting too many entity groups (separate
DomainApplications) in a TransactionalFlow when loading all applications
tracked by the DomainApplicationIndex. This makes the load operation
transactionless, to avoid overenlisting.

Potential problems:
1. We fail to prevent landrush applications, if a single sunrise application
exists. This is likely fine, except for a brief moment in Sunrush when a
sunrise application is made immediately prior to a landrush application. The
result is we accept an invalid application- which can be mediated manually.

2. We fail to prevent a domain create for a domain with an open application.
This is a little more sinister, but also unlikely unless someone submits an
application immediately before someone tries to create the same domain (sans
application?)

3. We return an invalid DomainCheck response (instead of 'pending allocation').
Not the worst outcome.

4. We reduce the AuctionStatusCommand and GetApplicationIdsCommand to
eventual consistency. Since they're internal tools, that's not too big a deal.

A better solution:
DomainApplications really should just be normalized under a virtualEntityGroup
by fullyQualifiedDomainName, or a hash-bucket like EppResources are. The
DomainApplication -> DomainBase -> EppResource hierarchy seems to be purely for
code reuse, at the cost of Datastore consistency. This would, however, require
quite some refactoring, and a custom resave operation across all
DomainApplications.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169395586
2017-10-04 16:16:44 -04:00
larryruili
578673141c Migrate to new Sheets v4 api
This moves us from the oudated google/data XML api to the OnePlatform REST/JSON api, finally silencing the deprecation warnings we've been seeing.

The synchronization algorithm diffs the spreadsheet's current values with its internally sourced values, adding the row to a batch update request if there's a discrepancy. Additional internal data are added as an append operation to the end of the sheet, and any extraneous spreadsheet data is cleared from the spreadsheet.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169273590
2017-09-20 10:27:17 -04:00
nickfelt
67116c5fa1 Remove long-dead LogsExportCursor and PersistedRangeLong
LogsExportCursor was only used by ExportLogsTaskServlet, which we removed a long time ago.  It's just dead code.  The PersistedRangeLong type was only written for use by LogsExportCursor, and since it hasn't picked up new users in 3+ years I don't think we need to keep it around.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169264994
2017-09-20 10:27:17 -04:00
mountford
f34d4b6bbb Resolve RDAP TODO without action
There was a TODO to consider making RDAP queries look up domains by foreign key rather than directly to the domain itself. But since the TLD is a possible search filter, it makes more sense to stick with direct lookup, so we can take advantage of the index on TLD.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169240318
2017-09-20 10:27:17 -04:00
mountford
1bb655267c Add RDAP warning when domain searches by nameserver may be incomplete
When searching for domains by nameserver name or IP address, we fetch the matching nameserver keys, then search for domains by those keys. We limit the number of nameserver keys returned, to avoid arbitrarily large domain queries. This CL adds a warning to the RDAP response if we retrieved the maximum number of nameservers. This may indicate that we have not found all the domains.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168885124
2017-09-20 10:27:17 -04:00
mcilwain
7dc1940cdb Move ResaveAllEppResources mapreduce from tools service to backend
It makes sense for all mapreduces to run in backend, especially onces
that are scheduled regularly to run in cron like this one now. We don't
have many instances configured for the tools service anymore on some
of our environments, so backend is the friendliest place for a mapreduce
to run.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168882122
2017-09-20 10:27:17 -04:00
guyben
3cc44259da Use different locks for thin and full rde reports
The lock is used to prevent dual writing of the same output file, and to
prevent us from generating the same data twice (if RdeStaging was run twice).

However, at times when we're creating both RDE and BRDA reports - we use the
same lock for both even though they write to different files and create
different reports.

This causes one of the two to almost always fail (when both are created, which
is once a week I think) delaying that report by several hours.

Note that the "prefix" part of the filenames has the mode in it, so different
modes will not have the same files.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168882007
2017-09-20 10:27:17 -04:00
guyben
892424b148 Check if lock owner is finished on lock acquisition
Sometimes requests "die" suddenly, without going through catch/finally blocks.
If this happens, any lock they own will remain locked until it times out (which
can take hours in some cases).

This cl implicitly unlocks any lock if the owner of the lock isn't running
anymore.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168880938
2017-09-20 10:27:17 -04:00
guyben
d7214b58fc Re-enable DeleteOldCommitLogs cron job
Also adds a "resave all epp" cron job that's needed for the delete to work correctly.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168879965
2017-09-20 10:27:17 -04:00
mountford
80ff106e4c Prohibit some RDAP domain and nameserver lookups by nameserver name
We had been allowing lookups by nameserver name using a wildcard and suffix if the suffix was a domain name. That's ok if the domain name is one we manage, but doesn't work efficiently otherwise. A lookup of ns*.zombo.com would require us to search for all nameservers beginning with ns (which could be almost all of them), then loop through until we found those ending with .zombo.com. So we are going to prohibit suffixes after the TLD unless the suffix is an in-bailiwick domain.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168835732
2017-09-20 10:27:17 -04:00
mcilwain
3a9d7f9b70 Add cloneProjectedInTime() to ResaveAllEppResources mapreduce
We're planning on adding a cronjob to run this mapreduce monthly, so
we may as well also project the resources being re-saved to the present
time so as to handle pending transfers, grace periods, and such. This will
make the BigQuery exports more useful.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168831056
2017-09-20 10:27:17 -04:00
jakubvrana
04a61794e0 Fix closing and self-closing tags in templates
Void tags (e.g. <img>) couldn't have a closing tag (e.g. </img> is invalid). Non-void tags (e.g. <div>) couldn't be self closing (e.g. <div/> is invalid) and must be closed explicitly (e.g. with </div>). This CL fixes the tags which also prepares the templates for stricthtml which enforces it.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168829028
2017-09-20 10:27:17 -04:00
jianglai
ccb0bf5af0 Use real Preconditions class, not old clone from unrelated package.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168720192
2017-09-20 10:27:17 -04:00
mcilwain
d73ef66352 Remove temporary handling of invalid billing events
The bad prober domain data has since been deleted, so we no longer need
to handle the case where these Keys point to entities that don't exist.

This mostly reverses []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168687701
2017-09-20 10:27:17 -04:00
larryruili
efd7010f9d Add resave command for all HistoryEntries
This pattern will mainly be used for data migrations, i.e. updating all
HistoryEntries' DomainTransactionRecords to the new schema.

TESTED=Ran in alpha, the underlying data dropped non-Objectify fields as
expected.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168684356
2017-09-20 10:27:17 -04:00
mmuller
07e5741cbb Implement compare_db_backups "main"
Implement toplevel class that reads in two database backups and displays
diffs.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168592124
2017-09-20 10:27:17 -04:00
mcilwain
51298aeabb Extract multiple commit prevention in DNS writers into a base class
This still retains the DnsWriter interface itself for better integration
with Dagger and to preserve the option of having a DNS writer that does
not have this requirement (e.g. because it is idempotent).

This also makes the commit check thread-safe, which is a nice-to-have.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168451114
2017-09-20 10:27:17 -04:00
mountford
f6e0d5fa0c Fix typo
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168437857
2017-09-20 10:27:17 -04:00
jianglai
c3f2002e6c Set up github CI kokoro job
TESTED=Set up the job in kokoro-qa:

[]

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166875896
2017-09-20 10:27:17 -04:00
mountford
5b444d93fb Add administrator privileges to RDAP
RDAP filters some contact data when the request is not authenticated as coming from a user associated with the registrar owning the contact. This CL adds an exception for admin users, which for the App Engine Users API are defined as App Engine project viewers. This means that the registry team will always get all information when logged in. This will also be useful when building tools that use RDAP output.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168293820
2017-09-12 15:52:02 -04:00
jijiang
211d89695a Migrate from old *Verb* classes to new *SubjectBuilder* classes
This migration does not change any behavior.

More information: []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168248439
2017-09-12 15:51:58 -04:00
bbilbo
4b83615513 Add support for a domain delete superuser EPP extension
Allow superusers to change the grace period and allow
superusers to change the pending delete length.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168028545
2017-09-12 15:51:50 -04:00
mountford
c85dc0c089 Avoid showing personal contact data in RDAP when not logged in
This CL changes the RDAP responses. When the requester asks for information about a domain, and is not logged in as the owning registrar, no contact information is shown. When the requester asks for information about a contact, and is not logged in as the owner registrar, the existence of the contact is shown, but not any personal data (the existence is shown to make things easier to test).

The login uses the same functionality as the registrar console.

For the most part, this CL does not include the necessary tests to make sure that data is not returned when not logged in. The CL is so large that I didn't want to burden it further. Those tests will be added in a follow-on CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168022034
2017-09-12 15:51:50 -04:00
guyben
f0621c4df1 Add unit tests to RequestStatusCheckerImpl
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167742899
2017-09-12 15:51:50 -04:00
bbilbo
3687cc5138 Qualify the usage of ImmutableSet.of()
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167718824
2017-09-12 15:51:50 -04:00
guyben
c3861f6e95 Swap all uses of Lock to LockHandler
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167661348
2017-09-12 15:51:50 -04:00
bbilbo
57bcd6b1eb Declare types in ImmutableSet.of() usage
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167625611
2017-09-12 15:51:50 -04:00
guyben
fa70bd272a Add tool to check if other requests are still running
This is needed for the Lock.java enhancement where a lock will be implicitly
released if the request owning it dies.

No matter which solution we want for refactoring the Lock itself, we will need this class.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167600314
2017-09-12 15:51:50 -04:00
guyben
18a13a09a4 Add request/lock to opensource build
This is to fix Kokoro, given the directory added in [] Also, added forgotten keyring/api directory.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167598465
2017-09-12 15:51:50 -04:00
bbilbo
2e4b63bb79 Add support for a domain transfer request superuser EPP extension
Allow superusers to change the transfer period to zero years and allow
superusers to change the automatic transfer length.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167598314
2017-09-12 15:51:50 -04:00
bbilbo
263aea3b2a Add logging to WhoisReader
Logging will make it easier to troubleshoot WhoisServer exceptions.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167596453
2017-09-12 15:51:50 -04:00
guyben
978149e677 Create an injectable LockHandler
We create an injectable LockHandler that just calls the static
Lock.executeWithLocks function.

I'm not sure what's the correct place to put the LockHandler. I think
model/server is only appropriate for the actual datastore lock. This is a "per request" lock, so maybe request/lock?

-----------------------------

This is the initial step in adding the "lock implicitly released on request death" feature, but it's also useful on its own - easier to test Actions when we can use a fake lock.

To keep this CL simple, we keep using the old Lock as is in most places. We just choose a single example to convert to LockHandler to showcase it. Converting all other uses will be in a subsequent CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167357564
2017-09-12 15:51:50 -04:00
mmuller
8aadf137fb Create an entity record accumulator
RecordAccumulator builds a set of datastore Entity records from a set of
leveldb logfiles in a directory tree (which is how we receive them for
database backup/restore testing).

This CL also refactors some of the logfile test code out of
LevelDbLogReaderTest so that we can reuse it for building test logs.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167313553
2017-09-12 15:51:50 -04:00
larryruili
06f3215659 Add transaction report generation code
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167311547
2017-09-12 15:51:50 -04:00
mmuller
f26bfbf632 Implement ComparableEntity class
ComparableEntity allows us to compare Entity objects by both key and
properties, regardless of the order of those properties in the protobufs.

This is necessary for comparing database backups, where we evaluate the
differences in the set of entities in one backup with those of another.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167288489
2017-09-12 15:51:50 -04:00
larryruili
3809ff59a5 Filter cancellation records for only cancellable records
Previously, I would cancel all the records associated with HistoryEntry that's
available for cancellation. This could cause unexpected behavior if we
cancelled a historyEntry which itself had cancelled records (in effect we would
negate the negation unintentionally). This is easily remedied by only
cancelling records which want to be cancelled.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167204383
2017-09-12 15:51:50 -04:00
dxy
d8c1501213 Add PollMapreduceAction
This is the first in a series of CLs containing code from an old CL of Dai's that had never been completed, which compares zone data between Datastore and DNS. I had written a script to do this by calling two nomulus commands, but maybe it can be done directly in Java, which would be convenient.

This CL is just the plumbing to check on the status of a Mapreduce. We will need this to know that we can proceed with the next step of comparing the output to the DNS data.

Cloned from CL 134295050 by 'g4 patch'.
Original change by dxy@dxy:zoneman-reader:1939:citc on 2016/09/26 10:34:22.

Add a command for comparing zone data between DNS and datastore

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167188979
2017-09-12 15:51:44 -04:00
guyben
fa447ce37e Fix soft delete for possible double-map of domain
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167040455
2017-09-12 14:57:34 -04:00
guyben
ccc51daa9f Add and fix mapreduce counters
Lessons from the first full run of the mapreduce.

Fixed the "old manifests still referenced" counter, since some of these
manifests could be new.

Added a debug "manifests incorrectly mapped multiple times" that is expected to never happen, but who knows? (this is a sort of sanity check for the mapreduce)

Added an "Epp resource revisions handled" that counts the total references, allowing for the possibility of the same manifest being referenced from multiple resources - this is expected to be equal to the map's "Epp resource revisions found" counter.

Added a "commit log manifests referenced multiple times" to see how often the same manifest is linked to from different epp resources.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166846879
2017-08-29 17:21:43 -04:00
larryruili
63fdb506df Add explicit useLegacySql flag to UpdateSnapshotViewAction
It turns out the Bigquery JSON api selects its validator exclusively through
the useLegacySql flag (the #standardSQL directive isn't considered). To fix
this, we add back the explicit flag.

This also logs unexpected API errors, instead of allowing the job to quietly fail.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166757569
2017-08-29 17:20:09 -04:00
larryruili
c86fd96654 Ignore test TLDs when logging transaction creates/deletes
The probers make a constant stream of create and delete calls, which we don't
want to account for when constructing transaction reports. This change will
cause only real TLDs to log create and delete transaction records.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166737801
2017-08-29 17:18:39 -04:00
larryruili
16e8286dca Record domain transaction for domain transfers
This is the last of many cls adding explicit logging in all our domain
mutation flows to facilitate transaction reporting.

The transfer process is as follows:
GAINING sends a TransferRequest to LOSING
LOSING either acks (TransferApprove), nacks (TransferReject) or does nothing
(auto approve). For acks and autoapproves, we produce a +1 counter for GAINING
and LOSING for domain-gaining/losing-successful for each registrar, to be
reported on the approve date + the transfer grace period. For nacks, we produce
a +1 counter for domain-gaining/losing-nacked for each registrar.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166535579
2017-08-29 17:17:07 -04:00
larryruili
7ee8bc9070 Record domain transaction for domain deletes
This is the third of many cls adding explicit logging in all our domain
mutation flows to facilitate transaction reporting.

We add a +1 counter for either grace or nograce deletes, based on the grace period status of the domain. We then search back in time for DOMAIN_CREATE, DOMAIN_RENEW and DOMAIN_AUTORENEW HistoryEntries off the same resource that happened in their corresponding grace periods (5, 5 and 45 days respectively). All transaction records for these events are then given -1 counters to properly account for cancellations in the NET_CREATE and NET_RENEW fields.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166506010
2017-08-29 17:15:38 -04:00
mcilwain
d011b8e073 Fix Java 7 type inference issue in ExpandRecurringBillingEvents
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166478634
2017-08-29 17:14:11 -04:00
jakubvrana
4a81236652 Use JSON.parse instead of deprecated goog.json.parse.
Thanks to [] shared libraries at Google now produce valid JSON which allows using JSON.parse. It is safer and faster than goog.json.parse which uses eval by default.

NOTE: All shared libraries producing JSON at Google were changed to produce valid JSON. However, if your code uses a custom way of producing JSON (not using the shared libraries) or if your code parses JSON generated a long time ago and stored, this CL might break you so please review with care.

Design doc: []

Tested:
    TAP --sample for global presubmit queue
    []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166454709
2017-08-29 17:12:44 -04:00
mcilwain
103b3d7608 Correct usages of DateTime.now() everywhere to DateTime.now(UTC)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166393128
2017-08-29 17:09:53 -04:00
larryruili
7fb44e4f66 Parent recurring billing events under separate HistoryEntries
To log autorenews, we currently run a mapreduce daily that creates synthetic
billing events for each recurring event past its due time. These are all
parented under the original recurring event, which allows these synthetic events to incorrectly stack on the original mutating entry.

We now explicitly create a new HistoryEntry of type DOMAIN_AUTORENEW to log
autorenews alongside other mutating EPP flows. These also parent DomainTransactionRecords for the NET_RENEWS_1_YEAR field, with the reporting time equal to the billing time (which accounts for the autorenew grace period).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166379700
2017-08-29 17:08:27 -04:00
larryruili
97581e519d Unnest transactionFieldAmount from DomainTransactionRecord
After working further with domain deletes, I realized we'll need to record multiple reportingTimes under a single historyEntry when issuing a -1 counter to cancel grace-period adds. Since the TLD would be the only shared component within a record, we'll just duplicate it across all records to save an unnecessary layer of hierarchy.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166261413
2017-08-29 17:05:15 -04:00
guyben
f9a2415954 Check that CommitLogManifest exists before deletion
It appears that there are some possible flows where the reducer runs twice on
the same key. Either because of some error in a subsequent key that makes the
entire shard become ignored and retried, or possible some obscure error outside
of the transaction on that key.

The result however is that sometimes the reducer runs on a key that has already
been deleted. We need to check for that to prevent a null pointer exception.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166112173
2017-08-29 17:02:12 -04:00
mountford
91d4fdb9a8 Modify GenerateZoneFilesAction to create output files more in line with standard DNS format
In standard DNS format, the first thing on an A, NS or DS definition line is a domain label relative to the zone, which in our case is a TLD. However, the generate_zone_files command prints out fully qualified host and domain names, resulting in a discrepancy when compared to the contents of the DNS subsystem. This CL removes the TLD suffix, which should remove one preprocessing step before file comparison.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166103705
2017-08-29 17:00:41 -04:00