mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 19:20:44 +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 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 int RETRIES_BEFORE_PERMANENT_FAILURE = 20;
|
||||
|
||||
|
@ -140,8 +137,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
|||
@Config("registrySupportEmail") Lazy<InternetAddress> registrySupportEmail,
|
||||
@Config("registryCcEmail") Lazy<InternetAddress> registryCcEmail,
|
||||
@Config("gSuiteOutgoingEmailAddress") InternetAddress gSuiteOutgoingEmailAddress,
|
||||
@Header(APP_ENGINE_RETRY_HEADER) Optional<Integer> appEngineRetryCount,
|
||||
@Header(CLOUD_TASKS_RETRY_HEADER) Optional<Integer> cloudTasksRetryCount,
|
||||
@Header(CLOUD_TASKS_RETRY_HEADER) int retryCount,
|
||||
DnsWriterProxy dnsWriterProxy,
|
||||
DnsMetrics dnsMetrics,
|
||||
LockHandler lockHandler,
|
||||
|
@ -153,11 +149,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
|||
this.dnsMetrics = dnsMetrics;
|
||||
this.timeout = timeout;
|
||||
this.sendEmailService = sendEmailService;
|
||||
retryCount =
|
||||
cloudTasksRetryCount.orElseGet(
|
||||
() ->
|
||||
appEngineRetryCount.orElseThrow(
|
||||
() -> new IllegalStateException("Missing a valid retry count header")));
|
||||
this.retryCount = retryCount;
|
||||
this.dnsWriter = dnsWriter;
|
||||
this.enqueuedTime = enqueuedTime;
|
||||
this.itemsCreateTime = itemsCreateTime;
|
||||
|
|
|
@ -15,11 +15,10 @@
|
|||
package google.registry.request;
|
||||
|
||||
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.model.tld.Tlds.assertTldExists;
|
||||
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.extractSetOfParameters;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
@ -131,8 +130,8 @@ public final class RequestModule {
|
|||
@FullServletPath
|
||||
static String provideFullServletPath(HttpServletRequest req) {
|
||||
// Include the port only if it differs from the default for the scheme.
|
||||
if ((req.getScheme().equals("http") && (req.getServerPort() == 80))
|
||||
|| (req.getScheme().equals("https") && (req.getServerPort() == 443))) {
|
||||
if (("http".equals(req.getScheme()) && (req.getServerPort() == 80))
|
||||
|| ("https".equals(req.getScheme()) && (req.getServerPort() == 443))) {
|
||||
return String.format("%s://%s%s", req.getScheme(), req.getServerName(), req.getServletPath());
|
||||
} else {
|
||||
return String.format(
|
||||
|
@ -237,16 +236,10 @@ public final class RequestModule {
|
|||
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
|
||||
@Header(CLOUD_TASKS_RETRY_HEADER)
|
||||
static Optional<Integer> provideCloudTasksRetryCount(HttpServletRequest req) {
|
||||
return extractOptionalHeader(req, CLOUD_TASKS_RETRY_HEADER).map(Integer::parseInt);
|
||||
static int provideCloudTasksRetryCount(HttpServletRequest req) {
|
||||
return Integer.parseInt(extractRequiredHeader(req, CLOUD_TASKS_RETRY_HEADER));
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -64,7 +64,6 @@ import google.registry.testing.FakeResponse;
|
|||
import google.registry.testing.Lazies;
|
||||
import google.registry.util.EmailMessage;
|
||||
import google.registry.util.SendEmailService;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -161,8 +160,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
registrySupportEmail,
|
||||
registryCcEmail,
|
||||
outgoingRegistry,
|
||||
Optional.ofNullable(retryCount),
|
||||
Optional.empty(),
|
||||
retryCount,
|
||||
new DnsWriterProxy(ImmutableMap.of("correctWriter", dnsWriter)),
|
||||
dnsMetrics,
|
||||
lockHandler,
|
||||
|
@ -449,20 +447,6 @@ public class PublishDnsUpdatesActionTest {
|
|||
.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
|
||||
void testHostAndDomain_published() {
|
||||
ImmutableSet<String> hosts =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue