mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 06:44:51 +02:00
Delete end-date sunrise, landrush, and sunrush phases
This also deletes the associated commands and domain application specific entities. We haven't used any of these TLD phases since early 2015 and have no intent to do so in the future, so it makes sense to delete them now so we don't have to carry them through the Registry 3.0 migration. Note that, while there are data model changes, there should be no required data migrations. The fields and entities being removed will simply remain as orphans. I confirmed that the removed types (such as the SUNRUSH_ADD GracePeriodType) are no longer used in production data, and left types that are still used, e.g. BillingEvent.Flag.LANDRUSH or HistoryEntry.Type.ALLOCATE. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=228752843
This commit is contained in:
parent
c74ffd7559
commit
580302898d
282 changed files with 344 additions and 17634 deletions
|
@ -1,116 +0,0 @@
|
|||
// Copyright 2019 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.tools.server;
|
||||
|
||||
import static google.registry.mapreduce.inputs.EppResourceInputs.createEntityInput;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.request.Action.Method.POST;
|
||||
import static google.registry.util.PipelineUtils.createJobPath;
|
||||
|
||||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.index.DomainApplicationIndex;
|
||||
import google.registry.model.index.EppResourceIndex;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.request.auth.Auth;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Deletes all {@link DomainApplication} entities in Datastore.
|
||||
*
|
||||
* <p>This also deletes the corresponding {@link DomainApplicationIndex}, {@link EppResourceIndex},
|
||||
* and descendent {@link HistoryEntry}s.
|
||||
*/
|
||||
@Action(path = "/_dr/task/killAllDomainApplications", method = POST, auth = Auth.AUTH_INTERNAL_ONLY)
|
||||
public class KillAllDomainApplicationsAction implements Runnable {
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject MapreduceRunner mrRunner;
|
||||
@Inject Response response;
|
||||
|
||||
@Inject
|
||||
KillAllDomainApplicationsAction() {}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
response.sendJavaScriptRedirect(
|
||||
createJobPath(
|
||||
mrRunner
|
||||
.setJobName("Delete all domain applications and associated entities")
|
||||
.setModuleName("tools")
|
||||
.runMapOnly(
|
||||
new KillAllDomainApplicationsMapper(),
|
||||
ImmutableList.of(createEntityInput(DomainApplication.class)))));
|
||||
}
|
||||
|
||||
static class KillAllDomainApplicationsMapper extends Mapper<DomainApplication, Void, Void> {
|
||||
|
||||
private static final long serialVersionUID = 2862967335000340688L;
|
||||
|
||||
@Override
|
||||
public void map(final DomainApplication application) {
|
||||
ofy()
|
||||
.transact(
|
||||
() -> {
|
||||
if (ofy().load().entity(application).now() == null) {
|
||||
getContext().incrementCounter("applications already deleted");
|
||||
return;
|
||||
}
|
||||
|
||||
Key<DomainApplication> applicationKey = Key.create(application);
|
||||
DomainApplicationIndex dai =
|
||||
ofy().load().key(DomainApplicationIndex.createKey(application)).now();
|
||||
EppResourceIndex eri =
|
||||
ofy().load().entity(EppResourceIndex.create(applicationKey)).now();
|
||||
|
||||
// This case is common and happens when the same domain name was applied for
|
||||
// multiple times (i.e. there are multiple domain applications sharing a name). The
|
||||
// first one that the mapreduce happens to process will delete the DAI and then
|
||||
// subsequent ones will see the entity as already deleted, which is safe and
|
||||
// expected.
|
||||
if (dai == null) {
|
||||
logger.atWarning().log(
|
||||
"Missing domain application index for application %s.", applicationKey);
|
||||
getContext().incrementCounter("missing domain application indexes");
|
||||
} else {
|
||||
ofy().delete().entity(dai);
|
||||
}
|
||||
|
||||
// This case shouldn't be possible except in extremely rare circumstances, as this
|
||||
// mapreduce itself is relying on EPP resource indexes to load the domain
|
||||
// applications to delete.
|
||||
if (eri == null) {
|
||||
logger.atSevere().log(
|
||||
"Missing EPP resource index for application %s.", applicationKey);
|
||||
getContext().incrementCounter("missing EPP resource indexes");
|
||||
} else {
|
||||
ofy().delete().entity(eri);
|
||||
}
|
||||
|
||||
// Delete the application, its descendents, and the indexes.
|
||||
ofy().delete().keys(ofy().load().ancestor(application).keys());
|
||||
logger.atInfo().log("Deleted domain application %s.", applicationKey);
|
||||
getContext().incrementCounter("applications deleted");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,8 +26,6 @@ import google.registry.config.RegistryEnvironment;
|
|||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.index.DomainApplicationIndex;
|
||||
import google.registry.model.index.EppResourceIndex;
|
||||
import google.registry.model.index.ForeignKeyIndex;
|
||||
import google.registry.request.Action;
|
||||
|
@ -75,12 +73,11 @@ public class KillAllEppResourcesAction implements Runnable {
|
|||
|
||||
/**
|
||||
* Delete an {@link EppResourceIndex}, its referent, all descendants of each referent, and the
|
||||
* {@link ForeignKeyIndex} or {@link DomainApplicationIndex} of the referent, as appropriate.
|
||||
* {@link ForeignKeyIndex} of the referent, as appropriate.
|
||||
*
|
||||
* <p>This will delete:
|
||||
* <ul>
|
||||
* <li>All {@link ForeignKeyIndex} types
|
||||
* <li>{@link DomainApplicationIndex}
|
||||
* <li>{@link EppResourceIndex}
|
||||
* <li>All {@link EppResource} types
|
||||
* <li>{@code HistoryEntry}
|
||||
|
@ -98,9 +95,7 @@ public class KillAllEppResourcesAction implements Runnable {
|
|||
}
|
||||
EppResource resource = ofy().load().key(eri.getKey()).now();
|
||||
// TODO(b/28247733): What about FKI's for renamed hosts?
|
||||
Key<?> indexKey = resource instanceof DomainApplication
|
||||
? DomainApplicationIndex.createKey((DomainApplication) resource)
|
||||
: ForeignKeyIndex.createKey(resource);
|
||||
Key<?> indexKey = ForeignKeyIndex.createKey(resource);
|
||||
emitAndIncrementCounter(indexKey, indexKey);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue