Skip to content
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

Support flatcar version >= 3815.2.0 #93

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/controller/operatingsystemconfig/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ if [ ! -s /etc/containerd/config.toml ]; then
fi
mkdir -p /etc/systemd/system/containerd.service.d
cat <<EOF > /etc/systemd/system/containerd.service.d/11-exec_config.conf
# TODO(MichaelEischer): remove this file once all flatcar versions that use torcx,
# that is before 3815.2.0, have run out of support
[Service]
ExecStart=
ExecStart=/bin/bash -c 'PATH="/run/torcx/unpack/docker/bin:$PATH" /run/torcx/unpack/docker/bin/containerd --config /etc/containerd/config.toml'
# try to use containerd provided via torcx, but also falls back to /usr/bin/containerd provided via systemd-sysext
ExecStart=/bin/bash -c 'PATH="/run/torcx/unpack/docker/bin:$PATH" containerd --config /etc/containerd/config.toml'
EOF
chmod 0644 /etc/systemd/system/containerd.service.d/11-exec_config.conf
` + writeFilesToDiskScript + `
Expand Down
19 changes: 16 additions & 3 deletions pkg/controller/operatingsystemconfig/actuator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ if [ ! -s /etc/containerd/config.toml ]; then
fi
mkdir -p /etc/systemd/system/containerd.service.d
cat <<EOF > /etc/systemd/system/containerd.service.d/11-exec_config.conf
# TODO(MichaelEischer): remove this file once all flatcar versions that use torcx,
# that is before 3815.2.0, have run out of support
[Service]
ExecStart=
ExecStart=/bin/bash -c 'PATH="/run/torcx/unpack/docker/bin:$PATH" /run/torcx/unpack/docker/bin/containerd --config /etc/containerd/config.toml'
# try to use containerd provided via torcx, but also falls back to /usr/bin/containerd provided via systemd-sysext
ExecStart=/bin/bash -c 'PATH="/run/torcx/unpack/docker/bin:$PATH" containerd --config /etc/containerd/config.toml'
EOF
chmod 0644 /etc/systemd/system/containerd.service.d/11-exec_config.conf

Expand All @@ -87,10 +90,18 @@ CONTAINERD_CONFIG=/etc/containerd/config.toml

ALTERNATE_LOGROTATE_PATH="/usr/bin/logrotate"

# prefer containerd from torcx
# TODO(MichaelEischer): remove this special case once all flatcar versions that use torcx,
# that is before 3815.2.0, have run out of support
CONTAINERD="/usr/bin/containerd"
if [ -x /run/torcx/unpack/docker/bin/containerd ]; then
CONTAINERD="/run/torcx/unpack/docker/bin/containerd"
fi

# initialize default containerd config if does not exist
if [ ! -s "$CONTAINERD_CONFIG" ]; then
mkdir -p /etc/containerd/
/run/torcx/unpack/docker/bin/containerd config default > "$CONTAINERD_CONFIG"
mkdir -p "$(dirname "$CONTAINERD_CONFIG")"
${CONTAINERD} config default > "$CONTAINERD_CONFIG"
chmod 0644 "$CONTAINERD_CONFIG"
fi

Expand All @@ -99,6 +110,8 @@ if [[ -e /sys/fs/cgroup/cgroup.controllers ]]; then
sed -i "s/SystemdCgroup *= *false/SystemdCgroup = true/" "$CONTAINERD_CONFIG"
fi

