Skip to content

Commit 8f749a5

Browse files
committed
enable test handler for containerd runtime
1 parent 419b93b commit 8f749a5

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ gcs-publish-ci: gsutil version-dist-ci
266266
@echo "== Uploading kops =="
267267
gsutil -h "Cache-Control:private, max-age=0, no-transform" -m cp -n -r ${UPLOAD}/kops/* ${GCS_LOCATION}
268268
echo "VERSION: ${VERSION}"
269-
echo "${GCS_URL}/${VERSION}" > ${UPLOAD}/${LATEST_FILE}
269+
echo "${GCS_URL}${VERSION}" > ${UPLOAD}/${LATEST_FILE}
270270
gsutil -h "Cache-Control:private, max-age=0, no-transform" cp ${UPLOAD}/${LATEST_FILE} ${GCS_LOCATION}
271271

272272
.PHONY: gen-cli-docs

tests/e2e/kubetest2-kops/deployer/common.go

-10
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ import (
2020
"errors"
2121
"fmt"
2222
"os"
23-
"path"
2423
"path/filepath"
2524
"strings"
2625
"time"
2726

2827
"k8s.io/klog/v2"
2928
"k8s.io/kops/tests/e2e/kubetest2-kops/gce"
30-
"k8s.io/kops/tests/e2e/pkg/kops"
3129
"k8s.io/kops/tests/e2e/pkg/target"
3230
"k8s.io/kops/tests/e2e/pkg/util"
3331
"sigs.k8s.io/kubetest2/pkg/boskos"
@@ -51,14 +49,6 @@ func (d *deployer) initialize() error {
5149
return fmt.Errorf("init failed to check up flags: %v", err)
5250
}
5351
}
54-
if d.KopsVersionMarker != "" {
55-
d.KopsBinaryPath = path.Join(d.commonOptions.RunDir(), "kops")
56-
baseURL, err := kops.DownloadKops(d.KopsVersionMarker, d.KopsBinaryPath)
57-
if err != nil {
58-
return fmt.Errorf("init failed to download kops from url: %v", err)
59-
}
60-
d.KopsBaseURL = baseURL
61-
}
6252

6353
switch d.CloudProvider {
6454
case "aws":

tests/e2e/kubetest2-kops/deployer/up.go

+13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"errors"
2121
"fmt"
2222
osexec "os/exec"
23+
"path"
2324
"strings"
2425
"time"
2526

@@ -41,6 +42,17 @@ func (d *deployer) Up() error {
4142
return err
4243
}
4344

45+
// kops is fetched when --up is called instead of init to support a scenario where k/k is being built
46+
// and a kops build is not ready yet
47+
if d.KopsVersionMarker != "" {
48+
d.KopsBinaryPath = path.Join(d.commonOptions.RunDir(), "kops")
49+
baseURL, err := kops.DownloadKops(d.KopsVersionMarker, d.KopsBinaryPath)
50+
if err != nil {
51+
return fmt.Errorf("init failed to download kops from url: %v", err)
52+
}
53+
d.KopsBaseURL = baseURL
54+
}
55+
4456
if d.terraform == nil {
4557
klog.Info("Cleaning up any leaked resources from previous cluster")
4658
// Intentionally ignore errors:
@@ -118,6 +130,7 @@ func (d *deployer) createCluster(zones []string, adminAccess string, yes bool) e
118130
"--kubernetes-version", d.KubernetesVersion,
119131
"--ssh-public-key", d.SSHPublicKeyPath,
120132
"--set", "cluster.spec.nodePortAccess=0.0.0.0/0",
133+
"--set", `spec.containerd.configAdditions="plugins.""io.containerd.grpc.v1.cri"".containerd.runtimes.test-handler.runtime_type=""io.containerd.runc.v2"""`,
121134
}
122135
if yes {
123136
args = append(args, "--yes")

tests/e2e/pkg/kops/state.go

+23
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"k8s.io/klog/v2"
2727
api "k8s.io/kops/pkg/apis/kops/v1alpha2"
28+
"k8s.io/kops/pkg/cloudinstances"
2829
"sigs.k8s.io/kubetest2/pkg/exec"
2930
)
3031

@@ -61,6 +62,28 @@ func GetCluster(kopsBinary, clusterName string, env []string) (*api.Cluster, err
6162
return cluster, nil
6263
}
6364

65+
// GetCluster will retrieve the specified Cluster from the state store.
66+
func GetInstances(kopsBinary, clusterName string, env []string) ([]*cloudinstances.CloudInstance, error) {
67+
args := []string{
68+
kopsBinary, "get", "instances", "--name", clusterName, "-ojson",
69+
}
70+
c := exec.Command(args[0], args[1:]...)
71+
c.SetEnv(env...)
72+
var stdout bytes.Buffer
73+
c.SetStdout(&stdout)
74+
var stderr bytes.Buffer
75+
c.SetStderr(&stderr)
76+
if err := c.Run(); err != nil {
77+
klog.Warningf("failed to run %s; stderr=%s", strings.Join(args, " "), stderr.String())
78+
return nil, fmt.Errorf("error querying instances from %s: %w", strings.Join(args, " "), err)
79+
}
80+
var instances []*cloudinstances.CloudInstance
81+
if err := json.Unmarshal(stdout.Bytes(), &instances); err != nil {
82+
return nil, fmt.Errorf("error parsing instance groups json: %w", err)
83+
}
84+
return instances, nil
85+
}
86+
6487
// GetInstanceGroups will retrieve the instance groups for the specified Cluster from the state store.
6588
func GetInstanceGroups(kopsBinary, clusterName string, env []string) ([]*api.InstanceGroup, error) {
6689
args := []string{

0 commit comments

Comments
 (0)