Skip to content

Allow user-defined host containers #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ for ws in workspaces packages images ; do
done
chmod o+r -R ${CARGO_HOME}

cd ${BUILDSYS_SOURCES_DIR}/host-containers/cmd/host-ctr
cd ${BUILDSYS_SOURCES_DIR}/host-ctr/cmd/host-ctr
docker run --rm \
-e GOPRIVATE='*' \
-e GOCACHE='/tmp/.cache' \
Expand Down
2 changes: 1 addition & 1 deletion packages/Cargo.lock

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

2 changes: 1 addition & 1 deletion packages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ members = [
"golang",
"growpart",
"grub",
"host-containers",
"host-ctr",
"iproute",
"iptables",
"iputils",
Expand Down
22 changes: 19 additions & 3 deletions packages/api/api.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Source7: settings-applier.service
Source8: data-store-version
Source9: migrator.service
Source10: api-sysusers.conf
Source11: [email protected]
Source12: host-containers-tmpfiles.conf
BuildRequires: gcc-%{_cross_target}
BuildRequires: %{_cross_os}glibc-devel
BuildRequires: %{_cross_os}systemd-devel
Expand Down Expand Up @@ -83,6 +85,12 @@ Requires: %{_cross_os}apiserver = %{version}-%{release}
%description -n %{_cross_os}servicedog
%{summary}.

%package -n %{_cross_os}host-containers
Summary: Manages system- and user-defined host containers
Requires: %{_cross_os}apiserver = %{version}-%{release}
%description -n %{_cross_os}host-containers
%{summary}.

%package -n %{_cross_os}storewolf
Summary: Data store creator
Requires: %{_cross_os}apiserver = %{version}-%{release}
Expand All @@ -109,7 +117,8 @@ Summary: Commits settings from user data, defaults, and generators at boot
for p in \
apiclient \
moondog netdog sundog pluto bork \
thar-be-settings servicedog storewolf settings-committer \
thar-be-settings servicedog host-containers \
storewolf settings-committer \
migration/migrator ;
do
%cargo_build --path %{workspace_dir}/${p}
Expand All @@ -128,15 +137,16 @@ install -d %{buildroot}%{_cross_bindir}
for p in \
apiclient apiserver \
moondog netdog sundog pluto bork \
thar-be-settings servicedog storewolf settings-committer \
thar-be-settings servicedog host-containers \
storewolf settings-committer \
migrator ;
do
install -p -m 0755 bin/${p} %{buildroot}%{_cross_bindir}
done

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 \
%{S:1} %{S:2} %{S:3} %{S:4} %{S:5} %{S:7} %{S:9} \
%{S:1} %{S:2} %{S:3} %{S:4} %{S:5} %{S:7} %{S:9} %{S:11} \
%{buildroot}%{_cross_unitdir}

install -d %{buildroot}%{_cross_datadir}/thar
Expand All @@ -150,6 +160,7 @@ done

install -d %{buildroot}%{_cross_tmpfilesdir}
install -p -m 0644 %{S:6} %{buildroot}%{_cross_tmpfilesdir}/migration.conf
install -p -m 0644 %{S:12} %{buildroot}%{_cross_tmpfilesdir}/host-containers.conf

install -d %{buildroot}%{_cross_sysusersdir}
install -p -m 0644 %{S:10} %{buildroot}%{_cross_sysusersdir}/api.conf
Expand Down Expand Up @@ -188,6 +199,11 @@ install -p -m 0644 %{S:10} %{buildroot}%{_cross_sysusersdir}/api.conf
%files -n %{_cross_os}servicedog
%{_cross_bindir}/servicedog

%files -n %{_cross_os}host-containers
%{_cross_bindir}/host-containers
%{_cross_unitdir}/[email protected]
%{_cross_tmpfilesdir}/host-containers.conf

%files -n %{_cross_os}storewolf
%{_cross_bindir}/storewolf
%{_cross_unitdir}/storewolf.service
Expand Down
1 change: 1 addition & 0 deletions packages/api/host-containers-tmpfiles.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d /etc/host-containers 0755 root root -
16 changes: 16 additions & 0 deletions packages/api/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Host container: %i
After=host-containerd.service
Requires=host-containerd.service

[Service]
Type=simple
EnvironmentFile=/etc/host-containers/%i.env
ExecStart=/usr/bin/host-ctr -ctr-id='%i' -source='${CTR_SOURCE}' -superpowered='${CTR_SUPERPOWERED}'
Restart=always
RestartSec=10
TimeoutStopSec=60
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "host-containers"
name = "host-ctr"
version = "0.1.0"
edition = "2018"
publish = false
build = "build.rs"

[package.metadata.build-package]
source-groups = [ "host-containers" ]
source-groups = [ "host-ctr" ]

[lib]
path = "pkg.rs"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
%global workspace_name host-containers
%global workspace_name host-ctr
%global systemd_systemdir %{_cross_libdir}/systemd/system

Name: %{_cross_os}%{workspace_name}
Version: 0.0
Release: 0%{?dist}
Summary: Thar host container management
Summary: Thar host container runner
License: FIXME
BuildRequires: gcc-%{_cross_target}
BuildRequires: %{_cross_os}glibc-devel
Expand Down
File renamed without changes.
15 changes: 0 additions & 15 deletions packages/release/host-containers-systemd-unit-admin.template

This file was deleted.

15 changes: 0 additions & 15 deletions packages/release/host-containers-systemd-unit-control.template

This file was deleted.

10 changes: 2 additions & 8 deletions packages/release/release.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Source99: release-tmpfiles.conf

# FIXME What should own system-level file templates?
Source200: hostname.template
Source201: host-containers-systemd-unit-admin.template
Source202: host-containers-systemd-unit-control.template

Source1000: eth0.xml
Source1002: configured.target
Expand Down Expand Up @@ -55,7 +53,7 @@ Requires: %{_cross_os}signpost
Requires: %{_cross_os}sundog
Requires: %{_cross_os}pluto
Requires: %{_cross_os}storewolf
Requires: %{_cross_os}servicedog
Requires: %{_cross_os}host-containers
Requires: %{_cross_os}settings-committer
Requires: %{_cross_os}systemd
Requires: %{_cross_os}thar-be-settings
Expand All @@ -64,7 +62,7 @@ Requires: %{_cross_os}updog
Requires: %{_cross_os}util-linux
Requires: %{_cross_os}preinit
Requires: %{_cross_os}wicked
Requires: %{_cross_os}host-containers
Requires: %{_cross_os}host-ctr

%description
%{summary}.
Expand Down Expand Up @@ -107,8 +105,6 @@ install -p -m 0644 %{S:1002} %{S:1003} %{S:1006} %{S:1007} %{S:1008} %{S:1009} %

install -d %{buildroot}%{_cross_templatedir}
install -p -m 0644 %{S:200} %{buildroot}%{_cross_templatedir}/hostname
install -p -m 0644 %{S:201} %{buildroot}%{_cross_templatedir}/host-containers-systemd-unit-admin
install -p -m 0644 %{S:202} %{buildroot}%{_cross_templatedir}/host-containers-systemd-unit-control

%files
%if %{with shell}
Expand All @@ -130,7 +126,5 @@ install -p -m 0644 %{S:202} %{buildroot}%{_cross_templatedir}/host-containers-sy
%{_cross_unitdir}/var-lib-thar.mount
%dir %{_cross_templatedir}
%{_cross_templatedir}/hostname
%{_cross_templatedir}/host-containers-systemd-unit-admin
%{_cross_templatedir}/host-containers-systemd-unit-control

%changelog
15 changes: 15 additions & 0 deletions workspaces/Cargo.lock

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

1 change: 1 addition & 0 deletions workspaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"api/sundog",
"api/pluto",
"api/servicedog",
"api/host-containers",
"api/storewolf",
"api/thar-be-settings",
"api/settings-committer",
Expand Down
18 changes: 3 additions & 15 deletions workspaces/api/apiserver/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::net::Ipv4Addr;

use crate::modeled_types::ValidBase64;
use crate::modeled_types::{SingleLineString, ValidBase64};

///// Primary user-visible settings

Expand All @@ -32,7 +32,7 @@ pub struct Settings {
pub updates: Option<UpdatesSettings>,

#[serde(skip_serializing_if = "Option::is_none")]
pub host_containers: Option<HostContainersSettings>,
pub host_containers: Option<HashMap<SingleLineString, ContainerImage>>,

#[serde(skip_serializing_if = "Option::is_none")]
pub ntp: Option<NtpSettings>,
Expand Down Expand Up @@ -82,23 +82,11 @@ pub struct UpdatesSettings {
pub seed: Option<String>,
}

// Settings for HostContainers, which manages the lifecycle of privileged, unorchestrated
// containers that are used for system management purposes.
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub struct HostContainersSettings {
#[serde(skip_serializing_if = "Option::is_none")]
pub admin: Option<ContainerImage>,

#[serde(skip_serializing_if = "Option::is_none")]
pub control: Option<ContainerImage>,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub struct ContainerImage {
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<String>,
pub source: Option<SingleLineString>,

#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
Expand Down
Loading