Skip to content

Commit

Permalink
Remove API unused field: ResourceInstanceSpecification::output_mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ccicconetti committed Dec 17, 2024
1 parent 4aae892 commit 12fd0d6
Show file tree
Hide file tree
Showing 12 changed files with 2 additions and 69 deletions.
2 changes: 0 additions & 2 deletions edgeless_api/proto/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,6 @@ message ResourceInstanceSpecification {
string resource_class_type = 1;
// Resource configuration (depends on the type).
map<string, string> configuration = 2;
// Mapping of the outputs to concrete function/resource instances.
map<string, InstanceId> output_mapping = 3;
}

// Message containing information provided as response to failed request.
Expand Down
6 changes: 0 additions & 6 deletions edgeless_api/src/coap_impl/resource_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ impl crate::resource_configuration::ResourceConfigurationAPI<edgeless_api_core::
&mut self,
instance_specification: crate::resource_configuration::ResourceInstanceSpecification,
) -> anyhow::Result<crate::common::StartComponentResponse<edgeless_api_core::instance_id::InstanceId>> {
let mut outputs = heapless::Vec::<(&str, edgeless_api_core::instance_id::InstanceId), 16>::new();
let mut configuration = heapless::Vec::<(&str, &str), 16>::new();
for (key, val) in &instance_specification.output_mapping {
outputs.push((key, *val)).map_err(|_| anyhow::anyhow!("Too many outputs"))?;
}

for (key, val) in &instance_specification.configuration {
configuration
.push((key, val))
Expand All @@ -22,7 +17,6 @@ impl crate::resource_configuration::ResourceConfigurationAPI<edgeless_api_core::

let encoded_resource_spec = edgeless_api_core::resource_configuration::EncodedResourceInstanceSpecification {
class_type: &instance_specification.class_type,
output_mapping: outputs,
configuration,
};

Expand Down
16 changes: 0 additions & 16 deletions edgeless_api/src/grpc_impl/resource_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ impl ResourceConfigurationConverters {
Ok(crate::resource_configuration::ResourceInstanceSpecification {
class_type: api_spec.resource_class_type.clone(),
configuration: api_spec.configuration.clone(),
output_mapping: api_spec
.output_mapping
.iter()
.flat_map(|(name, id)| {
let id = CommonConverters::parse_instance_id(id);
match id {
Ok(val) => Some((name.to_string(), val)),
Err(_) => None,
}
})
.collect(),
})
}

Expand All @@ -33,11 +22,6 @@ impl ResourceConfigurationConverters {
crate::grpc_impl::api::ResourceInstanceSpecification {
resource_class_type: crate_spec.class_type.clone(),
configuration: crate_spec.configuration.clone(),
output_mapping: crate_spec
.output_mapping
.iter()
.map(|(name, id)| (name.to_string(), CommonConverters::serialize_instance_id(id)))
.collect(),
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions edgeless_api/src/resource_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use crate::common::PatchRequest;
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
pub struct ResourceInstanceSpecification {
pub class_type: String,
#[serde(skip)]
pub output_mapping: std::collections::HashMap<String, crate::function_instance::InstanceId>, // XXX
pub configuration: std::collections::HashMap<String, String>,
}

Expand Down
17 changes: 0 additions & 17 deletions edgeless_api_core/src/resource_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#[derive(Clone, PartialEq, Eq)]
pub struct EncodedResourceInstanceSpecification<'a> {
pub class_type: &'a str,
pub output_mapping: heapless::Vec<(&'a str, crate::instance_id::InstanceId), 16>,
pub configuration: heapless::Vec<(&'a str, &'a str), 16>,
}

Expand All @@ -18,13 +17,6 @@ pub struct EncodedPatchRequest<'a> {
impl<C> minicbor::Encode<C> for EncodedResourceInstanceSpecification<'_> {
fn encode<W: minicbor::encode::Write>(&self, e: &mut minicbor::Encoder<W>, _ctx: &mut C) -> Result<(), minicbor::encode::Error<W::Error>> {
let mut e = e.str(self.class_type)?;
{
e = e.array(self.output_mapping.len() as u64)?;
for data in &self.output_mapping {
e = e.encode(data)?;
}
}

{
e = e.array(self.configuration.len() as u64)?;
for data in &self.configuration {
Expand All @@ -38,20 +30,14 @@ impl<C> minicbor::Encode<C> for EncodedResourceInstanceSpecification<'_> {
impl<'b, C> minicbor::Decode<'b, C> for EncodedResourceInstanceSpecification<'b> {
fn decode(d: &mut minicbor::Decoder<'b>, _ctx: &mut C) -> Result<Self, minicbor::decode::Error> {
let id = d.str()?;
let mut outputs = heapless::Vec::<(&'b str, crate::instance_id::InstanceId), 16>::new();
let mut configuration = heapless::Vec::<(&'b str, &'b str), 16>::new();

for item in d.array_iter::<(&str, crate::instance_id::InstanceId)>().unwrap().flatten() {
let _ = outputs.push(item);
}

for item in d.array_iter::<(&str, &str)>().unwrap().flatten() {
let _ = configuration.push(item);
}

Ok(EncodedResourceInstanceSpecification {
class_type: id,
output_mapping: outputs,
configuration,
})
}
Expand All @@ -61,8 +47,6 @@ impl<C> minicbor::CborLen<C> for EncodedResourceInstanceSpecification<'_> {
fn cbor_len(&self, ctx: &mut C) -> usize {
let mut len: usize = self.class_type.cbor_len(ctx);

len += self.output_mapping[..self.output_mapping.len()].cbor_len(ctx);

len += self.configuration[..self.configuration.len()].cbor_len(ctx);

len
Expand Down Expand Up @@ -136,7 +120,6 @@ mod test {

let id = super::EncodedResourceInstanceSpecification {
class_type: "class-1",
output_mapping: outputs,
configuration,
};

Expand Down
1 change: 0 additions & 1 deletion edgeless_con/src/controller/controller_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@ impl ControllerTask {
.start(edgeless_api::resource_configuration::ResourceInstanceSpecification {
class_type: resource.class_type.clone(),
configuration: resource.configurations.clone(),
output_mapping: std::collections::HashMap::new(),
})
.await;

Expand Down
9 changes: 1 addition & 8 deletions edgeless_embedded/src/resource/mock_sensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl MockSensor {
async fn parse_configuration<'a>(
data: edgeless_api_core::resource_configuration::EncodedResourceInstanceSpecification<'a>,
) -> Result<MockSensorConfiguration, edgeless_api_core::common::ErrorResponse> {
let mut out_id: Option<edgeless_api_core::instance_id::InstanceId> = None;
let out_id: Option<edgeless_api_core::instance_id::InstanceId> = None;

if data.class_type != "scd30-sensor" {
return Err(edgeless_api_core::common::ErrorResponse {
Expand All @@ -31,13 +31,6 @@ impl MockSensor {
});
}

for (key, val) in data.output_mapping {
if key == "data_out" {
out_id = Some(val);
break;
}
}

// let out_id = match out_id {
// Some(val) => val,
// None => {
Expand Down
10 changes: 1 addition & 9 deletions edgeless_embedded/src/resource/scd30_sensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,14 @@ impl SCD30Sensor {
async fn parse_configuration<'a>(
data: edgeless_api_core::resource_configuration::EncodedResourceInstanceSpecification<'a>,
) -> Result<SCD30SensorConfiguration, edgeless_api_core::common::ErrorResponse> {
let mut out_id: Option<edgeless_api_core::instance_id::InstanceId> = None;
let out_id: Option<edgeless_api_core::instance_id::InstanceId> = None;

if data.class_type != "scd30-sensor" {
return Err(edgeless_api_core::common::ErrorResponse {
summary: "Wrong Resource ProviderId",
detail: None,
});
}

for (key, val) in data.output_mapping {
if key == "data_out" {
out_id = Some(val);
break;
}
}

Ok(SCD30SensorConfiguration { data_out_id: out_id })
}

Expand Down
4 changes: 0 additions & 4 deletions edgeless_node/src/resources/dda/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ impl ResourceConfigurationAPI<edgeless_api::function_instance::InstanceId> for D
let new_id = edgeless_api::function_instance::InstanceId::new(lck.resource_provider_id.node_id);
let dataplane_handle = lck.dataplane_provider.get_handle_for(new_id).await;

// insert the initial output_mapping before the Instance is created
// to avoid data race
lck.mappings.insert(new_id.function_id, instance_specification.output_mapping);

// create the resource
let dda_res = match DDAResource::new(
self.clone(),
Expand Down
1 change: 0 additions & 1 deletion edgeless_orc/src/orchestrator/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ fn make_spawn_function_request(class_id: &str) -> edgeless_api::function_instanc
fn make_start_resource_request(class_type: &str) -> edgeless_api::resource_configuration::ResourceInstanceSpecification {
edgeless_api::resource_configuration::ResourceInstanceSpecification {
class_type: class_type.to_string(),
output_mapping: std::collections::HashMap::new(),
configuration: std::collections::HashMap::new(),
}
}
Expand Down
2 changes: 0 additions & 2 deletions edgeless_orc/src/orchestrator_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,6 @@ impl OrchestratorTask {
.resource_configuration_api()
.start(edgeless_api::resource_configuration::ResourceInstanceSpecification {
class_type: resource_provider.class_type.clone(),
// [TODO] Issue #94 remove output mapping
output_mapping: std::collections::HashMap::new(),
configuration: start_req.configuration.clone(),
})
.await
Expand Down
1 change: 0 additions & 1 deletion edgeless_orc/src/proxy_redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,6 @@ mod test {
crate::active_instance::ActiveInstance::Resource(
edgeless_api::resource_configuration::ResourceInstanceSpecification {
class_type: "res".to_string(),
output_mapping: std::collections::HashMap::new(),
configuration: std::collections::HashMap::from([
("key1".to_string(), "val1".to_string()),
("key2".to_string(), "val2".to_string()),
Expand Down

0 comments on commit 12fd0d6

Please sign in to comment.