Commit 42de53dc authored by Owen Min's avatar Owen Min Committed by Commit Bot

Add new DM server HTTP response code

Add code 413 Payload too large. This error is returned when the request
is too large, usually caused by report uploading requests.

Add this error so that we could publish metrics and setup retry logic based
on it.

Any exist error handling code treat the new error same as
DM_STATUS_HTTP_STATUS_ERROR so there is no behavior change.

Bug: 959398
Change-Id: Id4e1c1a82558bc56d870cc247f88e343ef38a9ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1632533Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Commit-Queue: Owen Min <zmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665165}
parent d7219851
...@@ -128,6 +128,7 @@ DemoSetupController::DemoSetupError CreateFromClientStatus( ...@@ -128,6 +128,7 @@ DemoSetupController::DemoSetupError CreateFromClientStatus(
ErrorCode::kTemporaryUnavailable, RecoveryMethod::kRetry, ErrorCode::kTemporaryUnavailable, RecoveryMethod::kRetry,
debug_message); debug_message);
case policy::DM_STATUS_HTTP_STATUS_ERROR: case policy::DM_STATUS_HTTP_STATUS_ERROR:
case policy::DM_STATUS_REQUEST_TOO_LARGE:
return DemoSetupController::DemoSetupError( return DemoSetupController::DemoSetupError(
ErrorCode::kResponseError, RecoveryMethod::kUnknown, debug_message); ErrorCode::kResponseError, RecoveryMethod::kUnknown, debug_message);
case policy::DM_STATUS_RESPONSE_DECODING_ERROR: case policy::DM_STATUS_RESPONSE_DECODING_ERROR:
......
...@@ -465,6 +465,7 @@ void EnterpriseEnrollmentHelperImpl::ReportEnrollmentStatus( ...@@ -465,6 +465,7 @@ void EnterpriseEnrollmentHelperImpl::ReportEnrollmentStatus(
UMA(policy::kMetricEnrollmentRegisterPolicyTempUnavailable); UMA(policy::kMetricEnrollmentRegisterPolicyTempUnavailable);
break; break;
case policy::DM_STATUS_HTTP_STATUS_ERROR: case policy::DM_STATUS_HTTP_STATUS_ERROR:
case policy::DM_STATUS_REQUEST_TOO_LARGE:
UMA(policy::kMetricEnrollmentRegisterPolicyHttpError); UMA(policy::kMetricEnrollmentRegisterPolicyHttpError);
break; break;
case policy::DM_STATUS_RESPONSE_DECODING_ERROR: case policy::DM_STATUS_RESPONSE_DECODING_ERROR:
......
...@@ -48,6 +48,8 @@ int GetIDSForDMStatus(DeviceManagementStatus status) { ...@@ -48,6 +48,8 @@ int GetIDSForDMStatus(DeviceManagementStatus status) {
return IDS_POLICY_DM_STATUS_SERVICE_POLICY_NOT_FOUND; return IDS_POLICY_DM_STATUS_SERVICE_POLICY_NOT_FOUND;
case DM_STATUS_CANNOT_SIGN_REQUEST: case DM_STATUS_CANNOT_SIGN_REQUEST:
return IDS_POLICY_DM_STATUS_CANNOT_SIGN_REQUEST; return IDS_POLICY_DM_STATUS_CANNOT_SIGN_REQUEST;
case DM_STATUS_REQUEST_TOO_LARGE:
return IDS_POLICY_DM_STATUS_REQUEST_TOO_LARGE;
case DM_STATUS_SERVICE_ARC_DISABLED: case DM_STATUS_SERVICE_ARC_DISABLED:
// This error is never shown on the UI. // This error is never shown on the UI.
return IDS_POLICY_DM_STATUS_UNKNOWN_ERROR; return IDS_POLICY_DM_STATUS_UNKNOWN_ERROR;
......
...@@ -123,6 +123,8 @@ enum DeviceManagementStatus { ...@@ -123,6 +123,8 @@ enum DeviceManagementStatus {
DM_STATUS_SERVICE_DOMAIN_MISMATCH = 14, DM_STATUS_SERVICE_DOMAIN_MISMATCH = 14,
// Client error: Request could not be signed. // Client error: Request could not be signed.
DM_STATUS_CANNOT_SIGN_REQUEST = 15, DM_STATUS_CANNOT_SIGN_REQUEST = 15,
// Client error: Request body is too large.
DM_STATUS_REQUEST_TOO_LARGE = 16,
// Service error: Policy not found. Error code defined by the DM folks. // Service error: Policy not found. Error code defined by the DM folks.
DM_STATUS_SERVICE_POLICY_NOT_FOUND = 902, DM_STATUS_SERVICE_POLICY_NOT_FOUND = 902,
// Service error: ARC is not enabled on this domain. // Service error: ARC is not enabled on this domain.
......
...@@ -308,6 +308,7 @@ void CloudPolicyRefreshScheduler::ScheduleRefresh() { ...@@ -308,6 +308,7 @@ void CloudPolicyRefreshScheduler::ScheduleRefresh() {
case DM_STATUS_HTTP_STATUS_ERROR: case DM_STATUS_HTTP_STATUS_ERROR:
case DM_STATUS_RESPONSE_DECODING_ERROR: case DM_STATUS_RESPONSE_DECODING_ERROR:
case DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED: case DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED:
case DM_STATUS_REQUEST_TOO_LARGE:
RefreshAfter(kUnmanagedRefreshDelayMs); RefreshAfter(kUnmanagedRefreshDelayMs);
return; return;
case DM_STATUS_SERVICE_MANAGEMENT_TOKEN_INVALID: case DM_STATUS_SERVICE_MANAGEMENT_TOKEN_INVALID:
......
...@@ -51,6 +51,7 @@ const int kDomainMismatch = 406; ...@@ -51,6 +51,7 @@ const int kDomainMismatch = 406;
const int kDeviceIdConflict = 409; const int kDeviceIdConflict = 409;
const int kDeviceNotFound = 410; const int kDeviceNotFound = 410;
const int kPendingApproval = 412; const int kPendingApproval = 412;
const int kRequestTooLarge = 413;
const int kConsumerAccountWithPackagedLicense = 417; const int kConsumerAccountWithPackagedLicense = 417;
const int kInternalServerError = 500; const int kInternalServerError = 500;
const int kServiceUnavailable = 503; const int kServiceUnavailable = 503;
...@@ -331,6 +332,9 @@ void DeviceManagementRequestJobImpl::HandleResponse(int net_error, ...@@ -331,6 +332,9 @@ void DeviceManagementRequestJobImpl::HandleResponse(int net_error,
case kPendingApproval: case kPendingApproval:
ReportError(DM_STATUS_SERVICE_ACTIVATION_PENDING); ReportError(DM_STATUS_SERVICE_ACTIVATION_PENDING);
return; return;
case kRequestTooLarge:
ReportError(DM_STATUS_REQUEST_TOO_LARGE);
return;
case kConsumerAccountWithPackagedLicense: case kConsumerAccountWithPackagedLicense:
ReportError(DM_STATUS_SERVICE_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE); ReportError(DM_STATUS_SERVICE_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE);
return; return;
......
...@@ -491,7 +491,11 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -491,7 +491,11 @@ INSTANTIATE_TEST_SUITE_P(
DM_STATUS_SERVICE_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE, DM_STATUS_SERVICE_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE,
net::OK, net::OK,
417, 417,
PROTO_STRING(kResponseEmpty)))); PROTO_STRING(kResponseEmpty)),
FailedRequestParams(DM_STATUS_REQUEST_TOO_LARGE,
net::OK,
413,
PROTO_STRING(kResponseEmpty))));
// Simple query parameter parser for testing. // Simple query parameter parser for testing.
class QueryParams { class QueryParams {
......
...@@ -55,10 +55,12 @@ ...@@ -55,10 +55,12 @@
<message name="IDS_POLICY_DM_STATUS_CANNOT_SIGN_REQUEST" desc="Message indicating a failure to sign a request."> <message name="IDS_POLICY_DM_STATUS_CANNOT_SIGN_REQUEST" desc="Message indicating a failure to sign a request.">
Request could not be signed Request could not be signed
</message> </message>
<message name="IDS_POLICY_DM_STATUS_REQUEST_TOO_LARGE" desc="Message indicating a request to enterprise server is too large.">
Request is too large
</message>
<message name="IDS_POLICY_DM_STATUS_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE" desc="Message to show when the user tries to enroll a device with a packaged license using a consumer account."> <message name="IDS_POLICY_DM_STATUS_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE" desc="Message to show when the user tries to enroll a device with a packaged license using a consumer account.">
Can't enroll with consumer account (packaged license available). Can't enroll with consumer account (packaged license available).
</message> </message>
<message name="IDS_POLICY_VALIDATION_OK" desc="Message indicating successful policy validation."> <message name="IDS_POLICY_VALIDATION_OK" desc="Message indicating successful policy validation.">
Validation successful Validation successful
</message> </message>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment