mirror of
https://github.com/google/nomulus.git
synced 2025-07-24 19:48:32 +02:00
Remove App Engine request retry headers (#2068)
Cloud Tasks now sends standard HTTP requests.
This commit is contained in:
parent
dfc7947a2f
commit
7a386c4577
3 changed files with 8 additions and 39 deletions
|
@ -81,9 +81,6 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
||||||
|
|
||||||
public static final String PATH = "/_dr/task/publishDnsUpdates";
|
public static final String PATH = "/_dr/task/publishDnsUpdates";
|
||||||
public static final String LOCK_NAME = "DNS updates";
|
public static final String LOCK_NAME = "DNS updates";
|
||||||
// TODO(b/236726584): Remove App Engine header once CloudTasksUtils is refactored to create HTTP
|
|
||||||
// tasks.
|
|
||||||
public static final String APP_ENGINE_RETRY_HEADER = "X-AppEngine-TaskRetryCount";
|
|
||||||
public static final String CLOUD_TASKS_RETRY_HEADER = "X-CloudTasks-TaskRetryCount";
|
public static final String CLOUD_TASKS_RETRY_HEADER = "X-CloudTasks-TaskRetryCount";
|
||||||
public static final int RETRIES_BEFORE_PERMANENT_FAILURE = 20;
|
public static final int RETRIES_BEFORE_PERMANENT_FAILURE = 20;
|
||||||
|
|
||||||
|
@ -140,8 +137,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
||||||
@Config("registrySupportEmail") Lazy<InternetAddress> registrySupportEmail,
|
@Config("registrySupportEmail") Lazy<InternetAddress> registrySupportEmail,
|
||||||
@Config("registryCcEmail") Lazy<InternetAddress> registryCcEmail,
|
@Config("registryCcEmail") Lazy<InternetAddress> registryCcEmail,
|
||||||
@Config("gSuiteOutgoingEmailAddress") InternetAddress gSuiteOutgoingEmailAddress,
|
@Config("gSuiteOutgoingEmailAddress") InternetAddress gSuiteOutgoingEmailAddress,
|
||||||
@Header(APP_ENGINE_RETRY_HEADER) Optional<Integer> appEngineRetryCount,
|
@Header(CLOUD_TASKS_RETRY_HEADER) int retryCount,
|
||||||
@Header(CLOUD_TASKS_RETRY_HEADER) Optional<Integer> cloudTasksRetryCount,
|
|
||||||
DnsWriterProxy dnsWriterProxy,
|
DnsWriterProxy dnsWriterProxy,
|
||||||
DnsMetrics dnsMetrics,
|
DnsMetrics dnsMetrics,
|
||||||
LockHandler lockHandler,
|
LockHandler lockHandler,
|
||||||
|
@ -153,11 +149,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
||||||
this.dnsMetrics = dnsMetrics;
|
this.dnsMetrics = dnsMetrics;
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
this.sendEmailService = sendEmailService;
|
this.sendEmailService = sendEmailService;
|
||||||
retryCount =
|
this.retryCount = retryCount;
|
||||||
cloudTasksRetryCount.orElseGet(
|
|
||||||
() ->
|
|
||||||
appEngineRetryCount.orElseThrow(
|
|
||||||
() -> new IllegalStateException("Missing a valid retry count header")));
|
|
||||||
this.dnsWriter = dnsWriter;
|
this.dnsWriter = dnsWriter;
|
||||||
this.enqueuedTime = enqueuedTime;
|
this.enqueuedTime = enqueuedTime;
|
||||||
this.itemsCreateTime = itemsCreateTime;
|
this.itemsCreateTime = itemsCreateTime;
|
||||||
|
|
|
@ -15,11 +15,10 @@
|
||||||
package google.registry.request;
|
package google.registry.request;
|
||||||
|
|
||||||
import static com.google.common.net.MediaType.JSON_UTF_8;
|
import static com.google.common.net.MediaType.JSON_UTF_8;
|
||||||
import static google.registry.dns.PublishDnsUpdatesAction.APP_ENGINE_RETRY_HEADER;
|
|
||||||
import static google.registry.dns.PublishDnsUpdatesAction.CLOUD_TASKS_RETRY_HEADER;
|
import static google.registry.dns.PublishDnsUpdatesAction.CLOUD_TASKS_RETRY_HEADER;
|
||||||
import static google.registry.model.tld.Tlds.assertTldExists;
|
import static google.registry.model.tld.Tlds.assertTldExists;
|
||||||
import static google.registry.model.tld.Tlds.assertTldsExist;
|
import static google.registry.model.tld.Tlds.assertTldsExist;
|
||||||
import static google.registry.request.RequestParameters.extractOptionalHeader;
|
import static google.registry.request.RequestParameters.extractRequiredHeader;
|
||||||
import static google.registry.request.RequestParameters.extractRequiredParameter;
|
import static google.registry.request.RequestParameters.extractRequiredParameter;
|
||||||
import static google.registry.request.RequestParameters.extractSetOfParameters;
|
import static google.registry.request.RequestParameters.extractSetOfParameters;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
@ -131,8 +130,8 @@ public final class RequestModule {
|
||||||
@FullServletPath
|
@FullServletPath
|
||||||
static String provideFullServletPath(HttpServletRequest req) {
|
static String provideFullServletPath(HttpServletRequest req) {
|
||||||
// Include the port only if it differs from the default for the scheme.
|
// Include the port only if it differs from the default for the scheme.
|
||||||
if ((req.getScheme().equals("http") && (req.getServerPort() == 80))
|
if (("http".equals(req.getScheme()) && (req.getServerPort() == 80))
|
||||||
|| (req.getScheme().equals("https") && (req.getServerPort() == 443))) {
|
|| ("https".equals(req.getScheme()) && (req.getServerPort() == 443))) {
|
||||||
return String.format("%s://%s%s", req.getScheme(), req.getServerName(), req.getServletPath());
|
return String.format("%s://%s%s", req.getScheme(), req.getServerName(), req.getServletPath());
|
||||||
} else {
|
} else {
|
||||||
return String.format(
|
return String.format(
|
||||||
|
@ -237,16 +236,10 @@ public final class RequestModule {
|
||||||
return params.build();
|
return params.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Header(APP_ENGINE_RETRY_HEADER)
|
|
||||||
static Optional<Integer> provideAppEngineRetryCount(HttpServletRequest req) {
|
|
||||||
return extractOptionalHeader(req, APP_ENGINE_RETRY_HEADER).map(Integer::parseInt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Header(CLOUD_TASKS_RETRY_HEADER)
|
@Header(CLOUD_TASKS_RETRY_HEADER)
|
||||||
static Optional<Integer> provideCloudTasksRetryCount(HttpServletRequest req) {
|
static int provideCloudTasksRetryCount(HttpServletRequest req) {
|
||||||
return extractOptionalHeader(req, CLOUD_TASKS_RETRY_HEADER).map(Integer::parseInt);
|
return Integer.parseInt(extractRequiredHeader(req, CLOUD_TASKS_RETRY_HEADER));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -64,7 +64,6 @@ import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.Lazies;
|
import google.registry.testing.Lazies;
|
||||||
import google.registry.util.EmailMessage;
|
import google.registry.util.EmailMessage;
|
||||||
import google.registry.util.SendEmailService;
|
import google.registry.util.SendEmailService;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -161,8 +160,7 @@ public class PublishDnsUpdatesActionTest {
|
||||||
registrySupportEmail,
|
registrySupportEmail,
|
||||||
registryCcEmail,
|
registryCcEmail,
|
||||||
outgoingRegistry,
|
outgoingRegistry,
|
||||||
Optional.ofNullable(retryCount),
|
retryCount,
|
||||||
Optional.empty(),
|
|
||||||
new DnsWriterProxy(ImmutableMap.of("correctWriter", dnsWriter)),
|
new DnsWriterProxy(ImmutableMap.of("correctWriter", dnsWriter)),
|
||||||
dnsMetrics,
|
dnsMetrics,
|
||||||
lockHandler,
|
lockHandler,
|
||||||
|
@ -449,20 +447,6 @@ public class PublishDnsUpdatesActionTest {
|
||||||
.isEqualTo("registry-cc@test.com");
|
.isEqualTo("registry-cc@test.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testTaskMissingRetryHeaders_throwsException() {
|
|
||||||
IllegalStateException thrown =
|
|
||||||
assertThrows(
|
|
||||||
IllegalStateException.class,
|
|
||||||
() ->
|
|
||||||
createAction(
|
|
||||||
"xn--q9jyb4c",
|
|
||||||
ImmutableSet.of(),
|
|
||||||
ImmutableSet.of("ns1.example.xn--q9jyb4c"),
|
|
||||||
null));
|
|
||||||
assertThat(thrown).hasMessageThat().contains("Missing a valid retry count header");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testHostAndDomain_published() {
|
void testHostAndDomain_published() {
|
||||||
ImmutableSet<String> hosts =
|
ImmutableSet<String> hosts =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue