From 851c71a00dc09250aafe39f3f28a741fee8ea944 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Wed, 12 May 2021 08:02:09 -0700 Subject: [PATCH] feat: Add support for custom runc deb URL (#4403) This helps enable testing new runc packages on aks-engine clusters. Signed-off-by: Brian Goff --- parts/k8s/cloud-init/artifacts/cse_main.sh | 8 ++++++++ pkg/api/converterfromapi.go | 1 + pkg/api/convertertoapi.go | 1 + pkg/api/types.go | 1 + pkg/api/vlabs/types.go | 1 + pkg/engine/template_generator.go | 6 ++++++ pkg/engine/template_generator_test.go | 14 ++++++++++++++ pkg/engine/templates_generated.go | 8 ++++++++ test/e2e/cluster.sh | 1 + test/e2e/engine/template.go | 6 +++++- 10 files changed, 46 insertions(+), 1 deletion(-) diff --git a/parts/k8s/cloud-init/artifacts/cse_main.sh b/parts/k8s/cloud-init/artifacts/cse_main.sh index ca63fc6e11..34e459049b 100755 --- a/parts/k8s/cloud-init/artifacts/cse_main.sh +++ b/parts/k8s/cloud-init/artifacts/cse_main.sh @@ -126,6 +126,14 @@ time_metric "installRunc" installRunc dpkg_install 20 30 /tmp/${DEB} || exit {{GetCSEErrorCode "ERR_DEB_PKG_ADD_FAIL"}} fi {{end}} +{{- if HasLinuxRuncURL}} + LINUX_RUNC_URL={{GetLinuxRuncURL}} + if [[ -n "${LINUX_RUNC_URL:-}" ]]; then + DEB="${LINUX_RUNC_URL##*/}" + retrycmd_no_stats 120 5 25 curl -fsSL ${LINUX_RUNC_URL} >/tmp/${DEB} || exit {{GetCSEErrorCode "ERR_DEB_DOWNLOAD_TIMEOUT"}} + dpkg_install 20 30 /tmp/${DEB} || exit {{GetCSEErrorCode "ERR_DEB_PKG_ADD_FAIL"}} + fi +{{end}} fi if [[ -n ${MASTER_NODE} ]] && [[ -z ${COSMOS_URI} ]]; then diff --git a/pkg/api/converterfromapi.go b/pkg/api/converterfromapi.go index b029cb819d..9dfcf2abb3 100644 --- a/pkg/api/converterfromapi.go +++ b/pkg/api/converterfromapi.go @@ -255,6 +255,7 @@ func convertKubernetesConfigToVLabs(apiCfg *KubernetesConfig, vlabsCfg *vlabs.Ku vlabsCfg.DockerBridgeSubnet = apiCfg.DockerBridgeSubnet vlabsCfg.MobyVersion = apiCfg.MobyVersion vlabsCfg.LinuxMobyURL = apiCfg.LinuxMobyURL + vlabsCfg.LinuxRuncURL = apiCfg.LinuxRuncURL vlabsCfg.ContainerdVersion = apiCfg.ContainerdVersion vlabsCfg.LinuxContainerdURL = apiCfg.LinuxContainerdURL vlabsCfg.CloudProviderBackoff = apiCfg.CloudProviderBackoff diff --git a/pkg/api/convertertoapi.go b/pkg/api/convertertoapi.go index 1f5cb3c329..ede29e5eca 100644 --- a/pkg/api/convertertoapi.go +++ b/pkg/api/convertertoapi.go @@ -262,6 +262,7 @@ func convertVLabsKubernetesConfig(vlabs *vlabs.KubernetesConfig, api *Kubernetes api.DockerBridgeSubnet = vlabs.DockerBridgeSubnet api.MobyVersion = vlabs.MobyVersion api.LinuxMobyURL = vlabs.LinuxMobyURL + api.LinuxRuncURL = vlabs.LinuxRuncURL api.ContainerdVersion = vlabs.ContainerdVersion api.LinuxContainerdURL = vlabs.LinuxContainerdURL api.CloudProviderBackoff = vlabs.CloudProviderBackoff diff --git a/pkg/api/types.go b/pkg/api/types.go index 2079779b3d..4485139ccd 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -412,6 +412,7 @@ type KubernetesConfig struct { DockerEngineVersion string `json:"dockerEngineVersion,omitempty"` // Deprecated MobyVersion string `json:"mobyVersion,omitempty"` LinuxMobyURL string `json:"linuxMobyURL,omitempty"` + LinuxRuncURL string `json:"linuxRuncURL,omitempty"` ContainerdVersion string `json:"containerdVersion,omitempty"` LinuxContainerdURL string `json:"linuxContainerdURL,omitempty"` CustomCcmImage string `json:"customCcmImage,omitempty"` // Image for cloud-controller-manager diff --git a/pkg/api/vlabs/types.go b/pkg/api/vlabs/types.go index 0086e495d8..388e892548 100644 --- a/pkg/api/vlabs/types.go +++ b/pkg/api/vlabs/types.go @@ -349,6 +349,7 @@ type KubernetesConfig struct { DockerEngineVersion string `json:"dockerEngineVersion,omitempty"` // Deprecated MobyVersion string `json:"mobyVersion,omitempty"` LinuxMobyURL string `json:"linuxMobyURL,omitempty"` + LinuxRuncURL string `json:"linuxRuncURL,omitempty"` ContainerdVersion string `json:"containerdVersion,omitempty"` LinuxContainerdURL string `json:"linuxContainerdURL,omitempty"` CustomCcmImage string `json:"customCcmImage,omitempty"` diff --git a/pkg/engine/template_generator.go b/pkg/engine/template_generator.go index 5dc05cf0fa..83b8e27491 100644 --- a/pkg/engine/template_generator.go +++ b/pkg/engine/template_generator.go @@ -603,6 +603,12 @@ func getContainerServiceFuncMap(cs *api.ContainerService) template.FuncMap { "GetLinuxContainerdURL": func() string { return cs.Properties.OrchestratorProfile.KubernetesConfig.LinuxContainerdURL }, + "HasLinuxRuncURL": func() bool { + return cs.Properties.OrchestratorProfile.KubernetesConfig.LinuxRuncURL != "" + }, + "GetLinuxRuncURL": func() string { + return cs.Properties.OrchestratorProfile.KubernetesConfig.LinuxRuncURL + }, "IsDockerContainerRuntime": func() bool { return cs.Properties.OrchestratorProfile.KubernetesConfig.ContainerRuntime == api.Docker }, diff --git a/pkg/engine/template_generator_test.go b/pkg/engine/template_generator_test.go index ef3d9e0992..8fbf54ffc7 100644 --- a/pkg/engine/template_generator_test.go +++ b/pkg/engine/template_generator_test.go @@ -103,6 +103,8 @@ func TestGetTemplateFuncMap(t *testing.T) { "GetLinuxContainerdURL", "HasLinuxMobyURL", "GetLinuxMobyURL", + "HasLinuxRuncURL", + "GetLinuxRuncURL", // TODO validate that the remaining func strings in getTemplateFuncMap are thinly wrapped and unit tested } @@ -161,6 +163,18 @@ func TestGetTemplateFuncMap(t *testing.T) { if ret[0].Interface() != "" { t.Fatalf("Got unexpected GetLinuxMobyURL response") } + case "HasLinuxRuncURL": + rargs := make([]reflect.Value, 0) + ret := v.Call(rargs) + if ret[0].Interface() != false { + t.Fatalf("Got unexpected HasLinuxRuncURL response") + } + case "GetinuxRuncURL": + rargs := make([]reflect.Value, 0) + ret := v.Call(rargs) + if ret[0].Interface() != "" { + t.Fatalf("Got unexpected GetLinuxRuncURL response") + } } } } diff --git a/pkg/engine/templates_generated.go b/pkg/engine/templates_generated.go index dfc6f251ac..45d2bb7b68 100644 --- a/pkg/engine/templates_generated.go +++ b/pkg/engine/templates_generated.go @@ -13382,6 +13382,14 @@ time_metric "installRunc" installRunc dpkg_install 20 30 /tmp/${DEB} || exit {{GetCSEErrorCode "ERR_DEB_PKG_ADD_FAIL"}} fi {{end}} +{{- if HasLinuxRuncURL}} + LINUX_RUNC_URL={{GetLinuxRuncURL}} + if [[ -n "${LINUX_RUNC_URL:-}" ]]; then + DEB="${LINUX_RUNC_URL##*/}" + retrycmd_no_stats 120 5 25 curl -fsSL ${LINUX_RUNC_URL} >/tmp/${DEB} || exit {{GetCSEErrorCode "ERR_DEB_DOWNLOAD_TIMEOUT"}} + dpkg_install 20 30 /tmp/${DEB} || exit {{GetCSEErrorCode "ERR_DEB_PKG_ADD_FAIL"}} + fi +{{end}} fi if [[ -n ${MASTER_NODE} ]] && [[ -z ${COSMOS_URI} ]]; then diff --git a/test/e2e/cluster.sh b/test/e2e/cluster.sh index aa60b8f196..56244b4c87 100755 --- a/test/e2e/cluster.sh +++ b/test/e2e/cluster.sh @@ -239,6 +239,7 @@ docker run --rm \ -e LINUX_CONTAINERD_URL=${LINUX_CONTAINERD_URL} \ -e WINDOWS_CONTAINERD_URL=${WINDOWS_CONTAINERD_URL} \ -e LINUX_MOBY_URL=${LINUX_MOBY_URL} \ +-e LINUX_RUNC_URL=${LINUX_RUNC_URL} \ -e VALIDATE_CPU_LOAD=${VALIDATE_CPU_LOAD} \ -e RUN_VMSS_NODE_PROTOTYPE=${RUN_VMSS_NODE_PROTOTYPE} \ -e KAMINO_VMSS_PROTOTYPE_LOCAL_CHART_PATH=${KAMINO_VMSS_PROTOTYPE_LOCAL_CHART_PATH} \ diff --git a/test/e2e/engine/template.go b/test/e2e/engine/template.go index ea31cc9dc0..ff6c402246 100644 --- a/test/e2e/engine/template.go +++ b/test/e2e/engine/template.go @@ -77,6 +77,7 @@ type Config struct { LinuxContainerdURL string `envconfig:"LINUX_CONTAINERD_URL"` WindowsContainerdURL string `envconfig:"WINDOWS_CONTAINERD_URL"` LinuxMobyURL string `envconfig:"LINUX_MOBY_URL"` + LinuxRuncURL string `envconfig:"LINUX_RUNC_URL"` WindowsProvisioningScriptsURL string `envconfig:"WINDOWS_PROVISIONING_SCRIPTS_URL" default:""` ArcClientID string `envconfig:"ARC_CLIENT_ID" default:""` ArcClientSecret string `envconfig:"ARC_CLIENT_SECRET" default:""` @@ -251,7 +252,7 @@ func Build(cfg *config.Config, masterSubnetID string, agentSubnetIDs []string, i } } } - + if config.ContainerRuntime != "" { prop.OrchestratorProfile.KubernetesConfig.ContainerRuntime = config.ContainerRuntime } @@ -444,6 +445,9 @@ func Build(cfg *config.Config, masterSubnetID string, agentSubnetIDs []string, i if config.LinuxMobyURL != "" { prop.OrchestratorProfile.KubernetesConfig.LinuxMobyURL = config.LinuxMobyURL } + if config.LinuxRuncURL != "" { + prop.OrchestratorProfile.KubernetesConfig.LinuxRuncURL = config.LinuxRuncURL + } if config.Eth0MTU != 0 { if prop.LinuxProfile == nil {