Skip to content

Commit 4062ec3

Browse files
committed
Remove remaining references to the cvd server
1 parent 1f1f356 commit 4062ec3

24 files changed

+7
-968
lines changed

base/cvd/cuttlefish/host/commands/cvd/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ cf_cc_library(
1919
"//cuttlefish/host/commands/cvd/cli:nesting_commands",
2020
"//cuttlefish/host/commands/cvd/instances",
2121
"//cuttlefish/host/commands/cvd/instances/lock",
22-
"//cuttlefish/host/commands/cvd/legacy:cvd_server_cc_proto",
2322
"//cuttlefish/host/commands/cvd/utils",
2423
"//libbase",
2524
],
@@ -35,7 +34,6 @@ cf_cc_binary(
3534
"//cuttlefish/common/libs/utils:files",
3635
"//cuttlefish/common/libs/utils:flag_parser",
3736
"//cuttlefish/common/libs/utils:subprocess",
38-
"//cuttlefish/host/commands/cvd/legacy",
3937
"//cuttlefish/host/commands/cvd/utils",
4038
"//cuttlefish/host/commands/cvd/version",
4139
"//libbase",

base/cvd/cuttlefish/host/commands/cvd/cli/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ cf_cc_library(
114114
"//cuttlefish/host/commands/cvd/instances",
115115
"//cuttlefish/host/commands/cvd/instances:cvd_persistent_data",
116116
"//cuttlefish/host/commands/cvd/instances/lock",
117-
"//cuttlefish/host/commands/cvd/legacy:cvd_server_cc_proto",
118117
"//cuttlefish/host/commands/cvd/utils",
119118
"//cuttlefish/host/libs/metrics:metrics_orchestration",
120119
"//libbase",

base/cvd/cuttlefish/host/commands/cvd/cli/commands/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ cf_cc_library(
6969
"//cuttlefish/host/commands/cvd/cli:types",
7070
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
7171
"//cuttlefish/host/commands/cvd/instances",
72-
"//cuttlefish/host/commands/cvd/legacy:cvd_server_cc_proto",
7372
],
7473
)
7574

@@ -435,7 +434,6 @@ cf_cc_library(
435434
"//cuttlefish/host/commands/cvd/cli:command_request",
436435
"//cuttlefish/host/commands/cvd/cli:types",
437436
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
438-
"//cuttlefish/host/commands/cvd/legacy",
439437
"//cuttlefish/host/commands/cvd/utils",
440438
"//cuttlefish/host/commands/cvd/version",
441439
"@fmt",

base/cvd/cuttlefish/host/commands/cvd/cli/commands/clear.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "cuttlefish/host/commands/cvd/cli/commands/command_handler.h"
2626
#include "cuttlefish/host/commands/cvd/cli/types.h"
2727
#include "cuttlefish/host/commands/cvd/instances/instance_manager.h"
28-
#include "cuttlefish/host/commands/cvd/legacy/cvd_server.pb.h"
2928

3029
namespace cuttlefish {
3130
namespace {
@@ -54,7 +53,7 @@ CvdClearCommandHandler::CvdClearCommandHandler(
5453

5554
Result<void> CvdClearCommandHandler::Handle(const CommandRequest& request) {
5655
CF_EXPECT(CanHandle(request));
57-
CF_EXPECT_EQ(instance_manager_.CvdClear(request).code(), cvd::Status::OK);
56+
CF_EXPECT(instance_manager_.CvdClear(request));
5857
return {};
5958
}
6059

base/cvd/cuttlefish/host/commands/cvd/cli/commands/reset.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,6 @@ class CvdResetCommandHandler : public CvdCommandHandler {
149149
LOG(ERROR) << "Error deleting instance database file";
150150
}
151151

152-
// Any responsive cvd server process was stopped nicely when this process
153-
// began, kill any unresponsive ones left.
154-
auto server_kill_res = KillCvdServerProcess();
155-
if (!server_kill_res.ok()) {
156-
LOG(ERROR) << "Error trying to kill unresponsive cvd server: "
157-
<< server_kill_res.error().Message();
158-
}
159152
CF_EXPECT(KillAllCuttlefishInstances(
160153
/* clear_instance_dirs*/ options.clean_runtime_dir));
161154
return {};

base/cvd/cuttlefish/host/commands/cvd/instances/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ cf_cc_library(
140140
"//cuttlefish/host/commands/cvd/instances:device_name",
141141
"//cuttlefish/host/commands/cvd/instances:run_cvd_proc_collector",
142142
"//cuttlefish/host/commands/cvd/instances/lock",
143-
"//cuttlefish/host/commands/cvd/legacy:cvd_server_cc_proto",
144143
"//cuttlefish/host/commands/cvd/utils",
145144
"//cuttlefish/host/libs/command_util",
146145
"//cuttlefish/host/libs/config:config_constants",
@@ -167,7 +166,6 @@ cf_cc_library(
167166
"//cuttlefish/common/libs/utils:subprocess_managed_stdio",
168167
"//cuttlefish/host/commands/cvd/instances",
169168
"//cuttlefish/host/commands/cvd/instances:run_cvd_proc_collector",
170-
"//cuttlefish/host/commands/cvd/legacy",
171169
"//cuttlefish/host/commands/cvd/utils",
172170
"//libbase",
173171
"@fmt",

base/cvd/cuttlefish/host/commands/cvd/instances/instance_database.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ namespace cuttlefish {
4040

4141
namespace {
4242

43-
constexpr const char kJsonGroups[] = "Groups";
44-
4543
constexpr const unsigned UNSET_ID = 0;
4644

4745
Result<std::string> GenUniqueGroupName(const cvd::PersistentData& data) {
@@ -269,23 +267,4 @@ Result<std::vector<LocalInstanceGroup>> InstanceDatabase::InstanceGroups()
269267
});
270268
}
271269

272-
Result<void> InstanceDatabase::LoadFromJson(const Json::Value& db_json) {
273-
std::vector<LocalInstanceGroup> new_groups;
274-
CF_EXPECT(db_json.isMember(kJsonGroups));
275-
const Json::Value& group_array = db_json[kJsonGroups];
276-
CF_EXPECT(group_array.isArray());
277-
int n_groups = group_array.size();
278-
for (int i = 0; i < n_groups; i++) {
279-
new_groups.push_back(
280-
CF_EXPECT(LocalInstanceGroup::Deserialize(group_array[i])));
281-
}
282-
return viewer_.WithExclusiveLock<void>(
283-
[&new_groups](cvd::PersistentData& data) -> Result<void> {
284-
for (const auto& group : new_groups) {
285-
*data.add_instance_groups() = group.Proto();
286-
}
287-
return {};
288-
});
289-
}
290-
291270
} // namespace cuttlefish

base/cvd/cuttlefish/host/commands/cvd/instances/instance_database.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include <utility>
2323
#include <vector>
2424

25-
#include <json/json.h>
26-
2725
#include "cuttlefish/common/libs/utils/result.h"
2826
#include "cuttlefish/host/commands/cvd/instances/cvd_persistent_data.pb.h"
2927
#include "cuttlefish/host/commands/cvd/instances/data_viewer.h"
@@ -51,8 +49,6 @@ class InstanceDatabase {
5149

5250
Result<bool> IsEmpty() const;
5351

54-
Result<void> LoadFromJson(const Json::Value&);
55-
5652
/** Adds instance group.
5753
*
5854
* A new group name will be generated one is not provided.

base/cvd/cuttlefish/host/commands/cvd/instances/instance_database_test.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -440,57 +440,6 @@ TEST_F(CvdInstanceDatabaseTest, AddInstancesTogether) {
440440
ASSERT_TRUE(result_tv.ok()) << result_tv.error().Trace();
441441
}
442442

443-
TEST_F(CvdInstanceDatabaseJsonTest, DumpLoadDumpCompare) {
444-
// starting set up
445-
if (!SetUpOk()) {
446-
GTEST_SKIP() << Error().msg;
447-
}
448-
/*
449-
* Dumping to json, clearing up the DB, loading from the json,
450-
*
451-
*/
452-
auto serialized_db =
453-
"{"
454-
" \"Groups\" : ["
455-
" {"
456-
" \"Group Name\" : \"miau\","
457-
" \"Host Tools Dir\" : \"/host/out/path\","
458-
" \"Instances\" : ["
459-
" {"
460-
" \"Instance Id\" : \"1\","
461-
" \"Parent Group\" : \"miau\","
462-
" \"Per-Instance Name\" : \"8\""
463-
" },{"
464-
" \"Instance Id\" : \"10\","
465-
" \"Parent Group\" : \"miau\","
466-
" \"Per-Instance Name\" : \"tv_instance\""
467-
" }"
468-
" ],"
469-
" \"Product Out Dir\" : \"/product/out/path\","
470-
" \"Runtime/Home Dir\" : \"/home/dir\","
471-
" \"Start Time\" : \"123456789\""
472-
" }"
473-
" ]"
474-
"}";
475-
auto json_parsing = ParseJson(serialized_db);
476-
ASSERT_TRUE(json_parsing.ok()) << serialized_db << std::endl
477-
<< " is not a valid json.";
478-
auto& db = GetDb();
479-
auto load_result = db.LoadFromJson(*json_parsing);
480-
ASSERT_TRUE(load_result.ok()) << load_result.error().Trace();
481-
{
482-
// re-look up the group and the instances
483-
auto miau_group = db.FindGroup({.group_name = "miau"});
484-
ASSERT_TRUE(miau_group.ok()) << miau_group.error().Trace();
485-
auto result_8 = db.FindInstanceWithGroup({.instance_names = {"8"}});
486-
auto result_tv =
487-
db.FindInstanceWithGroup({.instance_names = {"tv_instance"}});
488-
489-
ASSERT_TRUE(result_8.ok()) << result_8.error().Trace();
490-
ASSERT_TRUE(result_tv.ok()) << result_tv.error().Trace();
491-
}
492-
}
493-
494443
TEST_F(CvdInstanceDatabaseTest, UpdateInstances) {
495444
if (!SetUpOk()) {
496445
GTEST_SKIP() << Error().msg;

base/cvd/cuttlefish/host/commands/cvd/instances/instance_group_record.cpp

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <android-base/file.h>
2828
#include <android-base/parseint.h>
2929
#include <android-base/strings.h>
30+
#include <json/json.h>
3031

3132
#include "cuttlefish/common/libs/utils/result.h"
3233
#include "cuttlefish/host/commands/cvd/instances/instance_database_types.h"
@@ -36,15 +37,6 @@ namespace cuttlefish {
3637

3738
namespace {
3839

39-
static constexpr const char kJsonGroupName[] = "Group Name";
40-
static constexpr const char kJsonHomeDir[] = "Runtime/Home Dir";
41-
static constexpr const char kJsonHostArtifactPath[] = "Host Tools Dir";
42-
static constexpr const char kJsonProductOutPath[] = "Product Out Dir";
43-
static constexpr const char kJsonStartTime[] = "Start Time";
44-
static constexpr const char kJsonInstances[] = "Instances";
45-
static constexpr const char kJsonInstanceId[] = "Instance Id";
46-
static constexpr const char kJsonInstanceName[] = "Per-Instance Name";
47-
4840
std::vector<LocalInstance> Filter(
4941
const std::vector<LocalInstance>& instances,
5042
std::function<bool(const LocalInstance&)> predicate) {
@@ -192,63 +184,6 @@ std::string LocalInstanceGroup::BaseDir() const {
192184
return android::base::Dirname(HomeDir());
193185
}
194186

195-
Result<LocalInstanceGroup> LocalInstanceGroup::Deserialize(
196-
const Json::Value& group_json) {
197-
CF_EXPECT(group_json.isMember(kJsonGroupName));
198-
const std::string group_name = group_json[kJsonGroupName].asString();
199-
CF_EXPECT(group_json.isMember(kJsonHomeDir));
200-
const std::string home_dir = group_json[kJsonHomeDir].asString();
201-
CF_EXPECT(group_json.isMember(kJsonHostArtifactPath));
202-
const std::string host_artifacts_path =
203-
group_json[kJsonHostArtifactPath].asString();
204-
CF_EXPECT(group_json.isMember(kJsonProductOutPath));
205-
const std::string product_out_path =
206-
group_json[kJsonProductOutPath].asString();
207-
TimeStamp start_time = CvdServerClock::now();
208-
209-
// test if the field is available as the field has been added
210-
// recently as of b/315855286
211-
if (group_json.isMember(kJsonStartTime)) {
212-
auto restored_start_time_result =
213-
DeserializeTimePoint(group_json[kJsonStartTime]);
214-
if (restored_start_time_result.ok()) {
215-
start_time = std::move(*restored_start_time_result);
216-
} else {
217-
LOG(ERROR) << "Start time restoration from json failed, so we use "
218-
<< " the current system time. Reasons: "
219-
<< restored_start_time_result.error().FormatForEnv();
220-
}
221-
}
222-
223-
cvd::InstanceGroup group_proto;
224-
group_proto.set_name(group_name);
225-
group_proto.set_home_directory(home_dir);
226-
group_proto.set_host_artifacts_path(host_artifacts_path);
227-
group_proto.set_product_out_path(product_out_path);
228-
group_proto.set_start_time_sec(CvdServerClock::to_time_t(start_time));
229-
230-
CF_EXPECT(group_json.isMember(kJsonInstances));
231-
const Json::Value& instances_json_array = group_json[kJsonInstances];
232-
CF_EXPECT(instances_json_array.isArray());
233-
for (int i = 0; i < (int)instances_json_array.size(); i++) {
234-
const Json::Value& instance_json = instances_json_array[i];
235-
CF_EXPECT(instance_json.isMember(kJsonInstanceName));
236-
const std::string instance_name =
237-
instance_json[kJsonInstanceName].asString();
238-
CF_EXPECT(instance_json.isMember(kJsonInstanceId));
239-
const std::string instance_id = instance_json[kJsonInstanceId].asString();
240-
241-
int id = -1;
242-
CF_EXPECTF(android::base::ParseInt(instance_id, std::addressof(id)),
243-
"Invalid instance ID in instance json: {}", instance_id);
244-
auto instance = group_proto.add_instances();
245-
instance->set_id(id);
246-
instance->set_name(instance_name);
247-
}
248-
249-
return Create(group_proto);
250-
}
251-
252187
Result<Json::Value> LocalInstanceGroup::FetchStatus(
253188
std::chrono::seconds timeout) {
254189
Json::Value instances_json(Json::arrayValue);

0 commit comments

Comments
 (0)