Skip to content

Commit b69a125

Browse files
committed
fix(windows): resolve platform lint warnings
Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
1 parent fa63386 commit b69a125

9 files changed

Lines changed: 86 additions & 23 deletions

File tree

‎.github/workflows/windows-msvc.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
--all-targets
8787
--no-deps
8888
--features openshell-prover/prebuilt-z3
89-
-- -D warnings -A dead-code -A unused-imports -A clippy::unused-async
89+
-- -D warnings
9090
- name: Test
9191
run: mise run --skip-tools test:rust
9292
- name: sccache stats
@@ -140,7 +140,7 @@ jobs:
140140
--all-targets
141141
--no-deps
142142
--features openshell-prover/prebuilt-z3
143-
-- -D warnings -A dead-code -A unused-imports -A clippy::unused-async
143+
-- -D warnings
144144
- name: Test
145145
run: mise run --skip-tools test:rust
146146
- name: sccache stats

‎architecture/windows-msvc-build.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ The x64 GitHub Actions jobs run on `windows-2025`. Pull-request mirrors and
139139
merge queues execute:
140140

141141
```powershell
142-
cargo clippy -p openshell-server -p openshell-core -p openshell-cli --all-targets --no-deps --features openshell-prover/prebuilt-z3 -- -D warnings -A dead-code -A unused-imports -A clippy::unused-async
142+
cargo clippy -p openshell-server -p openshell-core -p openshell-cli --all-targets --no-deps --features openshell-prover/prebuilt-z3 -- -D warnings
143143
mise run --skip-tools test:rust
144144
```
145145

