-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Orchestrator Channel creation to helper in oak_sdk/containers
Provides a consistent interface for creating a new Oak Orchestrator client channel. This reduces the number of channels created on startup, and simplifies constructors for many other types. Bug: b/357921050 Change-Id: Id7e06df3704778f67ec8514dd93807ffe13c0373
- Loading branch information
Showing
11 changed files
with
122 additions
and
74 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
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
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,41 @@ | ||
# | ||
# Copyright 2024 The Project Oak 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. | ||
# | ||
|
||
load("@rules_rust//rust:defs.bzl", "rust_library") | ||
|
||
package( | ||
default_visibility = ["//:default_visibility"], | ||
licenses = ["notice"], | ||
) | ||
|
||
rust_library( | ||
name = "oak_sdk_containers", | ||
srcs = ["lib.rs"], | ||
deps = [ | ||
":orchestrator_channel", | ||
], | ||
) | ||
|
||
rust_library( | ||
name = "orchestrator_channel", | ||
srcs = ["orchestrator_channel.rs"], | ||
deps = [ | ||
"@oak_crates_index//:anyhow", | ||
"@oak_crates_index//:tokio", | ||
"@oak_crates_index//:tonic", | ||
"@oak_crates_index//:tower", | ||
], | ||
) |
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,17 @@ | ||
// | ||
// Copyright 2025 The Project Oak 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. | ||
// | ||
|
||
pub use orchestrator_channel::default_orchestrator_channel; |
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,38 @@ | ||
// | ||
// Copyright 2025 The Project Oak 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. | ||
|
||
use anyhow::{Context, Result}; | ||
use tokio::net::UnixStream; | ||
use tonic::transport::{Channel, Endpoint, Uri}; | ||
use tower::service_fn; | ||
// Unix Domain Sockets do not use URIs, hence this URI will never be used. | ||
// It is defined purely since in order to create a channel, since a URI has to | ||
// be supplied to create an `Endpoint`. Even though in this case the endpoint | ||
// is technically a file, tonic expects us to provide our own connector, and | ||
// this ignored endpoint. :( | ||
static IGNORED_ENDPOINT_URI: &str = "file://[::]:0"; | ||
|
||
// Path used to facilitate inter-process communication between the orchestrator | ||
// and the trusted application. | ||
const IPC_SOCKET: &str = "/oak_utils/orchestrator_ipc"; | ||
|
||
// Connect to the orchestrator instance in a default Oak Containers stack. | ||
pub async fn default_orchestrator_channel() -> Result<Channel> { | ||
Endpoint::try_from(IGNORED_ENDPOINT_URI) | ||
.context("couldn't form endpoint")? | ||
.connect_with_connector(service_fn(move |_: Uri| UnixStream::connect(IPC_SOCKET))) | ||
.await | ||
.context("couldn't connect to UDS socket") | ||
} |