Skip to content

Commit

Permalink
Merge pull request #1292 from zmrow/vmware-dev-variant
Browse files Browse the repository at this point in the history
Add a vmware-dev variant
  • Loading branch information
zmrow authored Feb 16, 2021
2 parents bc7a54a + 3df4ee2 commit 721426a
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
- variant: aws-dev
arch: x86_64
supported: false
- variant: vmware-dev
arch: x86_64
supported: false
fail-fast: false
steps:
- uses: actions/checkout@v2
Expand Down
14 changes: 14 additions & 0 deletions packages/containerd/containerd-config-toml_vmware-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version = 2
root = "/var/lib/containerd"
state = "/run/containerd"
disabled_plugins = [
"io.containerd.internal.v1.opt",
"io.containerd.snapshotter.v1.aufs",
"io.containerd.snapshotter.v1.devmapper",
"io.containerd.snapshotter.v1.native",
"io.containerd.snapshotter.v1.zfs",
"io.containerd.grpc.v1.cri",
]

[grpc]
address = "/run/containerd/containerd.sock"
3 changes: 2 additions & 1 deletion packages/containerd/containerd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Source2: containerd-config-toml_aws-k8s
Source3: containerd-config-toml_aws-dev
Source4: containerd-config-toml_aws-ecs-1
Source5: containerd-tmpfiles.conf
Source6: containerd-config-toml_vmware-dev
Source1000: clarify.toml

# Upstream patch; can drop when we move to v1.4.0.
Expand Down Expand Up @@ -100,7 +101,7 @@ install -p -m 0644 %{S:1} %{buildroot}%{_cross_unitdir}/containerd.service

install -d %{buildroot}%{_cross_templatedir}
install -d %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}/containerd
install -p -m 0644 %{S:2} %{S:3} %{S:4} %{buildroot}%{_cross_templatedir}
install -p -m 0644 %{S:2} %{S:3} %{S:4} %{S:6} %{buildroot}%{_cross_templatedir}

install -d %{buildroot}%{_cross_tmpfilesdir}
install -p -m 0644 %{S:5} %{buildroot}%{_cross_tmpfilesdir}/containerd.conf
Expand Down
6 changes: 2 additions & 4 deletions sources/api/host-containers/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ mod error {
source: serde_json::Error,
},

#[snafu(display("settings.host_containers missing in API response"))]
MissingSettings {},

#[snafu(display("Host containers '{}' missing field '{}'", name, field))]
MissingField { name: String, field: String },

Expand Down Expand Up @@ -157,7 +154,8 @@ where
let settings: model::Settings =
serde_json::from_str(&response_body).context(error::ResponseJson { method, uri })?;

settings.host_containers.context(error::MissingSettings)
// If host containers aren't defined, return an empty map
Ok(settings.host_containers.unwrap_or_default())
}

/// SystemdUnit stores the systemd unit being manipulated
Expand Down
1 change: 1 addition & 0 deletions sources/logdog/conf/logdog.vmware-dev.conf
7 changes: 6 additions & 1 deletion sources/models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ The `#[model]` attribute on Settings and its sub-structs reduces duplication and
* [Model](src/aws-ecs-1/mod.rs)
* [Default settings](src/aws-ecs-1/defaults.d/)

### aws-dev: Development build
### aws-dev: AWS development build

* [Model](src/aws-dev/mod.rs)
* [Default settings](src/aws-dev/defaults.d/)

### vmware-dev: VMWare development build

* [Model](src/vmware-dev/mod.rs)
* [Default settings](src/vmware-dev/defaults.d/)

## This directory

We use `build.rs` to symlink the proper API model source code for Cargo to build.
Expand Down
7 changes: 6 additions & 1 deletion sources/models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ The `#[model]` attribute on Settings and its sub-structs reduces duplication and
* [Model](src/aws-ecs-1/mod.rs)
* [Default settings](src/aws-ecs-1/defaults.d/)
## aws-dev: Development build
## aws-dev: AWS development build
* [Model](src/aws-dev/mod.rs)
* [Default settings](src/aws-dev/defaults.d/)
## vmware-dev: VMWare development build
* [Model](src/vmware-dev/mod.rs)
* [Default settings](src/vmware-dev/defaults.d/)
# This directory
We use `build.rs` to symlink the proper API model source code for Cargo to build.
Expand Down
1 change: 1 addition & 0 deletions sources/models/src/vmware-dev/defaults.d/10-defaults.toml
18 changes: 18 additions & 0 deletions sources/models/src/vmware-dev/defaults.d/50-vmware-dev.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[configuration-files.containerd-config-toml]
# No override to path
template-path = "/usr/share/templates/containerd-config-toml_vmware-dev"

# Docker
[services.docker]
restart-commands = ["/bin/systemctl try-restart docker.service"]
configuration-files = ["proxy-env"]

# Network
[metadata.settings.network]
affected-services = ["containerd", "docker", "host-containerd"]

# NTP
# Use a public endpoint, don't assume any local ones.
[settings.ntp]
time-servers = ["2.amazon.pool.ntp.org"]

18 changes: 18 additions & 0 deletions sources/models/src/vmware-dev/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use model_derive::model;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

use crate::modeled_types::Identifier;
use crate::{ContainerImage, KernelSettings, NetworkSettings, NtpSettings, UpdatesSettings};

// Note: we have to use 'rename' here because the top-level Settings structure is the only one
// that uses its name in serialization; internal structures use the field name that points to it
#[model(rename = "settings", impl_default = true)]
struct Settings {
motd: String,
updates: UpdatesSettings,
host_containers: HashMap<Identifier, ContainerImage>,
ntp: NtpSettings,
network: NetworkSettings,
kernel: KernelSettings,
}
9 changes: 8 additions & 1 deletion variants/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,17 @@ This variant is compatible with Kubernetes 1.19, 1.20, and 1.21 clusters.
The [aws-ecs-1](aws-ecs-1/Cargo.toml) variant includes the packages needed to run an [Amazon ECS](https://ecs.aws)
container instance in AWS.

### aws-dev: Development build
### aws-dev: AWS development build

The [aws-dev](aws-dev/Cargo.toml) variant has useful packages for local development of the OS.
It includes tools for troubleshooting as well as Docker for running containers.
User data will be read from IMDS.

### vmware-dev: VMWare development build

The [vmware-dev](vmware-dev/Cargo.toml) variant has useful packages for local development of the OS, and is intended to run as a VMWare guest.
It includes tools for troubleshooting as well as Docker for running containers.
User data will be read from a mounted CD-ROM, either from a file named "user-data" or from an OVF file.

## Development

Expand Down
5 changes: 5 additions & 0 deletions variants/vmware-dev/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions variants/vmware-dev/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "vmware-dev"
version = "0.1.0"
edition = "2018"
publish = false
build = "build.rs"
# Don't rebuild crate just because of changes to README.
exclude = ["README.md"]

[package.metadata.build-variant]
included-packages = [
# core
"release",
# docker
"docker-cli",
"docker-engine",
"docker-init",
"docker-proxy",
# tools
"findutils",
"login",
"iputils",
"procps",
"strace",
"tcpdump",
"chrony-tools",
]

[lib]
path = "lib.rs"
9 changes: 9 additions & 0 deletions variants/vmware-dev/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use std::process::{exit, Command};

fn main() -> Result<(), std::io::Error> {
let ret = Command::new("buildsys").arg("build-variant").status()?;
if !ret.success() {
exit(1);
}
Ok(())
}
1 change: 1 addition & 0 deletions variants/vmware-dev/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// not used

0 comments on commit 721426a

Please sign in to comment.