Commit 020b6b75 authored by Joe Downing's avatar Joe Downing Committed by Chromium LUCI CQ

Remove remote command logic from the host

The RemoteCommand logic will not be supported server-side in the near
future so I'm removing it from M89.  I don't think we can remove it
from the protos or we will break back compat so for now the host
will just log an error message if it receives a remote command.

Change-Id: Ieee15b0d225f645dff40b297f6fc3cce5f887f4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2596109Reviewed-by: default avatarYuwei Huang <yuweih@chromium.org>
Commit-Queue: Joe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837752}
parent 3a724a44
......@@ -317,7 +317,7 @@ void HeartbeatSender::OnResponse(
}
if (response->has_remote_command()) {
OnRemoteCommand(response->remote_command());
LOG(WARNING) << "Remote command ignored: " << response->remote_command();
}
} else {
LOG(ERROR) << "Heartbeat failed. Error code: "
......@@ -379,21 +379,6 @@ void HeartbeatSender::OnResponse(
&HeartbeatSender::SendHeartbeat);
}
void HeartbeatSender::OnRemoteCommand(
apis::v1::HeartbeatResponse::RemoteCommand remote_command) {
HOST_LOG << "Received remote command: "
<< apis::v1::HeartbeatResponse::RemoteCommand_Name(remote_command)
<< "(" << remote_command << ")";
switch (remote_command) {
case apis::v1::HeartbeatResponse::RESTART_HOST:
delegate_->OnRemoteRestartHost();
break;
default:
LOG(WARNING) << "Unknown remote command: " << remote_command;
break;
}
}
std::unique_ptr<apis::v1::HeartbeatRequest>
HeartbeatSender::CreateHeartbeatRequest() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
......@@ -46,8 +46,7 @@ class ProtobufHttpStatus;
// so that the signaling connector will try to reconnect signaling.
//
// The server sends a HeartbeatResponse in response to each successful
// heartbeat, which may contain a remote command to be executed on the host,
// e.g. restarting the host process upon reception of the response.
// heartbeat.
class HeartbeatSender final : public SignalStrategy::Listener {
public:
class Delegate {
......@@ -64,9 +63,6 @@ class HeartbeatSender final : public SignalStrategy::Listener {
// requests.
virtual void OnAuthFailed() = 0;
// Invoked when the host has been asked to restart.
virtual void OnRemoteRestartHost() = 0;
protected:
Delegate() = default;
};
......@@ -138,9 +134,6 @@ class HeartbeatSender final : public SignalStrategy::Listener {
void OnHostOfflineReasonTimeout();
void OnHostOfflineReasonAck();
void OnRemoteCommand(
apis::v1::HeartbeatResponse::RemoteCommand remote_command);
// Helper methods used by DoSendStanza() to generate heartbeat stanzas.
std::unique_ptr<apis::v1::HeartbeatRequest> CreateHeartbeatRequest();
......
......@@ -102,7 +102,6 @@ class MockDelegate : public HeartbeatSender::Delegate {
MOCK_METHOD0(OnFirstHeartbeatSuccessful, void());
MOCK_METHOD0(OnHostNotFound, void());
MOCK_METHOD0(OnAuthFailed, void());
MOCK_METHOD0(OnRemoteRestartHost, void());
};
class MockObserver : public HeartbeatSender::Observer {
......@@ -343,22 +342,6 @@ TEST_F(HeartbeatSenderTest, Unauthenticated) {
ASSERT_LT(1, heartbeat_count);
}
TEST_F(HeartbeatSenderTest, RemoteCommand) {
EXPECT_CALL(*mock_client_, Heartbeat(_, _))
.WillOnce([](std::unique_ptr<apis::v1::HeartbeatRequest> request,
HeartbeatResponseCallback callback) {
ValidateHeartbeat(std::move(request), true);
auto response = std::make_unique<apis::v1::HeartbeatResponse>();
response->set_set_interval_seconds(kGoodIntervalSeconds);
response->set_remote_command(apis::v1::HeartbeatResponse::RESTART_HOST);
std::move(callback).Run(ProtobufHttpStatus::OK(), std::move(response));
});
EXPECT_CALL(*mock_observer_, OnHeartbeatSent()).Times(1);
EXPECT_CALL(mock_delegate_, OnFirstHeartbeatSuccessful()).Times(1);
EXPECT_CALL(mock_delegate_, OnRemoteRestartHost()).Times(1);
signal_strategy_->Connect();
}
TEST_F(HeartbeatSenderTest, GooglerHostname) {
set_is_googler();
EXPECT_CALL(*mock_client_, Heartbeat(_, _))
......
......@@ -192,7 +192,6 @@ const int kHostOfflineReasonTimeoutSeconds = 10;
const char kHostOfflineReasonPolicyReadError[] = "POLICY_READ_ERROR";
const char kHostOfflineReasonPolicyChangeRequiresRestart[] =
"POLICY_CHANGE_REQUIRES_RESTART";
const char kHostOfflineReasonRemoteRestartHost[] = "REMOTE_RESTART_HOST";
const char kHostOfflineReasonZombieStateDetected[] = "ZOMBIE_STATE_DETECTED";
// The default email domain for Googlers. Used to determine whether the host's
......@@ -326,11 +325,10 @@ class HostProcess : public ConfigWatcher::Delegate,
void StartHostIfReady();
void StartHost();
// HeartbeatSender::Delegate implementations.
// HeartbeatSender::Delegate implementation.
void OnFirstHeartbeatSuccessful() override;
void OnHostNotFound() override;
void OnAuthFailed() override;
void OnRemoteRestartHost() override;
void OnZombieStateDetected();
......@@ -1605,10 +1603,6 @@ void HostProcess::OnAuthFailed() {
ShutdownHost(kInvalidOauthCredentialsExitCode);
}
void HostProcess::OnRemoteRestartHost() {
RestartHost(kHostOfflineReasonRemoteRestartHost);
}
void HostProcess::OnZombieStateDetected() {
RestartHost(kHostOfflineReasonZombieStateDetected);
}
......
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