-
Notifications
You must be signed in to change notification settings - Fork 249
Swap cgroupsv1 testing from GitHub Actions runner to Vagrant VM #368
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
AkihiroSuda
merged 2 commits into
containerd:main
from
austinvazquez:add-cgroups-v1-testing
Jun 4, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,143 @@ | ||
| # -*- mode: ruby -*- | ||
| # vi: set ft=ruby : | ||
|
|
||
| # Copyright The containerd Authors. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
|
|
||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| Vagrant.configure("2") do |config| | ||
| config.vm.box = ENV["BOX"] ? ENV["BOX"].split("@")[0] : "almalinux/8" | ||
| # BOX_VERSION is deprecated. Use "BOX=<BOX>@<BOX_VERSION>". | ||
| config.vm.box_version = ENV["BOX_VERSION"] || (ENV["BOX"].split("@")[1] if ENV["BOX"]) | ||
|
|
||
| memory = 4096 | ||
| cpus = 2 | ||
| disk_size = 60 | ||
| config.vm.provider :virtualbox do |v, o| | ||
| v.memory = memory | ||
| v.cpus = cpus | ||
| # Needs env var VAGRANT_EXPERIMENTAL="disks" | ||
| o.vm.disk :disk, size: "#{disk_size}GB", primary: true | ||
| v.customize ["modifyvm", :id, "--firmware", "efi"] | ||
| end | ||
| config.vm.provider :libvirt do |v| | ||
| v.memory = memory | ||
| v.cpus = cpus | ||
| v.machine_virtual_size = disk_size | ||
| # https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1725#issuecomment-1454058646 | ||
| # Needs `sudo cp /usr/share/OVMF/OVMF_VARS_4M.fd /var/lib/libvirt/qemu/nvram/` | ||
| v.loader = '/usr/share/OVMF/OVMF_CODE_4M.fd' | ||
| v.nvram = '/var/lib/libvirt/qemu/nvram/OVMF_VARS_4M.fd' | ||
| end | ||
|
|
||
| config.vm.synced_folder ".", "/vagrant", type: "rsync" | ||
|
|
||
| config.vm.provision 'shell', path: 'script/resize-vagrant-root.sh' | ||
|
|
||
| # To re-run, installing CNI from RPM: | ||
| # INSTALL_PACKAGES="containernetworking-plugins" vagrant up --provision-with=install-packages | ||
| # | ||
| config.vm.provision "install-packages", type: "shell", run: "once" do |sh| | ||
| sh.upload_path = "/tmp/vagrant-install-packages" | ||
| sh.env = { | ||
| 'INSTALL_PACKAGES': ENV['INSTALL_PACKAGES'], | ||
| } | ||
| sh.inline = <<~SHELL | ||
| #!/usr/bin/env bash | ||
| set -eux -o pipefail | ||
| dnf -y install \ | ||
| curl \ | ||
| gcc \ | ||
| git \ | ||
| make \ | ||
| ${INSTALL_PACKAGES} | ||
| SHELL | ||
| end | ||
|
|
||
| # AlmaLinux does not have /usr/local/{bin,sbin} in the PATH by default | ||
| config.vm.provision "setup-etc-environment", type: "shell", run: "once" do |sh| | ||
| sh.upload_path = "/tmp/vagrant-setup-etc-environment" | ||
| sh.inline = <<~SHELL | ||
| #!/usr/bin/env bash | ||
| set -eux -o pipefail | ||
| cat >> /etc/environment <<EOF | ||
| PATH=/usr/local/go/bin:/usr/local/bin:/usr/local/sbin:$PATH | ||
| EOF | ||
| source /etc/environment | ||
| SHELL | ||
| end | ||
|
|
||
| # To re-run this provisioner, installing a different version of go: | ||
| # GO_VERSION="1.14.6" vagrant up --provision-with=install-golang | ||
| # | ||
| config.vm.provision "install-golang", type: "shell", run: "once" do |sh| | ||
| sh.upload_path = "/tmp/vagrant-install-golang" | ||
| sh.env = { | ||
| 'GO_VERSION': ENV['GO_VERSION'] || "1.24.3", | ||
| } | ||
| sh.inline = <<~SHELL | ||
| #!/usr/bin/env bash | ||
| set -eux -o pipefail | ||
| curl -fsSL "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" | tar Cxz /usr/local | ||
| cat >> /etc/profile.d/sh.local <<EOF | ||
| GOPATH=\\$HOME/go | ||
| PATH=\\$GOPATH/bin:\\$PATH | ||
| export GOPATH PATH | ||
| git config --global --add safe.directory /vagrant | ||
| EOF | ||
| source /etc/profile.d/sh.local | ||
| SHELL | ||
| end | ||
|
|
||
| config.vm.provision "setup-gopath", type: "shell", run: "once" do |sh| | ||
| sh.upload_path = "/tmp/vagrant-setup-gopath" | ||
| sh.inline = <<~SHELL | ||
| #!/usr/bin/env bash | ||
| source /etc/environment | ||
| source /etc/profile.d/sh.local | ||
| set -eux -o pipefail | ||
| mkdir -p ${GOPATH}/src/github.com/containerd | ||
| ln -fnsv /vagrant ${GOPATH}/src/github.com/containerd/cgroups | ||
| SHELL | ||
| end | ||
|
|
||
| config.vm.provision "test", type: "shell", run: "never" do |sh| | ||
| sh.upload_path = "/tmp/test" | ||
| sh.env = { | ||
| 'GOTEST': ENV['GOTEST'] || "go test", | ||
| 'GOTESTSUM_JUNITFILE': ENV['GOTESTSUM_JUNITFILE'], | ||
| 'GOTESTSUM_JSONFILE': ENV['GOTESTSUM_JSONFILE'], | ||
| } | ||
| sh.inline = <<~SHELL | ||
| #!/usr/bin/env bash | ||
| source /etc/environment | ||
| source /etc/profile.d/sh.local | ||
| set -eux -o pipefail | ||
| cd ${GOPATH}/src/github.com/containerd/cgroups | ||
| go env -w CGO_ENABLED=1 | ||
| go test -exec "sudo" -v -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
| SHELL | ||
| end | ||
|
|
||
| config.vm.provision "build-cgctl", type: "shell", run: "never" do |sh| | ||
| sh.upload_path = "/tmp/build-cgctl" | ||
| sh.inline = <<~SHELL | ||
| #!/usr/bin/env bash | ||
| source /etc/environment | ||
| source /etc/profile.d/sh.local | ||
| set -eux -o pipefail | ||
| cd ${GOPATH}/src/github.com/containerd/cgroups | ||
| make all | ||
| SHELL | ||
| end | ||
| end |
This file contains hidden or 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,42 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Copyright The containerd Authors. | ||
|
|
||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
|
|
||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| set -eu -o pipefail | ||
|
|
||
| # Rocky Linux doesn't have growpart by default. | ||
| (growpart -h > /dev/null) || dnf -y install cloud-utils-growpart | ||
|
|
||
| df_line=$(df -T / | grep '^/dev/') | ||
| if [[ "$df_line" =~ ^/dev/([a-z]+)([0-9]+) ]]; then | ||
| dev="${BASH_REMATCH[1]}" | ||
| part="${BASH_REMATCH[2]}" | ||
| growpart "/dev/$dev" "$part" | ||
|
|
||
| fstype=$(echo "$df_line" | awk '{print $2}') | ||
| if [[ "$fstype" = 'btrfs' ]]; then | ||
| btrfs filesystem resize max / | ||
| elif [[ "$fstype" = 'xfs' ]]; then | ||
| xfs_growfs -d / | ||
| else | ||
| echo "Unknown filesystem: $df_line" | ||
| exit 1 | ||
| fi | ||
| elif [[ "$df_line" =~ ^/dev/mapper/ ]]; then | ||
| echo "TODO: support device mapper: $df_line" | ||
| else | ||
| echo "Failed to parse: $df_line" | ||
| exit 1 | ||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex used to parse the device name may not match commonly used device names like /dev/nvme0n1p1 that include numbers in the device portion. Consider updating the regex to something like ^/dev/([a-z0-9]+)([0-9]+)$ to better support a broader range of device names.