Skip to content

Commit dc36e06

Browse files
committed
fix(providers): preserve legacy environment with managed files
Signed-off-by: Drew Newberry <[email protected]>
1 parent b195e7a commit dc36e06

5 files changed

Lines changed: 91 additions & 44 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,6 @@ pub async fn fetch_provider_environment(
10931093
.get_sandbox_provider_environment(GetSandboxProviderEnvironmentRequest {
10941094
sandbox_id: sandbox_id.to_string(),
10951095
supports_static_credential_bindings: true,
1096-
supports_provider_files: true,
10971096
})
10981097
.await
10991098
.map_err(grpc_status_error)?;

‎crates/openshell-server/src/grpc/policy.rs‎

Lines changed: 83 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3337,7 +3337,6 @@ pub(super) async fn handle_get_sandbox_provider_environment(
33373337
) -> Result<Response<GetSandboxProviderEnvironmentResponse>, Status> {
33383338
let sandbox_id = request.get_ref().sandbox_id.clone();
33393339
let supports_static_credential_bindings = request.get_ref().supports_static_credential_bindings;
3340-
let supports_provider_files = request.get_ref().supports_provider_files;
33413340
crate::auth::guard::enforce_sandbox_scope(&request, &sandbox_id)?;
33423341
drop(request);
33433342

@@ -3350,11 +3349,6 @@ pub(super) async fn handle_get_sandbox_provider_environment(
33503349
let environment =
33513350
load_sandbox_provider_environment(state, &sandbox, supports_static_credential_bindings)
33523351
.await?;
3353-
if !supports_provider_files && !environment.files.is_empty() {
3354-
return Err(Status::failed_precondition(
3355-
"supervisor does not support provider files",
3356-
));
3357-
}
33583352
Ok(Response::new(environment))
33593353
}
33603354

@@ -11193,7 +11187,6 @@ mod tests {
1119311187
let environment = handle_get_sandbox_provider_environment(
1119411188
&state,
1119511189
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
11196-
supports_provider_files: false,
1119711190
sandbox_id: "sb-snapshot-consistency".to_string(),
1119811191
supports_static_credential_bindings: true,
1119911192
})),
@@ -12802,7 +12795,6 @@ mod tests {
1280212795
let legacy_env = handle_get_sandbox_provider_environment(
1280312796
&state,
1280412797
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
12805-
supports_provider_files: false,
1280612798
sandbox_id: "sb-provider-env".to_string(),
1280712799
supports_static_credential_bindings: true,
1280812800
})),
@@ -12815,7 +12807,6 @@ mod tests {
1281512807
let v2_env = handle_get_sandbox_provider_environment(
1281612808
&state,
1281712809
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
12818-
supports_provider_files: false,
1281912810
sandbox_id: "sb-provider-env".to_string(),
1282012811
supports_static_credential_bindings: true,
1282112812
})),
@@ -12829,6 +12820,89 @@ mod tests {
1282912820
assert_eq!(v2_env.get("GITHUB_TOKEN"), Some(&"ghp-test".to_string()));
1283012821
}
1283112822

