Commit graph

275 commits

Author SHA1 Message Date
mcilwain
1c4e79f99e Don't allow non-active registrars to create domains or applications
Specifically, this prevents suspended registrars from creating domains or applications. Pending registrars already can't perform these actions because they get an error message when attempting to log in.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170481338
2017-10-04 16:16:45 -04:00
nickfelt
2702c3a7f3 Fix code to always set HistoryEntry modification time using txn time
Since HistoryEntry always represents a read-only log of mutation to a core resource, that mutation should always happen in a transaction, and the HistoryEntry should be saved in that transaction.  As such, it's always more accurate to use ofy().getTransactionTime() for the modificationTime of the HistoryEntry rather than just DateTime.now(UTC).

In addition, having these be the exact same timestamp makes it possible to align HistoryEntries with commit log manifests using modificationTime = transactionTime, which is useful for recovery and analysis purposes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170136957
2017-10-04 16:16:45 -04:00
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
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
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
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
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
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
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
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
larryruili
c40dc67c5b Record transaction for domain adds, renews and allocates
This is the second of many cls adding explicit logging in all our domain
mutation flows to facilitate transaction reporting.

Adds and renews each result in a +1 counter for the NET_ADDS/RENEWS_#_YR field,
which I've added simple (# of years, add or renew) -> Enum functions to get.
Allocates are just a special case of adds, and are counted in a similar manner.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165963249
2017-08-29 16:56:19 -04:00
larryruili
2fe82921a7 Record domain transaction for DomainRestoreFlow
This is the first of many cls adding explicit logging in all our domain mutation flows to facilitate transaction reporting.

