mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 00:47:11 +02:00
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
This commit is contained in:
parent
d7da112c19
commit
d30f9411d8
11 changed files with 332 additions and 115 deletions
|
@ -641,7 +641,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
}
|
||||
|
||||
public Builder setTldStr(String tldStr) {
|
||||
checkArgument(tldStr != null, "TLD must not be null.");
|
||||
checkArgument(tldStr != null, "TLD must not be null");
|
||||
getInstance().tldStr = tldStr;
|
||||
return this;
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
}
|
||||
|
||||
public Builder setCreateBillingCost(Money amount) {
|
||||
checkArgument(amount.isPositiveOrZero(), "create billing cost cannot be negative");
|
||||
checkArgument(amount.isPositiveOrZero(), "createBillingCost cannot be negative");
|
||||
getInstance().createBillingCost = amount;
|
||||
return this;
|
||||
}
|
||||
|
@ -813,7 +813,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
}
|
||||
|
||||
public Builder setRestoreBillingCost(Money amount) {
|
||||
checkArgument(amount.isPositiveOrZero(), "restore billing cost cannot be negative");
|
||||
checkArgument(amount.isPositiveOrZero(), "restoreBillingCost cannot be negative");
|
||||
getInstance().restoreBillingCost = amount;
|
||||
return this;
|
||||
}
|
||||
|
@ -828,7 +828,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
*/
|
||||
public Builder setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap<DateTime, Money> renewCostsMap) {
|
||||
checkArgumentNotNull(renewCostsMap, "renew billing costs map cannot be null");
|
||||
checkArgumentNotNull(renewCostsMap, "Renew billing costs map cannot be null");
|
||||
checkArgument(Iterables.all(
|
||||
renewCostsMap.values(),
|
||||
new Predicate<Money>() {
|
||||
|
@ -836,7 +836,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
public boolean apply(Money amount) {
|
||||
return amount.isPositiveOrZero();
|
||||
}}),
|
||||
"renew billing cost cannot be negative");
|
||||
"Renew billing cost cannot be negative");
|
||||
getInstance().renewBillingCostTransitions =
|
||||
TimedTransitionProperty.fromValueMap(renewCostsMap, BillingCostTransition.class);
|
||||
return this;
|
||||
|
@ -868,7 +868,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
|
||||
public Builder setServerStatusChangeBillingCost(Money amount) {
|
||||
checkArgument(
|
||||
amount.isPositiveOrZero(), "server status change billing cost cannot be negative");
|
||||
amount.isPositiveOrZero(), "Server status change billing cost cannot be negative");
|
||||
getInstance().serverStatusChangeBillingCost = amount;
|
||||
return this;
|
||||
}
|
||||
|
@ -906,7 +906,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
final Registry instance = getInstance();
|
||||
// Pick up the name of the associated TLD from the instance object.
|
||||
String tldName = instance.tldStr;
|
||||
checkArgument(tldName != null, "No registry TLD specified.");
|
||||
checkArgument(tldName != null, "No registry TLD specified");
|
||||
// Check for canonical form by converting to an InternetDomainName and then back.
|
||||
checkArgument(
|
||||
InternetDomainName.isValid(tldName)
|
||||
|
@ -945,6 +945,9 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
"All EAP fees must be in the registry's currency");
|
||||
checkArgumentNotNull(
|
||||
instance.pricingEngineClassName, "All registries must have a configured pricing engine");
|
||||
checkArgumentNotNull(
|
||||
instance.dnsWriter,
|
||||
"A DNS writer must be specified. VoidDnsWriter can be used if DNS writing isn't wanted");
|
||||
instance.tldStrId = tldName;
|
||||
instance.tldUnicode = Idn.toUnicode(tldName);
|
||||
return super.build();
|
||||
|
|
|
@ -260,7 +260,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
|
|||
assertAllowedEnvironment();
|
||||
initTldCommand();
|
||||
String duplicates = Joiner.on(", ").join(findDuplicates(mainParameters));
|
||||
checkArgument(duplicates.isEmpty(), "Duplicate arguments found: \"%s\"", duplicates);
|
||||
checkArgument(duplicates.isEmpty(), "Duplicate arguments found: '%s'", duplicates);
|
||||
Set<String> tlds = ImmutableSet.copyOf(mainParameters);
|
||||
checkArgument(roidSuffix == null || tlds.size() == 1,
|
||||
"Can't update roid suffixes on multiple TLDs simultaneously");
|
||||
|
@ -268,7 +268,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
|
|||
checkArgument(tld.equals(canonicalizeDomainName(tld)));
|
||||
checkArgument(
|
||||
!CharMatcher.javaDigit().matches(tld.charAt(0)),
|
||||
"TLDs cannot begin with a number.");
|
||||
"TLDs cannot begin with a number");
|
||||
Registry oldRegistry = getOldRegistry(tld);
|
||||
// TODO(b/26901539): Add a flag to set the pricing engine once we have more than one option.
|
||||
Registry.Builder builder =
|
||||
|
@ -388,14 +388,12 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
|
|||
}
|
||||
}
|
||||
|
||||
if (dnsWriter != null) {
|
||||
if (dnsWriter.isPresent()) {
|
||||
if (dnsWriter != null && dnsWriter.isPresent()) {
|
||||
checkArgument(
|
||||
dnsWriterNames.contains(dnsWriter.get()),
|
||||
"The DNS writer '%s' doesn't exist",
|
||||
dnsWriter.get());
|
||||
builder.setDnsWriter(dnsWriter.get());
|
||||
}
|
||||
}
|
||||
|
||||
if (lrpPeriod != null) {
|
||||
|
|
|
@ -86,7 +86,7 @@ class CreateTldCommand extends CreateOrUpdateTldCommand {
|
|||
|
||||
@Override
|
||||
Registry getOldRegistry(String tld) {
|
||||
checkState(!getTlds().contains(tld), "TLD already exists");
|
||||
checkState(!getTlds().contains(tld), "TLD '%s' already exists", tld);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,9 @@ import google.registry.util.StringGenerator;
|
|||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import org.joda.time.Duration;
|
||||
|
||||
/** Composite command to set up OT&E TLDs and accounts. */
|
||||
|
@ -52,6 +54,10 @@ final class SetupOteCommand extends ConfirmingCommand implements RemoteApiComman
|
|||
|
||||
private static final String DEFAULT_PREMIUM_LIST = "default_sandbox_list";
|
||||
|
||||
@Inject
|
||||
@Named("dnsWriterNames")
|
||||
Set<String> dnsWriterNames;
|
||||
|
||||
@Parameter(
|
||||
names = {"-r", "--registrar"},
|
||||
description = "must 1) consist of only lowercase letters, numbers, or hyphens, "
|
||||
|
@ -75,6 +81,12 @@ final class SetupOteCommand extends ConfirmingCommand implements RemoteApiComman
|
|||
validateWith = PathParameter.InputFile.class)
|
||||
private Path certFile;
|
||||
|
||||
@Parameter(
|
||||
names = {"--dns_writer"},
|
||||
description = "DNS writer to use on all TLDs",
|
||||
required = true)
|
||||
private String dnsWriter;
|
||||
|
||||
@Parameter(
|
||||
names = {"--premium_list"},
|
||||
description = "premium list to apply to all TLDs")
|
||||
|
@ -97,15 +109,17 @@ final class SetupOteCommand extends ConfirmingCommand implements RemoteApiComman
|
|||
Duration redemptionGracePeriod,
|
||||
Duration pendingDeleteLength) throws Exception {
|
||||
CreateTldCommand command = new CreateTldCommand();
|
||||
command.addGracePeriod = addGracePeriod;
|
||||
command.dnsWriter = Optional.of(dnsWriter);
|
||||
command.dnsWriterNames = dnsWriterNames;
|
||||
command.force = force;
|
||||
command.initialTldState = initialTldState;
|
||||
command.mainParameters = ImmutableList.of(tldName);
|
||||
command.roidSuffix = String.format(
|
||||
"%S%X", tldName.replaceAll("[^a-z0-9]", "").substring(0, 7), roidSuffixCounter++);
|
||||
command.addGracePeriod = addGracePeriod;
|
||||
command.redemptionGracePeriod = redemptionGracePeriod;
|
||||
command.pendingDeleteLength = pendingDeleteLength;
|
||||
command.premiumListName = Optional.of(premiumList);
|
||||
command.force = force;
|
||||
command.roidSuffix = String.format(
|
||||
"%S%X", tldName.replaceAll("[^a-z0-9]", "").substring(0, 7), roidSuffixCounter++);
|
||||
command.redemptionGracePeriod = redemptionGracePeriod;
|
||||
command.run();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,9 @@ public abstract class TransitionListParameter<V> extends KeyValueMapParameter<Da
|
|||
private static final DateTimeParameter DATE_TIME_CONVERTER = new DateTimeParameter();
|
||||
|
||||
public TransitionListParameter() {
|
||||
super("Not formatted correctly or has transition times out of order.");
|
||||
// This is not sentence-capitalized like most exception messages because it is appended to the
|
||||
// end of the toString() of the transition map in rendering a full exception message.
|
||||
super("not formatted correctly or has transition times out of order");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,10 +42,10 @@ public abstract class TransitionListParameter<V> extends KeyValueMapParameter<Da
|
|||
|
||||
@Override
|
||||
protected final ImmutableSortedMap<DateTime, V> processMap(ImmutableMap<DateTime, V> map) {
|
||||
checkArgument(Ordering.natural().isOrdered(map.keySet()), "Transition times out of order.");
|
||||
checkArgument(Ordering.natural().isOrdered(map.keySet()), "Transition times out of order");
|
||||
return ImmutableSortedMap.copyOf(map);
|
||||
}
|
||||
|
||||
|
||||
/** Converter-validator for TLD state transitions. */
|
||||
public static class TldStateTransitions extends TransitionListParameter<TldState> {
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue