Commit 03476cf7 authored by Jae Hoon Kim's avatar Jae Hoon Kim Committed by Commit Bot

Log dlcservice availability

CQ is facing flakes from time to time where DBus method calls into
dlcservice is returning |org.freedesktop.DBus.Error.NoReply|.

This logging will help narrow down if service availability is the
cause as Chrome is frequently restarted during tast test runs.

BUG=b:164310699
TEST=unit_tests

Change-Id: Iebca6437c9407ea74c3dca06dddfb998733afae1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2358132
Commit-Queue: Jae Hoon Kim <kimjae@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798889}
parent 47d59d25
......@@ -107,6 +107,7 @@ class DlcserviceClientImpl : public DlcserviceClient {
void Install(const std::string& dlc_id,
InstallCallback install_callback,
ProgressCallback progress_callback) override {
CheckServiceAvailable("Install");
// If another installation for the same DLC ID was already called, go ahead
// and hold the installation fields.
if (installation_holder_.find(dlc_id) != installation_holder_.end()) {
......@@ -138,6 +139,7 @@ class DlcserviceClientImpl : public DlcserviceClient {
void Uninstall(const std::string& dlc_id,
UninstallCallback uninstall_callback) override {
CheckServiceAvailable("Uninstall");
dbus::MethodCall method_call(dlcservice::kDlcServiceInterface,
dlcservice::kUninstallMethod);
dbus::MessageWriter writer(&method_call);
......@@ -152,6 +154,7 @@ class DlcserviceClientImpl : public DlcserviceClient {
}
void Purge(const std::string& dlc_id, PurgeCallback purge_callback) override {
CheckServiceAvailable("Purge");
dbus::MethodCall method_call(dlcservice::kDlcServiceInterface,
dlcservice::kPurgeMethod);
dbus::MessageWriter writer(&method_call);
......@@ -166,6 +169,7 @@ class DlcserviceClientImpl : public DlcserviceClient {
}
void GetExistingDlcs(GetExistingDlcsCallback callback) override {
CheckServiceAvailable("GetExistingDlcs");
dbus::MethodCall method_call(dlcservice::kDlcServiceInterface,
dlcservice::kGetExistingDlcsMethod);
......@@ -198,6 +202,9 @@ class DlcserviceClientImpl : public DlcserviceClient {
weak_ptr_factory_.GetWeakPtr()),
base::BindOnce(&DlcserviceClientImpl::DlcStateChangedConnected,
weak_ptr_factory_.GetWeakPtr()));
dlcservice_proxy_->WaitForServiceToBeAvailable(
base::BindOnce(&DlcserviceClientImpl::OnServiceAvailable,
weak_ptr_factory_.GetWeakPtr()));
}
private:
......@@ -214,6 +221,14 @@ class DlcserviceClientImpl : public DlcserviceClient {
progress_callback(std::move(progress_callback)) {}
};
void OnServiceAvailable(bool service_available) {
if (service_available)
VLOG(1) << "dlcservice is available.";
else
LOG(ERROR) << "dlcservice is not available.";
service_available_ = service_available;
}
// Set the indication that an install is being performed which was requested
// from this client (Chrome specifically).
void TaskStarted() { installing_ = true; }
......@@ -372,6 +387,14 @@ class DlcserviceClientImpl : public DlcserviceClient {
}
}
// TODO(b/164310699): This check is added in order to see if dlcservice daemon
// not being available is the cause of flakes in the CQ.
void CheckServiceAvailable(const std::string& method_name) {
if (!service_available_)
LOG(WARNING) << method_name
<< " called when dlcservice is not available.";
}
// DLC ID to |InstallationCallbacks| mapping.
std::map<std::string, std::vector<InstallationCallbacks>>
installation_holder_;
......@@ -390,6 +413,9 @@ class DlcserviceClientImpl : public DlcserviceClient {
// A list of observers that are listening on state changes, etc.
base::ObserverList<Observer> observers_;
// Indicates if dlcservice daemon is available.
bool service_available_ = false;
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<DlcserviceClientImpl> weak_ptr_factory_{this};
......
......@@ -61,6 +61,8 @@ class DlcserviceClientTest : public testing::Test {
DoConnectToSignal(dlcservice::kDlcServiceInterface, _, _, _))
.WillOnce(Invoke(this, &DlcserviceClientTest::ConnectToSignal));
EXPECT_CALL(*mock_proxy_.get(), DoWaitForServiceToBeAvailable(_)).Times(1);
DlcserviceClient::Initialize(mock_bus_.get());
client_ = DlcserviceClient::Get();
......
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