Skip to content

Commit

Permalink
merge: #2703
Browse files Browse the repository at this point in the history
2703: Add support for Podman r=stack72 a=stack72

- chore: add sudomateo to contributors
- feat(si): implement the podman container engine
- fix(si): Ensure that the podman container engine sock works on macOS

This PR just builds on the wonderful work from `@sudomateo` to ensure that podman works on macOS - which it now does :)


```
SI_CONTAINER_ENGINE=podman buck2 run //bin/si start
File changed: root//lib/si-cli/src/engine/podman_engine.rs
File changed: root//lib/si-cli/src/engine/podman_engine.rs~
Build ID: 07d79a8a-c372-438c-ba68-cee337fab2cb
Network: Up: 0 B  Down: 0 B
Jobs completed: 6. Time elapsed: 5.2s.
Cache hits: 0%. Commands: 2 (cached: 0, remote: 0, local: 2)
System Initiative Launcher is in "local" mode


Launcher update found, please run `si update` to install it

System Initiative needs some credentials in order to be able to interact with AWS and Docker.
The credentials are never sent back to System Initiative and can be inspected at the location:
/Users/stack72/Library/Application Support/SI/si_credentials.toml

Checking that the system is able to interact with the container engine to control System Initiative...
┌─────────────────────────┬────────────┐
│ Container Engine Active ┆     ✅     │
└─────────────────────────┴────────────┘
Downloading the containers required to run System Initiative
Found 9 missing containers
Downloading systeminit/jaeger                                                                                                                                                                                     Downloading systeminit/postgres                                                                                                                                                                                   Downloading systeminit/nats                                                                                                                                                                                       Downloading systeminit/otelcol                                                                                                                                                                                    Downloading systeminit/council                                                                                                                                                                                    Downloading systeminit/veritech                                                                                                                                                                                   Downloading systeminit/pinga                                                                                                                                                                                      Downloading systeminit/sdf                                                                                                                                                                                        Downloading systeminit/web                                                                                                                                                                                        All containers successfully downloaded                                                                                                                                                                            All system components running... System Initiative is alive!

You can now use the `si launch` command to open the System Initiative web portal
```

```
SI_CONTAINER_ENGINE=podman buck2 run //bin/si status
Build ID: d93c60d1-6215-472f-9cb8-f4ffc9ca6531
Network: Up: 0 B  Down: 0 B
Jobs completed: 3. Time elapsed: 0.0s.
System Initiative Launcher is in "local" mode


Launcher update found, please run `si update` to install it

Checking the status of System Initiative Software
┌────────────────────────────┬────────────┬─────────────────────────────────┐
│ Container Image            ┆ State      ┆ Container Version               │
╞════════════════════════════╪════════════╪═════════════════════════════════╡
│ systeminit/jaeger:stable   ┆     ✅     ┆ 20230817.143531.0-sha.5aa23f0e2 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ systeminit/postgres:stable ┆     ✅     ┆ 20230817.143531.0-sha.5aa23f0e2 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ systeminit/nats:stable     ┆     ✅     ┆ 20230817.143531.0-sha.5aa23f0e2 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ systeminit/otelcol:stable  ┆     ✅     ┆ 20230817.143531.0-sha.5aa23f0e2 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ systeminit/council:stable  ┆     ✅     ┆ 20230824.175134.0-sha.b64dbeae4 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ systeminit/veritech:stable ┆     ✅     ┆ 20230824.175134.0-sha.b64dbeae4 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ systeminit/pinga:stable    ┆     ✅     ┆ 20230824.175134.0-sha.b64dbeae4 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ systeminit/sdf:stable      ┆     ✅     ┆ 20230824.175134.0-sha.b64dbeae4 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ systeminit/web:stable      ┆     ✅     ┆ 20230824.195646.0-sha.d33fda262 │
└────────────────────────────┴────────────┴─────────────────────────────────┘

All system components working as expected...
```


Co-authored-by: Matthew Sanabria <[email protected]>
Co-authored-by: stack72 <[email protected]>
  • Loading branch information
3 people authored Aug 25, 2023
2 parents c928d0f + 9d40881 commit d5aedb7
Show file tree
Hide file tree
Showing 9 changed files with 757 additions and 63 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ We contributors to System Initiative:
* Zack Hamm (@zacharyhamm)
* Dan Miller (@jazzdan)
* Neil Hanlon (@NeilHanlon)
* Matthew Sanabria (@sudomateo)
5 changes: 0 additions & 5 deletions bin/si/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ async fn main() -> Result<()> {
}
}

