-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1/n] Stabilize GCS/Autoscaler interface: Introduce monitor server (#…
…31827) This is the first PR towards stabilizing the GCS autoscaler interface by introducing a new grpc service definition which we will provide backwards compatibility guarantees. This PR mostly just introduces scaffolding and a trivial GetRayVersion endpoint. By the end of this series of PRs, monitor.py will only communicate with the rest of the ray cluster via this service definition.
- Loading branch information
Alex Wu
authored
Jan 26, 2023
1 parent
a32b9b1
commit e753b03
Showing
11 changed files
with
278 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pytest | ||
|
||
import ray | ||
import grpc | ||
from ray.core.generated import monitor_pb2, monitor_pb2_grpc | ||
|
||
|
||
@pytest.fixture | ||
def monitor_stub(ray_start_regular_shared): | ||
channel = grpc.insecure_channel(ray_start_regular_shared["gcs_address"]) | ||
|
||
return monitor_pb2_grpc.MonitorGcsServiceStub(channel) | ||
|
||
|
||
def test_ray_version(monitor_stub): | ||
request = monitor_pb2.GetRayVersionRequest() | ||
response = monitor_stub.GetRayVersion(request) | ||
assert response.version == ray.__version__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2017 The Ray Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "ray/gcs/gcs_server/gcs_monitor_server.h" | ||
|
||
#include "ray/common/constants.h" | ||
|
||
namespace ray { | ||
namespace gcs { | ||
|
||
GcsMonitorServer::GcsMonitorServer() {} | ||
|
||
void GcsMonitorServer::HandleGetRayVersion(rpc::GetRayVersionRequest request, | ||
rpc::GetRayVersionReply *reply, | ||
rpc::SendReplyCallback send_reply_callback) { | ||
reply->set_version(kRayVersion); | ||
send_reply_callback(Status::OK(), nullptr, nullptr); | ||
} | ||
|
||
} // namespace gcs | ||
} // namespace ray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2023 The Ray Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include "ray/rpc/gcs_server/gcs_rpc_server.h" | ||
|
||
namespace ray { | ||
namespace gcs { | ||
|
||
/// GcsMonitorServer is a shim responsible for providing a compatible interface between | ||
/// GCS and `monitor.py` | ||
class GcsMonitorServer : public rpc::MonitorServiceHandler { | ||
public: | ||
explicit GcsMonitorServer(); | ||
|
||
void HandleGetRayVersion(rpc::GetRayVersionRequest request, | ||
rpc::GetRayVersionReply *reply, | ||
rpc::SendReplyCallback send_reply_callback) override; | ||
}; | ||
} // namespace gcs | ||
} // namespace ray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
// Copyright 2017 The Ray Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <memory> | ||
|
||
// clang-format off | ||
#include "gtest/gtest.h" | ||
#include "ray/gcs/gcs_server/test/gcs_server_test_util.h" | ||
#include "ray/gcs/test/gcs_test_util.h" | ||
#include "ray/gcs/gcs_server/gcs_monitor_server.h" | ||
#include "mock/ray/pubsub/publisher.h" | ||
// clang-format on | ||
|
||
namespace ray { | ||
class GcsMonitorServerTest : public ::testing::Test { | ||
public: | ||
GcsMonitorServerTest() : monitor_server_() {} | ||
|
||
protected: | ||
gcs::GcsMonitorServer monitor_server_; | ||
}; | ||
|
||
TEST_F(GcsMonitorServerTest, TestRayVersion) { | ||
rpc::GetRayVersionRequest request; | ||
rpc::GetRayVersionReply reply; | ||
auto send_reply_callback = | ||
[](ray::Status status, std::function<void()> f1, std::function<void()> f2) {}; | ||
|
||
monitor_server_.HandleGetRayVersion(request, &reply, send_reply_callback); | ||
|
||
ASSERT_EQ(reply.version(), kRayVersion); | ||
} | ||
|
||
} // namespace ray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2017 The Ray Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
option cc_enable_arenas = true; | ||
package ray.rpc; | ||
|
||
message GetRayVersionRequest {} | ||
|
||
message GetRayVersionReply { | ||
string version = 1; | ||
} | ||
|
||
// This service provides a stable interface for a monitor/autoscaler process to interact | ||
// with Ray. | ||
service MonitorGcsService { | ||
// Get the ray version of the service. | ||
rpc GetRayVersion(GetRayVersionRequest) returns (GetRayVersionReply); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters