Skip to content

Commit

Permalink
chore(system-tests-k8s): containerDisk poc (#3481)
Browse files Browse the repository at this point in the history
**Enhancing Config Disk Logic for Improved Performance**

This PR replaces the existing
[CDI](https://kubevirt.io/user-guide/storage/containerized_data_importer/)
logic, where the configuration disk is pushed to a local S3 bucket and
imported via the CDI controller, with a new approach using
[containerDisk](https://kubevirt.io/user-guide/storage/disks_and_volumes/#containerdisk)
logic. The configuration disk is now wrapped as a container image,
pushed to a local container registry, and pulled by the container
runtime during VM creation.

This change is expected to provide better runtime performance and a more
streamlined setup, especially when running a large number of system
tests in parallel.

A cleaner implementation will follow once statistical data confirms a
significant improvement in performance with these changes. We anticipate
having runtime comparisons with FARM in the coming days to validate the
effectiveness of this approach.
  • Loading branch information
marko-k0 authored Jan 16, 2025
1 parent 1fdcec5 commit 96466fd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 57 deletions.
40 changes: 20 additions & 20 deletions rs/tests/driver/src/driver/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ use crate::driver::{
},
test_setup::InfraProvider,
};
use crate::k8s::datavolume::DataVolumeContentType;
use crate::k8s::images::*;
use crate::k8s::tnet::{TNet, TNode};
use crate::util::block_on;
use anyhow::{bail, Result};
Expand Down Expand Up @@ -286,25 +284,27 @@ pub fn setup_and_start_vms(
let conf_img_path = PathBuf::from(&node.node_path).join(CONF_IMG_FNAME);
match InfraProvider::read_attribute(&t_env) {
InfraProvider::K8s => {
let url = format!(
"{}/{}",
tnet_node.config_url.clone().expect("missing config_url"),
CONF_IMG_FNAME
// https://kubevirt.io/user-guide/storage/disks_and_volumes/#containerdisk
// build container disk that holds config fat disk for guestos
// push it to local container registry
let command = format!(
"set -xe; \
mkdir -p /var/sysimage/tnet; \
ctr=$(sudo buildah --root /var/sysimage/tnet from scratch); \
sudo buildah --root /var/sysimage/tnet copy --chown=107:107 $ctr {0} /disk/; \
sudo buildah --root /var/sysimage/tnet commit $ctr harbor-core.harbor.svc.cluster.local/tnet/config:{1}; \
sudo buildah --root /var/sysimage/tnet push --tls-verify=false --creds 'robot$tnet+tnet:TestingPOC1' harbor-core.harbor.svc.cluster.local/tnet/config:{1}",
conf_img_path.display(), tnet_node.name.clone().unwrap()
);
info!(
t_env.logger(),
"Uploading image {} to {}",
conf_img_path.clone().display().to_string(),
url.clone()
);
block_on(upload_image(conf_img_path.as_path(), &url))
.expect("Failed to upload config image");
block_on(tnet_node.deploy_config_image(
CONF_IMG_FNAME,
"config",
DataVolumeContentType::Kubevirt,
))
.expect("deploying config image failed");
let output = Command::new("bash")
.arg("-c")
.arg(command)
.output()
.expect("Failed to execute command");
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
bail!("Error building and pushing config container config image: {}", stderr);
}
block_on(tnet_node.start()).expect("starting vm failed");
}
InfraProvider::Farm => {
Expand Down
40 changes: 4 additions & 36 deletions rs/tests/driver/src/k8s/virtualmachine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spec:
domain:
cpu:
cores: {cpus}
model: host-passthrough
firmware:
bootloader:
efi:
Expand All @@ -47,23 +48,6 @@ spec:
- name: default
binding:
name: passt
ports:
- port: 22
- port: 8100
- port: 8101
- port: 8102
- port: 8103
- port: 8104
- port: 8105
- port: 8106
- port: 8107
- port: 8108
- port: 8109
- port: 8110
- port: 8111
- port: 8332
- port: 18444
- port: 20443
resources:
overcommitGuestOverhead: true
requests:
Expand Down Expand Up @@ -133,6 +117,7 @@ spec:
domain:
cpu:
cores: {cpus}
model: host-passthrough
firmware:
bootloader:
efi:
Expand All @@ -150,23 +135,6 @@ spec:
- name: default
binding:
name: passt
ports:
- port: 22
- port: 80
- port: 443
- port: 2497
- port: 4100
protocol: UDP
- port: 4444
- port: 7070
- port: 8080
- port: 8332
- port: 9090
- port: 9091
- port: 9100
- port: 18444
- port: 19100
- port: 19531
resources:
overcommitGuestOverhead: true
requests:
Expand All @@ -180,8 +148,8 @@ spec:
- dataVolume:
name: "{name}-guestos"
name: disk0
- dataVolume:
name: "{name}-config"
- containerDisk:
image: "harbor.ln1-idx1.dfinity.network/tnet/config:{name}"
name: disk1
"#;

Expand Down
8 changes: 7 additions & 1 deletion rs/tests/system_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ def system_test(
if uses_boundary_guestos:
icos_images["ENV_DEPS__BOUNDARY_GUESTOS_DISK_IMG_TAR_ZST_CAS_URL"] = "//ic-os/boundary-guestos/envs/dev:disk-img.tar.zst"

# set "local" tag for k8s system tests due to rootful container image builds
is_k8s = select({
"//rs/tests:k8s": True,
"//conditions:default": False,
})

run_system_test(
name = name,
src = test_driver_target,
Expand All @@ -284,7 +290,7 @@ def system_test(
env = env,
icos_images = icos_images,
env_inherit = env_inherit,
tags = tags + ["requires-network", "system_test"] +
tags = tags + ["requires-network", "system_test"] + (["local"] if is_k8s else []) +
(["manual"] if "experimental_system_test_colocation" in tags else []),
target_compatible_with = ["@platforms//os:linux"],
timeout = test_timeout,
Expand Down

0 comments on commit 96466fd

Please sign in to comment.