‎crates/openshell-core/src/config.rs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,13 +1041,15 @@ mod tests {
10411041
use super::{
10421042
ComputeDriverKind, Config, DEFAULT_SERVICE_ROUTING_DOMAIN, GatewayInterceptorBindingPolicy,
10431043
GatewayInterceptorConfig, GatewayInterceptorFailurePolicy, GatewayJwtConfig,
1044-
GatewayProviderProfileSourceConfig, PolicyValidationFailureMode,
1045-
detect_docker_socket_from_candidates, detect_driver, detect_podman_socket_from_candidates,
1046-
docker_host_unix_socket_path, docker_socket_responds, normalize_compute_driver_name,
1047-
podman_socket_candidates_from_env, podman_socket_responds,
1044+
GatewayProviderProfileSourceConfig, PolicyValidationFailureMode, detect_driver,
1045+
docker_host_unix_socket_path, normalize_compute_driver_name,
1046+
podman_socket_candidates_from_env,
10481047
};
10491048
#[cfg(unix)]
1050-
use super::{is_reachable_unix_socket, is_unix_socket};
1049+
use super::{
1050+
detect_docker_socket_from_candidates, detect_podman_socket_from_candidates,
1051+
docker_socket_responds, is_reachable_unix_socket, is_unix_socket, podman_socket_responds,
1052+
};
10511053
#[cfg(unix)]
10521054
use std::io::{Read as _, Write as _};
10531055
use std::net::SocketAddr;

‎crates/openshell-server/src/auth/k8s_sa.rs‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,26 @@
1818
use super::authenticator::Authenticator;
1919
use super::principal::{Principal, SandboxIdentitySource, SandboxPrincipal};
2020
use async_trait::async_trait;
21+
#[cfg(any(not(target_os = "windows"), test))]
2122
use k8s_openapi::api::{
2223
authentication::v1::{TokenReview, TokenReviewSpec, TokenReviewStatus, UserInfo},
2324
core::v1::Pod,
2425
};
26+
#[cfg(any(not(target_os = "windows"), test))]
2527
use k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
28+
#[cfg(any(not(target_os = "windows"), test))]
2629
use kube::Error as KubeError;
30+
#[cfg(not(target_os = "windows"))]
2731
use kube::api::{Api, ApiResource, PostParams};
28-
use kube::core::{DynamicObject, gvk::GroupVersionKind};
32+
#[cfg(any(not(target_os = "windows"), test))]
33+
use kube::core::DynamicObject;
34+
#[cfg(not(target_os = "windows"))]
35+
use kube::core::gvk::GroupVersionKind;
2936
use std::sync::Arc;
3037
use tonic::Status;
31-
use tracing::{debug, info, warn};
38+
#[cfg(not(target_os = "windows"))]
39+
use tracing::info;
40+
use tracing::{debug, warn};
3241

3342
/// gRPC method path that this authenticator accepts. All other paths fall
3443
/// through (return `Ok(None)`) so a gateway-minted JWT is required there.
@@ -39,15 +48,25 @@ pub const ISSUE_SANDBOX_TOKEN_PATH: &str = "/openshell.v1.OpenShell/IssueSandbox
3948
/// annotation only after validating the pod's `TokenReview` binding, live UID,
4049
/// and owning Sandbox CR. The K8s `Role` granted to the gateway must not
4150
/// include `patch pods` (see plan §11.8).
51+
#[cfg(any(not(target_os = "windows"), test))]
4252
pub const SANDBOX_ID_ANNOTATION: &str = "openshell.io/sandbox-id";
53+
#[cfg(any(not(target_os = "windows"), test))]
4354
const SANDBOX_API_GROUP: &str = "agents.x-k8s.io";
55+
#[cfg(any(not(target_os = "windows"), test))]
4456
const SANDBOX_API_VERSION_V1BETA1: &str = "v1beta1";
57+
#[cfg(not(target_os = "windows"))]
4558
const SANDBOX_API_VERSION_V1ALPHA1: &str = "v1alpha1";
59+
#[cfg(any(not(target_os = "windows"), test))]
4660
const SANDBOX_API_VERSION_FULL_V1BETA1: &str = "agents.x-k8s.io/v1beta1";
61+
#[cfg(any(not(target_os = "windows"), test))]
4762
const SANDBOX_API_VERSION_FULL_V1ALPHA1: &str = "agents.x-k8s.io/v1alpha1";
63+
#[cfg(any(not(target_os = "windows"), test))]
4864
const SANDBOX_KIND: &str = "Sandbox";
65+
#[cfg(any(not(target_os = "windows"), test))]
4966
const SANDBOX_ID_LABEL: &str = "openshell.ai/sandbox-id";
67+
#[cfg(any(not(target_os = "windows"), test))]
5068
const POD_NAME_EXTRA: &str = "authentication.kubernetes.io/pod-name";
69+
#[cfg(any(not(target_os = "windows"), test))]
5170
const POD_UID_EXTRA: &str = "authentication.kubernetes.io/pod-uid";
5271

5372
/// Resolved identity extracted from a validated SA token + pod lookup.
@@ -136,12 +155,14 @@ impl Authenticator for K8sServiceAccountAuthenticator {
136155
}
137156

138157
#[derive(Debug)]
158+
#[cfg(any(not(target_os = "windows"), test))]
139159
struct TokenReviewIdentity {
140160
pod_name: String,
141161
pod_uid: String,
142162
}
143163

144164
#[derive(Debug, Clone, PartialEq, Eq)]
165+
#[cfg(any(not(target_os = "windows"), test))]
145166
struct SandboxOwnerReference {
146167
api_version: String,
147168
name: String,
@@ -150,6 +171,7 @@ struct SandboxOwnerReference {
150171

151172
/// Resolver backed by the apiserver's `TokenReview` API and `kube::Client`
152173
/// for the per-pod annotation lookup.
174+
#[cfg(not(target_os = "windows"))]
153175
pub struct LiveK8sResolver {
154176
token_reviews_api: Api<TokenReview>,
155177
pods_api: Api<Pod>,
@@ -160,6 +182,7 @@ pub struct LiveK8sResolver {
160182
expected_service_account: String,
161183
}
162184

185+
#[cfg(not(target_os = "windows"))]
163186
impl LiveK8sResolver {
164187
pub fn new(
165188
client: kube::Client,
@@ -217,6 +240,7 @@ impl LiveK8sResolver {
217240
}
218241

219242
#[async_trait]
243+
#[cfg(not(target_os = "windows"))]
220244
impl K8sIdentityResolver for LiveK8sResolver {
221245
async fn resolve(&self, token: &str) -> Result<Option<ResolvedK8sIdentity>, Status> {
222246
let review = TokenReview {
@@ -324,6 +348,7 @@ impl K8sIdentityResolver for LiveK8sResolver {
324348
}
325349

326350
#[allow(clippy::result_large_err)]
351+
#[cfg(any(not(target_os = "windows"), test))]
327352
fn token_review_identity(
328353
status: &TokenReviewStatus,
329354
expected_audience: &str,
@@ -376,6 +401,7 @@ fn token_review_identity(
376401
}
377402

378403
#[allow(clippy::result_large_err)]
404+
#[cfg(any(not(target_os = "windows"), test))]
379405
fn user_extra_one(user: &UserInfo, key: &str) -> Result<String, Status> {
380406
let Some(values) = user.extra.as_ref().and_then(|extra| extra.get(key)) else {
381407
return Err(Status::permission_denied("SA token is not pod-bound"));
@@ -389,6 +415,7 @@ fn user_extra_one(user: &UserInfo, key: &str) -> Result<String, Status> {
389415
}
390416

391417
#[allow(clippy::result_large_err)]
418+
#[cfg(any(not(target_os = "windows"), test))]
392419
fn pod_sandbox_id(pod: &Pod) -> Result<String, Status> {
393420
let sandbox_id = pod
394421
.metadata
@@ -406,6 +433,7 @@ fn pod_sandbox_id(pod: &Pod) -> Result<String, Status> {
406433
}
407434

408435
#[allow(clippy::result_large_err)]
436+
#[cfg(any(not(target_os = "windows"), test))]
409437
fn sandbox_owner_reference(pod: &Pod) -> Result<SandboxOwnerReference, Status> {
410438
let owner_refs = pod.metadata.owner_references.as_deref().unwrap_or_default();
411439
let mut sandbox_refs = owner_refs
@@ -453,6 +481,7 @@ fn sandbox_owner_reference(pod: &Pod) -> Result<SandboxOwnerReference, Status> {
453481
})
454482
}
455483

484+
#[cfg(any(not(target_os = "windows"), test))]
456485
fn is_supported_sandbox_owner_reference(
457486
owner: &k8s_openapi::apimachinery::pkg::apis::meta::v1::OwnerReference,
458487
) -> bool {
@@ -463,6 +492,7 @@ fn is_supported_sandbox_owner_reference(
463492
)
464493
}
465494

495+
#[cfg(any(not(target_os = "windows"), test))]
466496
fn should_try_next_sandbox_api_version(err: &KubeError) -> bool {
467497
// Kubernetes returns a structured 404 for some missing API resources and a
468498
// raw "404 page not found" body for others. Both mean the probed
@@ -472,6 +502,7 @@ fn should_try_next_sandbox_api_version(err: &KubeError) -> bool {
472502
}
473503

474504
#[allow(clippy::result_large_err)]
505+
#[cfg(any(not(target_os = "windows"), test))]
475506
fn validate_sandbox_owner_reference(
476507
owner: &SandboxOwnerReference,
477508
sandbox_id: &str,

‎crates/openshell-server/src/compute/driver_config.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ impl From<&LocalTlsPaths> for GuestTlsPaths {
3737
#[derive(Clone, Copy)]
3838
pub struct DriverStartupContext<'a> {
3939
pub file: Option<&'a config_file::ConfigFile>,
40+
#[cfg(not(target_os = "windows"))]
4041
pub guest_tls: Option<&'a GuestTlsPaths>,
42+
#[cfg(not(target_os = "windows"))]
4143
pub gateway_port: u16,
44+
#[cfg(not(target_os = "windows"))]
4245
pub gateway_tls_enabled: bool,
4346
pub endpoint_overrides: &'a BTreeMap<String, PathBuf>,
4447
}
@@ -125,8 +128,11 @@ mod tests {
125128
) -> DriverStartupContext<'a> {
126129
DriverStartupContext {
127130
file,
131+
#[cfg(not(target_os = "windows"))]
128132
guest_tls: None,
133+
#[cfg(not(target_os = "windows"))]
129134
gateway_port: openshell_core::config::DEFAULT_SERVER_PORT,
135+
#[cfg(not(target_os = "windows"))]
130136
gateway_tls_enabled: false,
131137
endpoint_overrides,
132138
}

‎crates/openshell-server/src/compute/mod.rs‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ pub struct AcquiredRemoteDriverEndpoint {
429429
}
430430

431431
impl AcquiredRemoteDriverEndpoint {
432+
#[cfg(unix)]
432433
pub(crate) fn managed_builtin(
433434
driver_kind: ComputeDriverKind,
434435
channel: Channel,
@@ -441,6 +442,7 @@ impl AcquiredRemoteDriverEndpoint {
441442
}
442443
}
443444

445+
#[cfg(unix)]
444446
pub(crate) fn unmanaged(name: impl Into<String>, channel: Channel) -> Self {
445447
Self {
446448
name: name.into(),
@@ -574,6 +576,7 @@ pub struct ComputeRuntime {
574576
driver_info: ComputeDriverInfoSnapshot,
575577
shutdown_cleanup: Option<Arc<dyn ShutdownCleanup>>,
576578
startup_starter: Option<Arc<dyn StartupSandboxStarter>>,
579+
#[cfg(unix)]
577580
driver_process: Option<Arc<ManagedDriverProcess>>,
578581
default_image: String,
579582
store: Arc<Store>,
@@ -616,6 +619,8 @@ impl ComputeRuntime {
616619
tracing_log_bus: TracingLogBus,
617620
supervisor_sessions: Arc<SupervisorSessionRegistry>,
618621
) -> Result<Self, ComputeError> {
622+
#[cfg(not(unix))]
623+
let _ = driver_process;
619624
let capabilities = driver
620625
.get_capabilities(Request::new(GetCapabilitiesRequest {}))
621626
.await
@@ -695,6 +700,7 @@ impl ComputeRuntime {
695700
driver_info,
696701
shutdown_cleanup,
697702
startup_starter,
703+
#[cfg(unix)]
698704
driver_process,
699705
default_image,
700706
store,
@@ -3107,13 +3113,13 @@ pub async fn connect_remote_compute_driver(
31073113
}
31083114

31093115
#[cfg(not(unix))]
3110-
pub async fn connect_remote_compute_driver(
3116+
pub fn connect_remote_compute_driver(
31113117
_name: impl Into<String>,
31123118
_socket_path: &Path,
3113-
) -> Result<AcquiredRemoteDriverEndpoint, ComputeError> {
3114-
Err(ComputeError::Message(
3119+
) -> std::future::Ready<Result<AcquiredRemoteDriverEndpoint, ComputeError>> {
3120+
std::future::ready(Err(ComputeError::Message(
31153121
"remote compute driver endpoints require unix domain socket support".to_string(),
3116-
))
3122+
)))
31173123
}
31183124

31193125
fn driver_sandbox_from_public(
@@ -3896,6 +3902,7 @@ pub async fn new_test_runtime_for_driver(store: Arc<Store>, driver_name: &str) -
38963902
},
38973903
shutdown_cleanup: None,
38983904
startup_starter: None,
3905+
#[cfg(unix)]
38993906
driver_process: None,
39003907
default_image: "openshell/sandbox:test".to_string(),
39013908
store,
@@ -4501,6 +4508,7 @@ mod tests {
45014508
},
45024509
shutdown_cleanup: None,
45034510
startup_starter,
4511+
#[cfg(unix)]
45044512
driver_process: None,
45054513
default_image: "openshell/sandbox:test".to_string(),
45064514
store,

‎crates/openshell-server/src/credentials.rs‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ use async_trait::async_trait;
2626
#[cfg(unix)]
2727
use hyper_util::rt::TokioIo;
2828
use openshell_core::proto::credentials::v1::{
29-
DeleteCredentialRequest, GetCredentialDriverCapabilitiesRequest,
30-
GetCredentialDriverCapabilitiesResponse, ResolveCredentialRequest, ResolveCredentialsRequest,
31-
ResolvedCredential, StoreCredentialRequest, credential_driver_client::CredentialDriverClient,
29+
DeleteCredentialRequest, ResolveCredentialRequest, ResolvedCredential, StoreCredentialRequest,
30+
};
31+
#[cfg(unix)]
32+
use openshell_core::proto::credentials::v1::{
33+
GetCredentialDriverCapabilitiesRequest, GetCredentialDriverCapabilitiesResponse,
34+
ResolveCredentialsRequest, credential_driver_client::CredentialDriverClient,
3235
};
3336
use openshell_core::proto::{CredentialHandle, Provider};
3437
use openshell_core::{Config, Error, Result as CoreResult};
@@ -43,15 +46,18 @@ use tokio::net::UnixStream;
4346
#[cfg(unix)]
4447
use tokio::process::Command;
4548
#[cfg(unix)]
49+
use tonic::Request;
50+
use tonic::Status;
51+
#[cfg(unix)]
4652
use tonic::transport::{Channel, Endpoint};
47-
use tonic::{Request, Status};
4853
#[cfg(unix)]
4954
use tower::service_fn;
5055
use tracing::warn;
5156

5257
use crate::persistence::{PersistenceError, Store, WriteCondition};
5358

5459
const DEFAULT_CREDENTIAL_DRIVER_STARTUP_TIMEOUT_SECS: u64 = 10;
60+
#[cfg(unix)]
5561
const DEFAULT_CREDENTIAL_DRIVER_RPC_TIMEOUT_SECS: u64 = 30;
5662
const COMMON_CREDENTIAL_DRIVER_FIELDS: &[&str] = &[
5763
"transport",
@@ -1253,14 +1259,14 @@ async fn connect_uds_driver(
12531259
}
12541260

12551261
#[cfg(not(unix))]
1256-
async fn connect_uds_driver(
1262+
fn connect_uds_driver(
12571263
driver_name: &str,
12581264
_config: ConfiguredCredentialDriver,
12591265
_socket_path: &Path,
1260-
) -> CoreResult<BuiltCredentialDriver> {
1261-
Err(Error::config(format!(
1266+
) -> std::future::Ready<CoreResult<BuiltCredentialDriver>> {
1267+
std::future::ready(Err(Error::config(format!(
12621268
"credential driver '{driver_name}' uses transport = 'uds', but this platform does not support Unix domain sockets"
1263-
)))
1269+
))))
12641270
}
12651271

12661272
#[cfg(unix)]

‎crates/openshell-server/src/lib.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,11 @@ pub(crate) async fn run_server(
344344
let supervisor_sessions = Arc::new(supervisor_session::SupervisorSessionRegistry::new());
345345
let driver_startup = compute::driver_config::DriverStartupContext {
346346
file: config_file.as_ref(),
347+
#[cfg(not(target_os = "windows"))]
347348
guest_tls: guest_tls.as_ref(),
349+
#[cfg(not(target_os = "windows"))]
348350
gateway_port: config.bind_address.port(),
351+
#[cfg(not(target_os = "windows"))]
349352
gateway_tls_enabled: config.tls.is_some(),
350353
endpoint_overrides: &config.compute_driver_endpoints,
351354
};
@@ -1016,13 +1019,15 @@ fn builtin_compute_driver(name: &str) -> Option<ComputeDriverKind> {
10161019
name.parse().ok()
10171020
}
10181021

1022+
#[cfg(not(target_os = "windows"))]
10191023
fn kubernetes_sandbox_jwt_expiry_disabled(config: &Config) -> bool {
10201024
config
10211025
.gateway_jwt
10221026
.as_ref()
10231027
.is_some_and(|jwt| jwt.ttl_secs == 0)
10241028
}
10251029

1030+
#[cfg(not(target_os = "windows"))]
10261031
fn warn_if_kubernetes_sandbox_jwt_expiry_disabled(config: &Config) {
10271032
if kubernetes_sandbox_jwt_expiry_disabled(config) {
10281033
warn!(
@@ -1127,8 +1132,11 @@ mod tests {
11271132
) -> crate::compute::driver_config::DriverStartupContext<'a> {
11281133
crate::compute::driver_config::DriverStartupContext {
11291134
file,
1135+
#[cfg(not(target_os = "windows"))]
11301136
guest_tls: None,
1137+
#[cfg(not(target_os = "windows"))]
11311138
gateway_port: openshell_core::config::DEFAULT_SERVER_PORT,
1139+
#[cfg(not(target_os = "windows"))]
11321140
gateway_tls_enabled: false,
11331141
endpoint_overrides: &config.compute_driver_endpoints,
11341142
}

0 commit comments

Comments
 (0)