# TODO(MichaelEischer): remove this block once all flatcar versions that use torcx,
# that is before 3815.2.0, have run out of support
# provide kubelet with access to the containerd binaries in /run/torcx/unpack/docker/bin
if [ ! -s /etc/systemd/system/kubelet.service.d/environment.conf ]; then
mkdir -p /etc/systemd/system/kubelet.service.d/
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/operatingsystemconfig/coreos_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,13 @@ WantedBy=containerd.service kubelet.service
coreos.File{
Path: "/etc/systemd/system/containerd.service.d/11-exec_config.conf",
RawFilePermissions: "0644",
Content: `[Service]
Content: `# TODO(MichaelEischer): remove this file once all flatcar versions that use torcx,
# that is before 3815.2.0, have run out of support
[Service]
SyslogIdentifier=containerd
ExecStart=
ExecStart=/bin/bash -c 'PATH="/run/torcx/unpack/docker/bin:$PATH" /run/torcx/unpack/docker/bin/containerd --config /etc/containerd/config.toml'
# try to use containerd provided via torcx, but also falls back to /usr/bin/containerd provided via systemd-sysext
ExecStart=/bin/bash -c 'PATH="/run/torcx/unpack/docker/bin:$PATH" containerd --config /etc/containerd/config.toml'
`,
},
coreos.File{
Expand Down
19 changes: 16 additions & 3 deletions pkg/controller/operatingsystemconfig/coreos_reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,13 @@ var _ = Describe("CloudConfig", func() {

expectedFiles := `write_files:
- content: |
# TODO(MichaelEischer): remove this file once all flatcar versions that use torcx,
# that is before 3815.2.0, have run out of support
[Service]
SyslogIdentifier=containerd
ExecStart=
ExecStart=/bin/bash -c 'PATH="/run/torcx/unpack/docker/bin:$PATH" /run/torcx/unpack/docker/bin/containerd --config /etc/containerd/config.toml'
# try to use containerd provided via torcx, but also falls back to /usr/bin/containerd provided via systemd-sysext
ExecStart=/bin/bash -c 'PATH="/run/torcx/unpack/docker/bin:$PATH" containerd --config /etc/containerd/config.toml'
path: /etc/systemd/system/containerd.service.d/11-exec_config.conf
permissions: "0644"
- content: |
Expand All @@ -140,10 +143,18 @@ var _ = Describe("CloudConfig", func() {

ALTERNATE_LOGROTATE_PATH="/usr/bin/logrotate"

# prefer containerd from torcx
# TODO(MichaelEischer): remove this special case once all flatcar versions that use torcx,
# that is before 3815.2.0, have run out of support
CONTAINERD="/usr/bin/containerd"
if [ -x /run/torcx/unpack/docker/bin/containerd ]; then
CONTAINERD="/run/torcx/unpack/docker/bin/containerd"
fi

# initialize default containerd config if does not exist
if [ ! -s "$CONTAINERD_CONFIG" ]; then
mkdir -p /etc/containerd/
/run/torcx/unpack/docker/bin/containerd config default > "$CONTAINERD_CONFIG"
mkdir -p "$(dirname "$CONTAINERD_CONFIG")"
${CONTAINERD} config default > "$CONTAINERD_CONFIG"
chmod 0644 "$CONTAINERD_CONFIG"
fi

Expand All @@ -152,6 +163,8 @@ var _ = Describe("CloudConfig", func() {
sed -i "s/SystemdCgroup *= *false/SystemdCgroup = true/" "$CONTAINERD_CONFIG"
fi

# TODO(MichaelEischer): remove this block once all flatcar versions that use torcx,
# that is before 3815.2.0, have run out of support
# provide kubelet with access to the containerd binaries in /run/torcx/unpack/docker/bin
if [ ! -s /etc/systemd/system/kubelet.service.d/environment.conf ]; then
mkdir -p /etc/systemd/system/kubelet.service.d/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ CONTAINERD_CONFIG=/etc/containerd/config.toml

ALTERNATE_LOGROTATE_PATH="/usr/bin/logrotate"

# prefer containerd from torcx
# TODO(MichaelEischer): remove this special case once all flatcar versions that use torcx,
# that is before 3815.2.0, have run out of support
CONTAINERD="/usr/bin/containerd"
if [ -x /run/torcx/unpack/docker/bin/containerd ]; then
CONTAINERD="/run/torcx/unpack/docker/bin/containerd"
fi

# initialize default containerd config if does not exist
if [ ! -s "$CONTAINERD_CONFIG" ]; then
mkdir -p /etc/containerd/
/run/torcx/unpack/docker/bin/containerd config default > "$CONTAINERD_CONFIG"
mkdir -p "$(dirname "$CONTAINERD_CONFIG")"
${CONTAINERD} config default > "$CONTAINERD_CONFIG"
chmod 0644 "$CONTAINERD_CONFIG"
fi

Expand All @@ -16,6 +24,8 @@ if [[ -e /sys/fs/cgroup/cgroup.controllers ]]; then
sed -i "s/SystemdCgroup *= *false/SystemdCgroup = true/" "$CONTAINERD_CONFIG"
fi

# TODO(MichaelEischer): remove this block once all flatcar versions that use torcx,
# that is before 3815.2.0, have run out of support
# provide kubelet with access to the containerd binaries in /run/torcx/unpack/docker/bin
if [ ! -s /etc/systemd/system/kubelet.service.d/environment.conf ]; then
mkdir -p /etc/systemd/system/kubelet.service.d/
Expand Down