Skip to content

Commit 997ef1c

Browse files
committed
sgx-faasm: bump faasm version and refine deployment strategy
1 parent 4cacb1a commit 997ef1c

File tree

9 files changed

+66
-52
lines changed

9 files changed

+66
-52
lines changed

ansible/tasks/sgx-faasm/apt.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
- name: "Add Intel SGX repository"
99
apt_repository:
10-
repo: "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-sgx-archive-keyring.gpg] https://download.01.org/intel-sgx/sgx_repo/ubuntu jammy main"
10+
repo: "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-sgx-archive-keyring.gpg] https://download.01.org/intel-sgx/sgx_repo/ubuntu noble main"
1111
filename: intel-sgx
1212
state: present
1313
become: yes
@@ -17,7 +17,7 @@
1717
update_cache: yes
1818
become: yes
1919

20-
- name: "Install APT depdencencies"
20+
- name: "Install APT dependencies"
2121
become: yes
2222
apt:
2323
name:

ansible/tasks/sgx-faasm/sgx_setup.yaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,3 @@
55

66
- name: "Set WASM VM env. variable to SGX"
77
shell: "echo 'export PATH=$PATH:/home/{{ ansible_user }}/.local/bin' >> /home/{{ ansible_user }}/.bashrc"
8-
9-
- name: "Update apt cache"
10-
become: yes
11-
apt:
12-
update_cache: yes
13-
14-
- name: "Install linux recommends"
15-
become: yes
16-
shell: "apt install --install-recommends -y linux-generic"
17-
18-
- name: "Upgrade to 6.x kernel for EDMM features"
19-
become: yes
20-
apt:
21-
name: linux-image-6.5.0-1025-azure
22-
environment:
23-
DEBIAN_FRONTEND: noninteractive
24-
25-
- name: "Reboot to pick-up latest kernel"
26-
reboot:
27-
become: yes

ansible/tasks/sgxfaasm.yaml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
---
22

3+
- name: "Fetch all container images"
4+
shell:
5+
cmd: |
6+
docker pull ghcr.io/faasm/accless-experiments:{{ accless_version}}
7+
docker pull ghcr.io/faasm/upload:{{ faasm_version }}
8+
docker pull ghcr.io/faasm/worker:{{ faasm_version }}
9+
docker pull ghcr.io/faasm/worker-sgx:{{ faasm_version }}
10+
docker pull ghcr.io/faasm/cli:{{ faasm_version }}
11+
docker pull ghcr.io/faasm/cli-sgx:{{ faasm_version }}
12+
args:
13+
executable: /bin/bash
14+
315
- name: "Deploy Faasm cluster"
416
shell: rm -rf ./venv-bm && source ./bin/workon.sh && faasmctl deploy.compose --mount-source . --workers=4
517
args:
@@ -12,18 +24,12 @@
1224
# FAASM_ATTESTATION_SERVICE_URL: "{{ as_ip }}"
1325
FAASM_WASM_VM: sgx
1426

15-
# Build all the targets for the SGX baselines (SGX-Faasm and Accless-Faasm)
27+
# Build all the targets for the SGX and non-SGX baselines
1628
- name: "Deploy Faasm cluster"
17-
shell: source ./bin/workon.sh && faasmctl cli.faasm --cmd "./bin/inv_wrapper.sh dev.tools --build Release --sgx Hardware"
18-
args:
19-
chdir: "/home/{{ ansible_user }}/git/faasm/faasm"
20-
executable: /bin/bash
21-
environment:
22-
FAASM_WASM_VM: sgx
23-
24-
# Build all the targets for the non-SGX baseline (Faasm)
25-
- name: "Deploy Faasm cluster"
26-
shell: source ./bin/workon.sh && faasmctl cli.faasm --cmd "./bin/inv_wrapper.sh dev.tools --build Release --sgx Disabled"
29+
shell:
30+
cmd: |
31+
source ./bin/workon.sh && faasmctl cli.faasm --cmd "./bin/inv_wrapper.sh dev.tools --build Release --sgx Hardware"
32+
source ./bin/workon.sh && faasmctl cli.faasm --cmd "./bin/inv_wrapper.sh dev.tools --build Release --sgx Disabled"
2733
args:
2834
chdir: "/home/{{ ansible_user }}/git/faasm/faasm"
2935
executable: /bin/bash
@@ -39,9 +45,4 @@
3945
environment:
4046
FAASM_WASM_VM: sgx
4147

