-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
260 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// kindContainerdConfig was extracted from a Kind cluster | ||
const kindContainerdConfig = ` | ||
# explicitly use v2 config format | ||
version = 2 | ||
[proxy_plugins] | ||
# fuse-overlayfs is used for rootless | ||
[proxy_plugins."fuse-overlayfs"] | ||
type = "snapshot" | ||
address = "/run/containerd-fuse-overlayfs.sock" | ||
[plugins."io.containerd.grpc.v1.cri".containerd] | ||
# save disk space when using a single snapshotter | ||
discard_unpacked_layers = true | ||
# explicitly use default snapshotter so we can sed it in entrypoint | ||
snapshotter = "overlayfs" | ||
# explicit default here, as we're configuring it below | ||
default_runtime_name = "runc" | ||
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] | ||
# set default runtime handler to v2, which has a per-pod shim | ||
runtime_type = "io.containerd.runc.v2" | ||
# Generated by "ctr oci spec" and modified at base container to mount poduct_uuid | ||
base_runtime_spec = "/etc/containerd/cri-base.json" | ||
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] | ||
# use systemd cgroup by default | ||
SystemdCgroup = true | ||
# Setup a runtime with the magic name ("test-handler") used for Kubernetes | ||
# runtime class tests ... | ||
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.test-handler] | ||
# same settings as runc | ||
runtime_type = "io.containerd.runc.v2" | ||
base_runtime_spec = "/etc/containerd/cri-base.json" | ||
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.test-handler.options] | ||
SystemdCgroup = true | ||
[plugins."io.containerd.grpc.v1.cri"] | ||
# use fixed sandbox image | ||
sandbox_image = "registry.k8s.io/pause:3.7" | ||
# allow hugepages controller to be missing | ||
# see https://github.com/containerd/cri/pull/1501 | ||
tolerate_missing_hugepages_controller = true | ||
# restrict_oom_score_adj needs to be true when running inside UserNS (rootless) | ||
restrict_oom_score_adj = true | ||
` | ||
|
||
func TestConfigureContainerd(t *testing.T) { | ||
configFile, err := os.CreateTemp("", "containerd-config-*.toml") | ||
require.NoError(t, err) | ||
|
||
require.NoError(t, os.WriteFile(configFile.Name(), []byte(kindContainerdConfig), os.ModePerm)) | ||
|
||
restart, err := configureContainerd(runtimeContainerd, configFile.Name()) | ||
require.NoError(t, err) | ||
|
||
newFile, err := os.ReadFile(configFile.Name()) | ||
require.NoError(t, err) | ||
|
||
backupInfo, err := os.Stat(configFile.Name() + configBackupSuffix) | ||
require.NoError(t, err) | ||
|
||
assert.NotEmpty(t, backupInfo.Size()) | ||
assert.NotEmpty(t, newFile) | ||
assert.True(t, restart) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resources: | ||
- uninstaller.yaml | ||
images: | ||
- name: installer | ||
newName: ghcr.io/ctrox/zeropod-installer | ||
newTag: dev |
Oops, something went wrong.