if let Engine::Podman = args.engine() {
println!("Podman isn't supported as an engine at this time! It's coming soon though...");
return Ok(());
}

if is_preview {
println!("Preview mode... System Initiative would have taken the following actions");
}
Expand Down
6 changes: 3 additions & 3 deletions lib/si-cli/src/cmd/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ impl AppState {

async fn invoke(app: &AppState, silent: bool, is_preview: bool) -> CliResult<()> {
if !silent {
println!("Checking that the system is able to interact with the docker engine to control System Initiative...");
println!("Checking that the system is able to interact with the container engine to control System Initiative...");
}

if is_preview {
return Ok(());
}

if let Err(_e) = app.container_engine().ping().await {
return Err(SiCliError::DockerEngine);
return Err(SiCliError::ContainerEngine);
}

if !silent {
Expand All @@ -35,7 +35,7 @@ async fn invoke(app: &AppState, silent: bool, is_preview: bool) -> CliResult<()>
.set_content_arrangement(ContentArrangement::Dynamic)
.set_width(100)
.add_row(vec![
Cell::new("Docker Engine Active").add_attribute(Attribute::Bold),
Cell::new("Container Engine Active").add_attribute(Attribute::Bold),
Cell::new(" ✅ "),
]);

Expand Down
2 changes: 2 additions & 0 deletions lib/si-cli/src/cmd/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ async fn invoke(app: &AppState, is_preview: bool, keep_images: bool) -> CliResul
}
}

app.container_engine().delete_network().await?;

Ok(())
}
2 changes: 2 additions & 0 deletions lib/si-cli/src/cmd/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ async fn invoke(app: &AppState, is_preview: bool) -> CliResult<()> {
ensure_jwt_public_signing_key().await?;
let si_data_dir = get_si_data_dir().await?;

app.container_engine().create_network().await?;

for name in CONTAINER_NAMES.iter() {
let container = format!("systeminit/{0}", name);
let container_name = format!("local-{0}-1", name);
Expand Down
52 changes: 52 additions & 0 deletions lib/si-cli/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub trait ContainerEngine {
async fn downloaded_systeminit_containers_list(
&self,
) -> Result<Vec<SiImageSummary>, SiCliError>;
async fn create_network(&self) -> CliResult<()>;
async fn delete_network(&self) -> CliResult<()>;
async fn start_container(&self, id: String) -> CliResult<()>;
async fn stop_container(&self, id: String) -> CliResult<()>;
async fn create_otelcol(&self, name: String, image: String) -> CliResult<()>;
Expand Down Expand Up @@ -95,3 +97,53 @@ impl From<docker_api::models::ContainerSummary> for SiContainerSummary {
}
}
}

impl From<podman_api::models::LibpodImageSummary> for SiImageSummary {
fn from(image: podman_api::models::LibpodImageSummary) -> SiImageSummary {
let containers = match image.containers {
Some(count) => count as isize,
None => 0,
};

let created = match image.created {
Some(seconds) => seconds as isize,
None => 0,
};

let id = match image.id {
Some(id) => id,
None => "".to_owned(),
};

let labels = match image.labels {
Some(labels) => labels,
None => HashMap::new(),
};

let repo_tags = match image.repo_tags {
Some(repo_tags) => repo_tags,
None => Vec::new(),
};

SiImageSummary {
containers,
created,
id,
labels,
repo_tags,
}
}
}

impl From<podman_api::models::ListContainer> for SiContainerSummary {
fn from(container: podman_api::models::ListContainer) -> SiContainerSummary {
SiContainerSummary {
created: container.created.map(|created| created.timestamp()),
id: container.id,
image: container.image,
labels: container.labels,
status: container.status,
state: container.state,
}
}
}
8 changes: 8 additions & 0 deletions lib/si-cli/src/engine/docker_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ impl ContainerEngine for DockerEngine {
Ok(())
}

async fn create_network(&self) -> CliResult<()> {
Ok(())
}

async fn delete_network(&self) -> CliResult<()> {
Ok(())
}

async fn create_otelcol(&self, name: String, image: String) -> CliResult<()> {
let create_opts = ContainerCreateOpts::builder()
.name(name.clone())
Expand Down
Loading

0 comments on commit d5aedb7

Please sign in to comment.