Restores are relatively simple- it happens immediately, so the reporting time is just the time of the HistoryEntry, and we add a single "RESTORED_DOMAINS" count of 1.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165639084
2017-08-29 16:35:42 -04:00
larryruili
bf383081ce Add TransactionRecord to HistoryEntry for transaction reporting
This change adds the persisted data model necessary to facilitate transaction
reporting. TransactionRecord is an embedded repeated class within HistoryEntry
which is only added to when a HistoryEntry is created that counts towards
transaction reporting.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165619552
2017-08-29 16:34:16 -04:00
mcilwain
2a29ada032 Allow multiple DNS writers on TLDs
This completes the data/functionality migration for multiple DNS writers.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163835077
2017-08-01 17:10:33 -04:00
mountford
05d22a2556 Add retry to claims list load
A NullPointerException reported via StackDriver appears to stem from trying to load the claims list right at the moment it was being updated. Since the update only happens once every 12 hours, retrying the load once should fix the problem, if this is really the cause.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163732624
2017-08-01 17:09:10 -04:00
guyben
aee4f7acc2 Remove queueing from Lock
It was buggy (didn't work) and was never actually used.

Why never actually used: for it to be used executeWithLock has to be called
with different requesters on the same lockId. That never happend in the code.

How it was buggy: Logically, the queue is deleted on release of the lock (meaning it was
meaningless the only time it mattered - when the lock isn't taken). In
addition, a different bug meant that having items in the queue prevented the
lock from being released forcing all other tasks to have to wait for lock
timeout even if the task that acquired the lock is long done.

Alternative: fix the queue. This would mean we don't want to delete the lock on release (since we want to keep the queue). Instead, we resave the same lock with expiration date being START_OF_TIME. In addition - we need to fix the .equals used to determine if the lock the same as the acquired lock - instead use some isSame function that ignores the queue.

Note: the queue is dangerous! An item (calling class / action) in the first place of a queue means no other calling class can get that lock. Everything is waiting for the first calling class to be re-run - but that might take a long time (depending on that action's rerun policy) and even might never happen (if for some reason that action decided it was no longer needed without acquiring the lock) - causing all other actions to stall forever!

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163705463
2017-08-01 17:06:20 -04:00
mcilwain
d536cef20f Make Registrar load methods return Optionals instead of Nullables
This makes the code more understandable from callsites, and also forces
users of this function to deal with the situation where the registrar
with a given client ID might not be present (it was previously silently
NPEing from some of the callsites).

This also adds a test helper method loadRegistrar(clientId) that retains
the old functionality for terseness in tests. It also fixes some instances
of using the load method with the wrong cachedness -- some uses in high-
traffic situations (WHOIS) that should have caching, but also low-traffic
reporting that don't benefit from caching so might as well always be
current.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162990468
2017-08-01 16:58:59 -04:00
mcilwain
8a921f08ed Fix bad formatting/line breaks in Registry entity
This file was particularly bad for some reason.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162623626
2017-08-01 16:54:52 -04:00
mcilwain
d3e9ebad16 Remove deprecated singular DNS writer field and update tooling
Note that even though the nomulus command line tool now supports multiple
DNS writers for all subcommands, this still won't work quite yet because
the DNS task queue format migration from [] is still in progress.
After next week's push that migration will be complete and we can remove
the final restriction against only having one DNS writer per TLD.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162490399
2017-08-01 16:50:49 -04:00
guyben
bfde7dac0b Add info printouts for lock acquisition / release
Trying to debug lock acquisition issues with RdeStaging.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161966189
2017-08-01 16:29:01 -04:00
mcilwain
37f33e5e7a Migrate plural DNS writers field to being the canonical one
After this point all data is migrated to use the new canonical
plural version, and subsequent code changes can be made that use
multiple writers.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161673486
2017-08-01 16:12:42 -04:00
mcilwain
4d5b6845b7 Add plural DNS writers field to Registry entity
This is the first step in a multi-step data migration to allow multiple
DNS writers per TLD. The overall process looks like this:

1. Add a plural DNS writers field with backfill (this commit).
2. Deploy it.
3. Run the ResaveEnvironmentEntitiesCommand to populate this new field
   on all entities.
4. Update the code to use the new field everywhere.
5. Deploy it.
6. Delete the now-unreferenced, old deprecated singular value field.

This process is rollback-safe.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161253436
2017-07-10 11:45:13 -04:00
guyben
1f25a862e6 Set KmsKeyring as the default Keyring
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161113761
2017-07-10 11:40:02 -04:00
jianglai
0013312f5c Export billing account map to registrar sheet
The billing account map will be serialized in the following format:

{currency1=id1, currency2=id2, ...}

In order for the output to be deterministic, the billing account map is stored as a sorted map.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161075814
2017-07-10 11:37:23 -04:00
Ben McIlwain
fd1051f90a Remove temporary @OnLoad used for setting period in DomainApplication
Now that the registration period has been added to DomainApplication, we
can remove this @OnLoad that was populating it for objects that were
missing the period.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=159464438
2017-06-21 09:51:28 -04:00
jianglai
d1ef4b9c37 Allow partial update of billing account map
When doing update_registrar, it is now possible to only specify the currencies and the account ids that need updating.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=159262119
2017-06-21 09:48:19 -04:00
cgoldfeder
ae039aa0d8 Remove all vestiges of memcache
Memcache is already off but now it's not in the code anymore.

This includes removing domain creation failfast, since that is actually
slower now than just running the flow - all you gain is a non-transactional
read over a transactional read, but the cost is that you always pay that
read, which is going to drive up latency.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158183506
2017-06-14 10:28:24 -04:00
guyben
75bb1aacdc Update cloudkms_java with the non-beta version
Changed [] to use v1 instead of v1beta1, and replaced v1beta1 with v1 in all the java files.

If there is special build rules for open-source etc. that also need to be updated, or non "TAP-able" tests that need to be run, please check and see if they are OK.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=157895888
2017-06-05 18:17:09 -04:00
mcilwain
42513f41ca Remove migration @OnLoad for EppResource StatusValue LINKED
This was needed to correct bad data (LINKED status values on EppResources). The code has been fixed to no longer persist LINKED on any resources and I ran a resave all action yesterday to remove all persisted LINKED status values, so the migration @OnLoad can be safely removed now.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156580334
2017-05-23 17:22:49 -04:00
cgoldfeder
c9d7e75946 Cache Registrars in memory
This replaces the memcache caching, which we think is overall a bad idea.
We load all registrars at once instead of caching each as needed, so that
the loadAllCached() methods can be cached as well, and therefore will
always produce results consistent with loadByClientIdCached()'s view of the
registrar's values. All of our prod registrars together total 300k of data
right now, so this is hardly worth optimizing further, and in any case this
will likely reduce latency even further since most requests will be
served out of memory.

While I was in the Registrar file I standardized the error messages for incorrect
password and clientId length to be the same format, and cleaned up a few
random things I noticed in the code.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156151828
2017-05-17 12:26:11 -04:00
mcilwain
ef1487cb57 Make name and address fields required on Registrar
The absence of these fields causes RDE failures, so they are in effect
required on any functioning registry system. We are currently
experiencing problems in sandbox caused by null values on these fields.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=155474895
2017-05-17 11:44:46 -04:00
cgoldfeder
275d6ddc10 Disable memcache completely
We've determined that getting correctness semantics right, even
in the few cases that it is possible to do so (see linked bug for
audit) is not worth the bother in terms of highly complicated code
and potential bugs. This CL turns off memcache at the Ofy level
but doesn't rip out the annotations etc. so that we can quickly
turn it back on if this turns out to have been a mistake.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=155227761
2017-05-17 11:35:19 -04:00
cgoldfeder
608e121a37 Set the premium cache duration in tests to 60s not 60ms
This was causing test flakiness.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=155225717
2017-05-17 11:33:44 -04:00
jianglai
7a3852b5a5 Add visibleInWhoisAsAbuse field in RegistrarContact
Also added corresponding getters and setters for the new field. Note that
nothing has changed on the RDAP front for now, as the CL&D only concerns WHOIS.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=155116134
2017-05-17 11:27:24 -04:00
cgoldfeder
386d2bc6be Make Registrar.loadByClientId explicitly use memcache
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154712979
2017-05-03 11:01:54 -04:00
cgoldfeder
0267214841 Replace some unnecessary uses of "real" ofy() with Ofy.
Only Ofy itself and its two helpers (AugmentedSaver and
AugmentedDeleter) need to use the real ofy(). All other
callers should be using Ofy. Fixing this even though it
doesn't change anything because I found it baffling to
follow the code while trying to make a small change.

Update: added a presubmit to enforce this.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154456603
2017-05-03 10:46:28 -04:00
nickfelt
924e5e3e3a Clean up one usage of ForeignKeyIndex.mapToFkiClass()
Followup to []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154361061
2017-05-03 10:41:53 -04:00
mcilwain
d30f9411d8 Require that DNS writer be set on Registry entities
We ran into a bunch of prober deployment issues this past week when
attempting to spin up a new cluster because the newly created prober
TLDs had null values for the dnsWriter field. Given that VoidDnsWriter
exists, we can require that dnsWriter always be set, and have people
use that if DNS publishing is not required.

Also cleans up a bunch of related inconsistent exception messages and
tests not verifying said exception messages properly.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154325830
2017-05-03 10:38:49 -04:00
cgoldfeder
4eba2ea07a Make Registry.get(tld) hit memcache explicitly.
TESTED=The test fails if you change line 134 in Ofy to not use memcache
    and use the unchanged original Registry.get() code. This is the
    expected behavior.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154226534
2017-04-26 11:18:02 -04:00
cgoldfeder
9e61f1d6ef Make failfastForCreate for domain and application creates explicitly hit memcache
TESTED=For all tests, I added @Cache to DomainBase because otherwise the tests will
    fail. We aren't ready to do this in prod yet, which is why the tests are still
    marked @Ignore. The new tests fail if you change line 134 in Ofy to not use memcache
    and either use the unchanged original DomainCreateFlow code, or use the new
    inlined code and change loadWithMemcache() to load(). They pass with the new
    inlined code that calls loadWithMemcache(), as long as the @Cache is added to
    DomainResource.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154224748
2017-04-26 11:16:33 -04:00
cgoldfeder
c596d23523 Add loadWithMemcache() to Ofy
Also clean up some minor uses of load() to standardize calls.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154067731
2017-04-26 10:57:41 -04:00
nickfelt
c5d6a1f6fb Add and adjust EppInput accessors for more useful properties
This primarily adds accessors to EppInput that will be used for flow reporting
logging in FlowReporter.  Specifically, it adds:

 - Optional<String> getResourceType() -> domain/host/contact
 - Optional<String> getSingleTargetId() -> for SingleResourceCommands

And in addition, it adjusts getCommandName() so that it's now named
getCommandType() for better parallelism with the new getResourceType() (since
getResourceName() would be misleading), and it changes the value returned to be
lowercased, again for consistency.  This isn't an issue because getCommandName()
isn't actually used anywhere right now (it was formerly used for EPP whitebox
metrics, but no longer due to recent changes there).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=153851957
2017-04-26 10:51:47 -04:00
jianglai
8f05ca466f Add Ability to return registrar contacts of a certain type
This is required by ICANN Consistent Labeling & Display policy that WHOIS domain query response contains registrar abuse contact's phone number and email address. Add a helper function to load registrar contact of a certain type for a given registrar.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=153606137
2017-04-26 10:44:14 -04:00
larryruili
5047d568de Notify registrars of async contact/host deletions
We now send PendingActionNotificationResponses in our poll messages upon completion of an asynchronous contact or host deletion. This is part 1 of 2, which begins logging Trid in all enqueued Host/Contact deletion flows for use in batch deletions, and optionally consuming the resultant Trid info to emit a Host/ContactPendingActionNotifcationResponse.

Part 2 will make this response emission non-optional, which will happen once the queue is cleared of all non-Trid containing tasks.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=153084197
2017-04-26 10:33:55 -04:00
mcilwain
8653d2f204 Refactor out creation of server TRIDs so they can be tested
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=152837185
2017-04-13 10:55:47 -04:00
nickfelt
5081d780dc Add assertTldsExist(Iterable<String>) to check multiple TLDs at once
This is better than calling assertTldExists() inside a for loop because you can throw a single exception reporting all bad TLDs at once rather than only getting as far as the first failure.  And then it's also a one-liner instead of 3 lines.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=152412876
2017-04-10 13:44:52 -04:00
mountford
62c7a3935a Add nomulus tool command to delete a TLD
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=151863632
2017-04-05 10:10:38 -04:00
nickfelt
91c2558feb Make FlowRunner log ICANN activity report field name
As part of b/36599833, this makes FlowRunner log the appropriate ICANN activity
report field name for each flow it runs as part of a structured JSON log
statement which can be parsed to generate ICANN activity reports (under the key
"icannActivityReportField").

In order to support this, we introduce an annotation for Flow classes called
@ReportingSpec and a corresponding enum of values for this annotation, which is
IcannReportingTypes.ActivityReportField, that stores the mapping of constant
enum values to field names.

The mapping from flows to fields is fairly obvious, with three exceptions:

 - Application flows are all accounted under domains, since applications are
   technically just deferred domain creates within the EPP protocol
 - ClaimsCheckFlow is counted as a domain check
 - DomainAllocateFlow is counted as a domain create

In addition, I've added tests to all the corresponding flows that we are
indeed logging what we expect.

We'll also need to log the TLD for this to be useful, but I'm doing that in a
follow-up CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=151283411
2017-03-27 13:32:57 -04:00