12823+
#[tokio::test]
12824+
async fn provider_files_do_not_block_legacy_provider_environment_requests() {
12825+
use openshell_core::proto::{
12826+
GetSandboxProviderEnvironmentRequest, ProviderProfile, ProviderProfileCategory,
12827+
ProviderProfileFile,
12828+
};
12829+
12830+
let state = test_server_state().await;
12831+
state
12832+
.store
12833+
.put_message(&StoredProviderProfile {
12834+
metadata: Some(openshell_core::proto::datamodel::v1::ObjectMeta {
12835+
id: "profile-config-only".to_string(),
12836+
name: "config-only".to_string(),
12837+
workspace: "default".to_string(),
12838+
..Default::default()
12839+
}),
12840+
profile: Some(ProviderProfile {
12841+
id: "config-only".to_string(),
12842+
display_name: "Config only".to_string(),
12843+
category: ProviderProfileCategory::Other as i32,
12844+
files: vec![ProviderProfileFile {
12845+
path: "client.toml".to_string(),
12846+
content: "endpoint = '{{config.endpoint}}'".to_string(),
12847+
env_var: "CLIENT_CONFIG_FILE".to_string(),
12848+
}],
12849+
..Default::default()
12850+
}),
12851+
})
12852+
.await
12853+
.unwrap();
12854+
12855+
let mut file_provider = test_provider("work-config", "config-only");
12856+
file_provider.credentials.clear();
12857+
file_provider
12858+
.config
12859+
.insert("endpoint".to_string(), "https://config.example".to_string());
12860+
state.store.put_message(&file_provider).await.unwrap();
12861+
state
12862+
.store
12863+
.put_message(&test_provider("work-github", "github"))
12864+
.await
12865+
.unwrap();
12866+
state
12867+
.store
12868+
.put_message(&test_sandbox(
12869+
"sb-files-and-credentials",
12870+
"files-and-credentials",
12871+
test_policy_with_rule("sandbox_only", "sandbox.example.com"),
12872+
vec!["work-config".to_string(), "work-github".to_string()],
12873+
))
12874+
.await
12875+
.unwrap();
12876+
12877+
// An older supervisor sends this request without a provider-file
12878+
// capability field and ignores the additive files response field.
12879+
let response = handle_get_sandbox_provider_environment(
12880+
&state,
12881+
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
12882+
sandbox_id: "sb-files-and-credentials".to_string(),
12883+
supports_static_credential_bindings: true,
12884+
})),
12885+
)
12886+
.await
12887+
.unwrap()
12888+
.into_inner();
12889+
12890+
assert_eq!(
12891+
response.environment.get("GITHUB_TOKEN"),
12892+
Some(&"ghp-test".to_string())
12893+
);
12894+
assert_eq!(
12895+
response.environment.get("CLIENT_CONFIG_FILE"),
12896+
Some(&"/run/openshell/providers/work-config/client.toml".to_string())
12897+
);
12898+
assert_eq!(
12899+
response
12900+
.files
12901+
.get("/run/openshell/providers/work-config/client.toml"),
12902+
Some(&"endpoint = 'https://config.example'".to_string())
12903+
);
12904+
}
12905+
1283212906
#[tokio::test]
1283312907
async fn provider_readiness_snapshot_uses_baseline_static_binding_contract() {
1283412908
let state = test_server_state().await;
@@ -12852,7 +12926,6 @@ mod tests {
1285212926
let response = handle_get_sandbox_provider_environment(
1285312927
&state,
1285412928
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
12855-
supports_provider_files: false,
1285612929
sandbox_id: "sb-static-ready".to_string(),
1285712930
supports_static_credential_bindings: true,
1285812931
})),
@@ -12911,7 +12984,6 @@ mod tests {
1291112984
let response = handle_get_sandbox_provider_environment(
1291212985
&state,
1291312986
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
12914-
supports_provider_files: false,
1291512987
sandbox_id: "sb-legacy-provider-env".to_string(),
1291612988
supports_static_credential_bindings: false,
1291712989
})),
@@ -12956,7 +13028,6 @@ mod tests {
1295613028
let response = handle_get_sandbox_provider_environment(
1295713029
&state,
1295813030
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
12959-
supports_provider_files: false,
1296013031
sandbox_id: "sb-unbound-provider-env".to_string(),
1296113032
supports_static_credential_bindings: true,
1296213033
})),
@@ -13067,7 +13138,6 @@ mod tests {
1306713138
let environment = handle_get_sandbox_provider_environment(
1306813139
&state,
1306913140
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
13070-
supports_provider_files: false,
1307113141
sandbox_id: "sb-policy-binding".to_string(),
1307213142
supports_static_credential_bindings: true,
1307313143
})),
@@ -13133,7 +13203,6 @@ mod tests {
1313313203
let next_environment = handle_get_sandbox_provider_environment(
1313413204
&state,
1313513205
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
13136-
supports_provider_files: false,
1313713206
sandbox_id: "sb-policy-binding".to_string(),
1313813207
supports_static_credential_bindings: true,
1313913208
})),
@@ -13194,7 +13263,6 @@ mod tests {
1319413263
let unbound_environment = handle_get_sandbox_provider_environment(
1319513264
&state,
1319613265
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
13197-
supports_provider_files: false,
1319813266
sandbox_id: "sb-policy-binding".to_string(),
1319913267
supports_static_credential_bindings: true,
1320013268
})),
@@ -13291,7 +13359,6 @@ mod tests {
1329113359
let response = handle_get_sandbox_provider_environment(
1329213360
&state,
1329313361
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
13294-
supports_provider_files: false,
1329513362
sandbox_id: "sb-mixed-provider-env".to_string(),
1329613363
supports_static_credential_bindings: true,
1329713364
})),
@@ -13400,7 +13467,6 @@ mod tests {
1340013467
let response = handle_get_sandbox_provider_environment(
1340113468
&state,
1340213469
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
13403-
supports_provider_files: false,
1340413470
sandbox_id: "sb-token-exchange-subject".to_string(),
1340513471
supports_static_credential_bindings: true,
1340613472
})),
@@ -13468,7 +13534,6 @@ mod tests {
1346813534
let first = handle_get_sandbox_provider_environment(
1346913535
&state,
1347013536
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
13471-
supports_provider_files: false,
1347213537
sandbox_id: "sb-provider-revision".to_string(),
1347313538
supports_static_credential_bindings: true,
1347413539
})),
@@ -13508,7 +13573,6 @@ mod tests {
1350813573
let second = handle_get_sandbox_provider_environment(
1350913574
&state,
1351013575
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
13511-
supports_provider_files: false,
1351213576
sandbox_id: "sb-provider-revision".to_string(),
1351313577
supports_static_credential_bindings: true,
1351413578
})),
@@ -13958,7 +14022,6 @@ mod tests {
1395814022
let baseline_env = handle_get_sandbox_provider_environment(
1395914023
&state,
1396014024
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
13961-
supports_provider_files: false,
1396214025
sandbox_id: "sb-attach-lifecycle".to_string(),
1396314026
supports_static_credential_bindings: true,
1396414027
})),
@@ -13992,7 +14055,6 @@ mod tests {
1399214055
let attached_env = handle_get_sandbox_provider_environment(
1399314056
&state,
1399414057
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
13995-
supports_provider_files: false,
1399614058
sandbox_id: "sb-attach-lifecycle".to_string(),
1399714059
supports_static_credential_bindings: true,
1399814060
})),
@@ -14034,7 +14096,6 @@ mod tests {
1403414096
let detached_env = handle_get_sandbox_provider_environment(
1403514097
&state,
1403614098
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
14037-
supports_provider_files: false,
1403814099
sandbox_id: "sb-attach-lifecycle".to_string(),
1403914100
supports_static_credential_bindings: true,
1404014101
})),
@@ -14139,7 +14200,6 @@ mod tests {
1413914200
let baseline_env = handle_get_sandbox_provider_environment(
1414014201
&state,
1414114202
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
14142-
supports_provider_files: false,
1414314203
sandbox_id: "sb-attach-lifecycle".to_string(),
1414414204
supports_static_credential_bindings: true,
1414514205
})),
@@ -14176,7 +14236,6 @@ mod tests {
1417614236
let attached_env = handle_get_sandbox_provider_environment(
1417714237
&state,
1417814238
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
14179-
supports_provider_files: false,
1418014239
sandbox_id: "sb-attach-lifecycle".to_string(),
1418114240
supports_static_credential_bindings: true,
1418214241
})),
@@ -14217,7 +14276,6 @@ mod tests {
1421714276
let detached_env = handle_get_sandbox_provider_environment(
1421814277
&state,
1421914278
with_user(Request::new(GetSandboxProviderEnvironmentRequest {
14220-
supports_provider_files: false,
1422114279
sandbox_id: "sb-attach-lifecycle".to_string(),
1422214280
supports_static_credential_bindings: true,
1422314281
})),

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ mod tests {
123123
// Unspecified (treated as Never), zero count, and absent timestamps.
124124
// ProviderProfileFile is reachable from stored provider profiles. Its
125125
// additive declaration changes the durable and public/durable overlap
126-
// inventories; the provider-environment file map is public-only.
126+
// inventories; the provider-environment file map is public-only. The
127+
// request has no provider-file capability field: older supervisors ignore
128+
// the additive file map while retaining the rest of the response.
127129
const PUBLIC_RPC_SCHEMA_SHA256: &str =
128-
"7e1d78dc48d47f1d348c4f61120c582211519c1d37190ac67d5c4f4f6c717d69";
130+
"2ed66dbc38c60eb96c7461c76d02813c177facfad93753b180534477270ad240";
129131
const DURABLE_SCHEMA_SHA256: &str =
130132
"399737f2a367d2e3a9d78cf84e2a97eef041835554599790788e4bbf318116c3";
131133
const PUBLIC_DURABLE_OVERLAP_SHA256: &str =

‎proto/openshell.proto‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,8 +2594,6 @@ message GetSandboxProviderEnvironmentRequest {
25942594
// provider credentials. Gateways withhold static credential material when
25952595
// this capability is absent.
25962596
bool supports_static_credential_bindings = 2;
2597-
// Whether this supervisor supports provider-managed workload files.
2598-
bool supports_provider_files = 3;
25992597
}
26002598

26012599
// One network endpoint at which a static provider credential may be resolved.

‎sdk/go/proto/openshellv1/openshell.pb.go‎

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)