Update parameter to Datastore wipe pipeline (#1385)

* Update parameter to Datastore wipe pipeline

Add the newly required RegistryEnvironment parameter to
BulkDeleteDatastorePipeline.

Remove the nullable annotation for this parameter in options
class.

Update metadata files regarding this parameter.
This commit is contained in:
Weimin Yu 2021-10-11 17:31:50 -04:00 committed by GitHub
parent 34f5e532b5
commit b52e289037
8 changed files with 27 additions and 8 deletions

View file

@ -92,7 +92,12 @@ public class WipeoutDatastoreAction implements Runnable {
.setJobName(createJobName("bulk-delete-datastore-", clock)) .setJobName(createJobName("bulk-delete-datastore-", clock))
.setContainerSpecGcsPath( .setContainerSpecGcsPath(
String.format("%s/%s_metadata.json", stagingBucketUrl, PIPELINE_NAME)) String.format("%s/%s_metadata.json", stagingBucketUrl, PIPELINE_NAME))
.setParameters(ImmutableMap.of("kindsToDelete", "*")); .setParameters(
ImmutableMap.of(
"kindsToDelete",
"*",
"registryEnvironment",
RegistryEnvironment.get().name()));
LaunchFlexTemplateResponse launchResponse = LaunchFlexTemplateResponse launchResponse =
dataflow dataflow
.projects() .projects()

View file

@ -34,7 +34,6 @@ import org.apache.beam.sdk.options.Description;
public interface RegistryPipelineOptions extends GcpOptions { public interface RegistryPipelineOptions extends GcpOptions {
@Description("The Registry environment.") @Description("The Registry environment.")
@Nullable
RegistryEnvironment getRegistryEnvironment(); RegistryEnvironment getRegistryEnvironment();
void setRegistryEnvironment(RegistryEnvironment environment); void setRegistryEnvironment(RegistryEnvironment environment);

View file

@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.datastore.v1.Entity; import com.google.datastore.v1.Entity;
import google.registry.config.RegistryEnvironment;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.apache.beam.sdk.Pipeline; import org.apache.beam.sdk.Pipeline;
@ -308,6 +309,11 @@ public class BulkDeleteDatastorePipeline {
public interface BulkDeletePipelineOptions extends GcpOptions { public interface BulkDeletePipelineOptions extends GcpOptions {
@Description("The Registry environment.")
RegistryEnvironment getRegistryEnvironment();
void setRegistryEnvironment(RegistryEnvironment environment);
@Description( @Description(
"The Datastore KINDs to be deleted. The format may be:\n" "The Datastore KINDs to be deleted. The format may be:\n"
+ "\t- The list of kinds to be deleted as a comma-separated string, or\n" + "\t- The list of kinds to be deleted as a comma-separated string, or\n"

View file

@ -2,6 +2,15 @@
"name": "Bulk Delete Cloud Datastore", "name": "Bulk Delete Cloud Datastore",
"description": "An Apache Beam batch pipeline that deletes Cloud Datastore in bulk. This is easier to use than the GCP-provided template.", "description": "An Apache Beam batch pipeline that deletes Cloud Datastore in bulk. This is easier to use than the GCP-provided template.",
"parameters": [ "parameters": [
{
"name": "registryEnvironment",
"label": "The Registry environment.",
"helpText": "The Registry environment, required only because the worker initializer demands it.",
"is_optional": false,
"regexes": [
"^PRODUCTION|SANDBOX|CRASH|QA|ALPHA$"
]
},
{ {
"name": "kindsToDelete", "name": "kindsToDelete",
"label": "The data KINDs to delete.", "label": "The data KINDs to delete.",

View file

@ -5,10 +5,10 @@
{ {
"name": "registryEnvironment", "name": "registryEnvironment",
"label": "The Registry environment.", "label": "The Registry environment.",
"helpText": "The Registry environment, required if environment-specific initialization (such as JPA) is needed on worker VMs.", "helpText": "The Registry environment.",
"is_optional": true, "is_optional": false,
"regexes": [ "regexes": [
"^[0-9A-Z_]+$" "^PRODUCTION|SANDBOX|CRASH|QA|ALPHA$"
] ]
}, },
{ {

View file

@ -5,7 +5,7 @@
{ {
"name": "registryEnvironment", "name": "registryEnvironment",
"label": "The Registry environment.", "label": "The Registry environment.",
"helpText": "The Registry environment, required if environment-specific initialization (such as JPA) is needed on worker VMs.", "helpText": "The Registry environment.",
"is_optional": false, "is_optional": false,
"regexes": [ "regexes": [
"^PRODUCTION|SANDBOX|CRASH|QA|ALPHA$" "^PRODUCTION|SANDBOX|CRASH|QA|ALPHA$"

View file

@ -5,7 +5,7 @@
{ {
"name": "registryEnvironment", "name": "registryEnvironment",
"label": "The Registry environment.", "label": "The Registry environment.",
"helpText": "The Registry environment, required if environment-specific initialization (such as JPA) is needed on worker VMs.", "helpText": "The Registry environment.",
"is_optional": false, "is_optional": false,
"regexes": [ "regexes": [
"^PRODUCTION|SANDBOX|CRASH|QA|ALPHA$" "^PRODUCTION|SANDBOX|CRASH|QA|ALPHA$"

View file

@ -5,7 +5,7 @@
{ {
"name": "registryEnvironment", "name": "registryEnvironment",
"label": "The Registry environment.", "label": "The Registry environment.",
"helpText": "The Registry environment, required if environment-specific initialization (such as JPA) is needed on worker VMs.", "helpText": "The Registry environment.",
"is_optional": false, "is_optional": false,
"regexes": [ "regexes": [
"^PRODUCTION|SANDBOX|CRASH|QA|ALPHA$" "^PRODUCTION|SANDBOX|CRASH|QA|ALPHA$"