Add more options to the generate escrow deposit command (#1453)

This adds two new options:

1) An option to run RDE in lenient mode.
2) An option to run RDE with the new Beam pipeline regardless of the datastore setting.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/google/nomulus/1453)
<!-- Reviewable:end -->
This commit is contained in:
Lai Jiang
2021-12-10 22:25:32 -05:00
committed by GitHub
parent fe0353ae7d
commit 8c1b178c94
4 changed files with 90 additions and 2 deletions
@@ -45,6 +45,7 @@ public abstract class RdeModule {
public static final String PARAM_WATERMARK = "watermark";
public static final String PARAM_WATERMARKS = "watermarks";
public static final String PARAM_MANUAL = "manual";
public static final String PARAM_BEAM = "beam";
public static final String PARAM_DIRECTORY = "directory";
public static final String PARAM_MODE = "mode";
public static final String PARAM_REVISION = "revision";
@@ -72,6 +73,12 @@ public abstract class RdeModule {
return extractBooleanParameter(req, PARAM_MANUAL);
}
@Provides
@Parameter(PARAM_BEAM)
static boolean provideBeam(HttpServletRequest req) {
return extractBooleanParameter(req, PARAM_BEAM);
}
@Provides
@Parameter(PARAM_DIRECTORY)
static Optional<String> provideDirectory(HttpServletRequest req) {
@@ -264,6 +264,11 @@ public final class RdeStagingAction implements Runnable {
@Inject @Config("beamStagingBucketUrl") String stagingBucketUrl;
@Inject @Config("rdeBucket") String rdeBucket;
@Inject @Parameter(RdeModule.PARAM_MANUAL) boolean manual;
@Inject
@Parameter(RdeModule.PARAM_BEAM)
boolean beam;
@Inject @Parameter(RdeModule.PARAM_DIRECTORY) Optional<String> directory;
@Inject @Parameter(RdeModule.PARAM_MODE) ImmutableSet<String> modeStrings;
@Inject @Parameter(RequestParameters.PARAM_TLDS) ImmutableSet<String> tlds;
@@ -289,7 +294,7 @@ public final class RdeStagingAction implements Runnable {
logger.atInfo().log("Pending deposit: %s", pending);
}
ValidationMode validationMode = lenient ? LENIENT : STRICT;
if (tm().isOfy()) {
if (tm().isOfy() && !beam) {
RdeStagingMapper mapper = new RdeStagingMapper(validationMode, pendings);
RdeStagingReducer reducer = reducerFactory.create(validationMode, gcsUtils);
mrRunner
@@ -382,6 +387,9 @@ public final class RdeStagingAction implements Runnable {
if (revision.isPresent()) {
throw new BadRequestException("Revision parameter not allowed in standard operation");
}
if (beam) {
throw new BadRequestException("Beam parameter not allowed in standard operation");
}
return ImmutableSetMultimap.copyOf(
Multimaps.filterValues(
@@ -16,7 +16,9 @@ package google.registry.tools;
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
import static google.registry.model.tld.Registries.assertTldsExist;
import static google.registry.rde.RdeModule.PARAM_BEAM;
import static google.registry.rde.RdeModule.PARAM_DIRECTORY;
import static google.registry.rde.RdeModule.PARAM_LENIENT;
import static google.registry.rde.RdeModule.PARAM_MANUAL;
import static google.registry.rde.RdeModule.PARAM_MODE;
import static google.registry.rde.RdeModule.PARAM_REVISION;
@@ -65,6 +67,20 @@ final class GenerateEscrowDepositCommand implements CommandWithRemoteApi {
description = "Mode of operation: FULL for RDE deposits, THIN for BRDA deposits.")
private RdeMode mode = RdeMode.FULL;
@Parameter(
names = {"-l", "--lenient"},
description =
"Whether to run RDE in LENIENT mode, which omits validation of the generated "
+ "XML deposit files.")
private boolean lenient = false;
@Parameter(
names = {"-b", "--beam"},
description =
"Whether to explicitly launch the beam pipeline instead of letting the action decide"
+ " which one to run.")
private boolean beam = false;
@Parameter(
names = {"-r", "--revision"},
description = "Revision number. Use >0 for resends.")
@@ -119,6 +135,8 @@ final class GenerateEscrowDepositCommand implements CommandWithRemoteApi {
.param(PARAM_MANUAL, String.valueOf(true))
.param(PARAM_MODE, mode.toString())
.param(PARAM_DIRECTORY, outdir)
.param(PARAM_LENIENT, Boolean.toString(lenient))
.param(PARAM_BEAM, Boolean.toString(beam))
.param(PARAM_TLDS, tlds.stream().collect(Collectors.joining(",")))
.param(
PARAM_WATERMARKS,