42-
- name: "Fetch the cross-compilation toolchain image"
43-
shell: docker pull ghcr.io/faasm/accless-experiments:{{ accless_version}}
44-
args:
45-
executable: /bin/bash
46-
4748
# TODO: build workflows here, and patch with the right certificate for the AS

bin/workon.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ alias kubectl=${COCO_SOURCE}/bin/kubectl
3232

3333
# This is the path in the SGX-enabled machine we use for the experiments
3434
export FAASM_INI_FILE=/home/tless/git/faasm/faasm/faasm.ini
35-
export FAASM_VERSION=0.30.0
35+
export FAASM_VERSION=0.33.0
3636

3737
# ----------------------------
3838
# Git config

docs/sgx_faasm.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@
22

33
TODO(docs): explain SGX-Faasm design
44

5+
SGX-Faasm is a port of the [Faasm](https://github.com/faasm/faasm) serverless
6+
runtime to execute serverless functions (inside WASM modules) inside SGX
7+
enclaves and, optionally, leverage Accless for access control.
8+
9+
We had to modify Faasm quite extensively, but all our modifications are
10+
upstreamed and cover mostly what is under the `src/enclave` directory.
11+
512
## Deploy
613

714
For the time being, we deploy SGX-Faasm on an SGXv2 VM on Azure, and deploy
815
a Faasm compose cluster in there. In the future we could consider deploying
916
directly on top of AKS.
1017

18+
To create the Azure resources to run SGX-Faasm you may run:
19+
1120
```bash
1221
invrs azure sgx-faasm create
1322
invrs azure sgx-faasm provision
1423
```
1524

25+
then, for each variant of Faasm follow the coresponding instructions:
26+
* [Faasm](#faasm) - vanilla Faasm.
27+
* [SGX-Faasm](#sgx-faasm) - Faasm on top of SGX, no access control.
28+
* [Accless-Faasm](#sgx-faasm) - Faasm on top of SGX with access control.
29+
1630
### Faasm
1731

1832
```bash

invrs/ansible/inventory/vms.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

invrs/src/env.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ impl Env {
3737

3838
Ok(version.trim().to_string())
3939
}
40+
41+
pub fn get_faasm_version() -> String {
42+
std::env::var("FAASM_VERSION").unwrap()
43+
}
4044
}

invrs/src/main.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::tasks::s3::S3;
77
use crate::tasks::ubench::{MicroBenchmarks, Ubench, UbenchRunArgs};
88
use clap::{Parser, Subcommand};
99
use log::error;
10-
use std::{path::Path, process};
10+
use std::{collections::HashMap, path::Path, process};
1111

1212
pub mod attestation_service;
1313
pub mod env;
@@ -604,10 +604,13 @@ async fn main() -> anyhow::Result<()> {
604604
let client_ip = Azure::get_vm_ip("accless-cvm");
605605
let server_ip = Azure::get_vm_ip("accless-as");
606606

607+
let vars: HashMap<&str, &str> = HashMap::from([
608+
("as_ip", server_ip.as_str())
609+
]);
607610
Azure::provision_with_ansible(
608611
"accless",
609612
"accless",
610-
Some(format!("as_ip={server_ip}").as_str()),
613+
Some(vars),
611614
);
612615

613616
// Copy the necessary stuff from the server to the client
@@ -677,10 +680,13 @@ async fn main() -> anyhow::Result<()> {
677680
AzureSubCommand::Provision {} => {
678681
let service_ip = Azure::get_vm_ip("attestation-service");
679682

683+
let vars: HashMap<&str, &str> = HashMap::from([
684+
("as_ip", service_ip.as_str())
685+
]);
680686
Azure::provision_with_ansible(
681687
"attestation-service",
682688
"attestationservice",
683-
Some(format!("as_ip={service_ip}").as_str()),
689+
Some(vars),
684690
);
685691
}
686692
AzureSubCommand::ScpResults {} => {
@@ -739,10 +745,15 @@ async fn main() -> anyhow::Result<()> {
739745
}
740746
AzureSubCommand::Provision {} => {
741747
let version = Env::get_version().unwrap();
748+
let faasm_version = Env::get_faasm_version();
749+
let vars: HashMap<&str, &str> = HashMap::from([
750+
("accless_version", version.as_str()),
751+
("faasm_version", faasm_version.as_str()),
752+
]);
742753
Azure::provision_with_ansible(
743754
"sgx-faasm",
744755
"sgxfaasm",
745-
Some(format!("accless_version={version}").as_str()),
756+
Some(vars),
746757
);
747758
}
748759
AzureSubCommand::ScpResults {} => {
@@ -779,10 +790,11 @@ async fn main() -> anyhow::Result<()> {
779790
}
780791
AzureSubCommand::Provision {} => {
781792
let version = Env::get_version().unwrap();
793+
let vars: HashMap<&str, &str> = HashMap::from([("accless_version", version.as_str())]);
782794
Azure::provision_with_ansible(
783795
"snp-knative",
784796
"snpknative",
785-
Some(format!("accless_version={version}").as_str()),
797+
Some(vars),
786798
);
787799
}
788800
AzureSubCommand::ScpResults {} => {
@@ -828,10 +840,13 @@ async fn main() -> anyhow::Result<()> {
828840
let client_ip = Azure::get_vm_ip("tless-trustee-client");
829841
let server_ip = Azure::get_vm_ip("tless-trustee-server");
830842

843+
let vars: HashMap<&str, &str> = HashMap::from([
844+
("kbs_ip", server_ip.as_str())
845+
]);
831846
Azure::provision_with_ansible(
832847
"tless-trustee",
833848
"trustee",
834-
Some(format!("kbs_ip={server_ip}").as_str()),
849+
Some(vars),
835850
);
836851

837852
// Copy the necessary stuff from the server to the client

invrs/src/tasks/azure.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use base64::Engine;
33
use log::info;
44
use serde_json::Value;
55
use shellexpand;
6-
use std::{fs, process::Command, process::ExitStatus};
6+
use std::{fs, collections::HashMap, process::Command, process::ExitStatus};
77

88
const AZURE_RESOURCE_GROUP: &str = "faasm";
99
const AZURE_USERNAME: &str = "tless";
@@ -12,8 +12,7 @@ const AZURE_LOCATION: &str = "eastus";
1212
const AZURE_SSH_PRIV_KEY: &str = "~/.ssh/id_rsa";
1313
const AZURE_SSH_PUB_KEY: &str = "~/.ssh/id_rsa.pub";
1414

15-
const AZURE_SGX_VM_IMAGE: &str =
16-
"Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:22.04.202301140";
15+
const AZURE_SGX_VM_IMAGE: &str = "Canonical:ubuntu-24_04-lts:server:latest";
1716
const AZURE_SNP_CC_VM_SIZE: &str =
1817
"/CommunityGalleries/cocopreview-91c44057-c3ab-4652-bf00-9242d5a90170/Images/ubu2204-snp-host-upm/Versions/latest";
1918

@@ -482,7 +481,7 @@ impl Azure {
482481
pub fn provision_with_ansible(
483482
vm_deployment: &str,
484483
inventory_name: &str,
485-
extra_vars: Option<&str>,
484+
extra_vars: Option<HashMap<&str, &str>>,
486485
) {
487486
let mut inventory_file = Env::ansible_root().join("inventory");
488487
fs::create_dir_all(&inventory_file).expect("invrs: failed to create inventory directory");
@@ -514,7 +513,10 @@ impl Azure {
514513
.to_str()
515514
.unwrap(),
516515
match extra_vars {
517-
Some(val) => format!("-e {val}"),
516+
Some(val) => {
517+
let json = serde_json::to_string(&val).unwrap();
518+
format!("-e {json}")
519+
},
518520
None => "".to_string(),
519521
}
520522
);

0 commit comments

Comments
 (0)