Commit dd3c86d4 authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[remoting][host] Don't send host offline reason for host deletion

When the host receives a deletion notification from directory, it tries
to send an invalid host ID offline reason to directory before shutting
itself down. This is likely to fail since the backend might have already
unregistered the robot account. Then the host will keep trying to send
the offline reason a few times until it eventually gives up.

Sending offline reason for host deleted on the directory is unnecessary
and will delay the host shutdown process, so this CL prevents the host
from sending the offline reason in this case.

Bug: 968859
Change-Id: I2de39b5426f52c3e3db05af92e00ec68a4dd9206
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1678700
Commit-Queue: Joe Downing <joedow@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672758}
parent 5da28401
...@@ -9,15 +9,16 @@ ...@@ -9,15 +9,16 @@
namespace remoting { namespace remoting {
const NameMapElement<HostExitCodes> kHostExitCodeStrings[] = { const NameMapElement<HostExitCodes> kHostExitCodeStrings[] = {
{ kSuccessExitCode, "SUCCESS_EXIT" }, {kSuccessExitCode, "SUCCESS_EXIT"},
{ kInitializationFailed, "INITIALIZATION_FAILED" }, {kInitializationFailed, "INITIALIZATION_FAILED"},
{ kInvalidCommandLineExitCode, "INVALID_COMMAND_LINE" }, {kInvalidCommandLineExitCode, "INVALID_COMMAND_LINE"},
{ kInvalidHostConfigurationExitCode, "INVALID_HOST_CONFIGURATION" }, {kInvalidHostConfigurationExitCode, "INVALID_HOST_CONFIGURATION"},
{ kInvalidHostIdExitCode, "INVALID_HOST_ID" }, {kInvalidHostIdExitCode, "INVALID_HOST_ID"},
{ kInvalidOauthCredentialsExitCode, "INVALID_OAUTH_CREDENTIALS" }, {kInvalidOauthCredentialsExitCode, "INVALID_OAUTH_CREDENTIALS"},
{ kInvalidHostDomainExitCode, "INVALID_HOST_DOMAIN" }, {kInvalidHostDomainExitCode, "INVALID_HOST_DOMAIN"},
{ kLoginScreenNotSupportedExitCode, "LOGIN_SCREEN_NOT_SUPPORTED" }, {kLoginScreenNotSupportedExitCode, "LOGIN_SCREEN_NOT_SUPPORTED"},
{ kUsernameMismatchExitCode, "USERNAME_MISMATCH" }, {kUsernameMismatchExitCode, "USERNAME_MISMATCH"},
{kHostDeletedExitCode, "HOST_DELETED"},
}; };
const char* ExitCodeToString(HostExitCodes exit_code) { const char* ExitCodeToString(HostExitCodes exit_code) {
......
...@@ -26,11 +26,12 @@ enum HostExitCodes { ...@@ -26,11 +26,12 @@ enum HostExitCodes {
kInvalidHostDomainExitCode = 103, kInvalidHostDomainExitCode = 103,
kLoginScreenNotSupportedExitCode = 104, kLoginScreenNotSupportedExitCode = 104,
kUsernameMismatchExitCode = 105, kUsernameMismatchExitCode = 105,
kHostDeletedExitCode = 106,
// The range of the exit codes that should be interpreted as a permanent error // The range of the exit codes that should be interpreted as a permanent error
// condition. // condition.
kMinPermanentErrorExitCode = kInvalidHostConfigurationExitCode, kMinPermanentErrorExitCode = kInvalidHostConfigurationExitCode,
kMaxPermanentErrorExitCode = kUsernameMismatchExitCode kMaxPermanentErrorExitCode = kHostDeletedExitCode
}; };
const char* ExitCodeToString(HostExitCodes exit_code); const char* ExitCodeToString(HostExitCodes exit_code);
......
...@@ -967,7 +967,7 @@ void HostProcess::OnHeartbeatSuccessful() { ...@@ -967,7 +967,7 @@ void HostProcess::OnHeartbeatSuccessful() {
void HostProcess::OnHostDeleted() { void HostProcess::OnHostDeleted() {
LOG(ERROR) << "Host was deleted from the directory."; LOG(ERROR) << "Host was deleted from the directory.";
ShutdownHost(kInvalidHostIdExitCode); ShutdownHost(kHostDeletedExitCode);
} }
void HostProcess::OnInitializePairingRegistry( void HostProcess::OnInitializePairingRegistry(
...@@ -1724,7 +1724,12 @@ void HostProcess::GoOffline(const std::string& host_offline_reason) { ...@@ -1724,7 +1724,12 @@ void HostProcess::GoOffline(const std::string& host_offline_reason) {
// Before shutting down HostSignalingManager, send the |host_offline_reason| // Before shutting down HostSignalingManager, send the |host_offline_reason|
// if possible (i.e. if we have the config). // if possible (i.e. if we have the config).
if (!serialized_config_.empty()) { if (host_offline_reason == ExitCodeToString(kHostDeletedExitCode)) {
// Host is deleted. There is no need to report the host offline reason back
// to directory.
OnHostOfflineReasonAck(true);
return;
} else if (!serialized_config_.empty()) {
if (!signal_strategy_) if (!signal_strategy_)
InitializeSignaling(); InitializeSignaling();
......
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