mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 02:11:09 +00:00
Hostprocess container test updates
Signed-off-by: Mark Rossetti <marosset@microsoft.com>
This commit is contained in:
parent
f3d90aef8d
commit
85e4dd2d48
@ -19,10 +19,12 @@ package windows
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/onsi/gomega"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/onsi/gomega"
|
||||||
|
|
||||||
|
semver "github.com/blang/semver/v4"
|
||||||
"github.com/onsi/ginkgo/v2"
|
"github.com/onsi/ginkgo/v2"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -196,6 +198,29 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
|
|||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("container command path validation", func() {
|
ginkgo.It("container command path validation", func() {
|
||||||
|
|
||||||
|
// The way hostprocess containers are created is being updated in container
|
||||||
|
// v1.7 to better support volume mounts and part of these changes include
|
||||||
|
// updates how the container's starting process is invoked.
|
||||||
|
// These test cases are only valid for containerd v1.6.
|
||||||
|
// See https://github.com/kubernetes/enhancements/blob/master/keps/sig-windows/1981-windows-privileged-container-support/README.md
|
||||||
|
// for more details.
|
||||||
|
ginkgo.By("Ensuring Windows nodes are running containerd v1.6.x")
|
||||||
|
windowsNode, err := findWindowsNode(f)
|
||||||
|
framework.ExpectNoError(err, "error finding Windows node")
|
||||||
|
r, v, err := getNodeContainerRuntimeAndVersion(windowsNode)
|
||||||
|
framework.ExpectNoError(err, "error getting node container runtime and version")
|
||||||
|
framework.Logf("Got runtime: %s, version %v, node: %s", r, v, windowsNode.Name)
|
||||||
|
|
||||||
|
if !strings.EqualFold(r, "containerd") {
|
||||||
|
e2eskipper.Skipf("container runtime is not containerd")
|
||||||
|
}
|
||||||
|
|
||||||
|
v1dot7 := semver.MustParse("1.7.0")
|
||||||
|
if v.GTE(v1dot7) {
|
||||||
|
e2eskipper.Skipf("container runtime is >= 1.7.0")
|
||||||
|
}
|
||||||
|
|
||||||
// The following test cases are broken into batches to speed up the test.
|
// The following test cases are broken into batches to speed up the test.
|
||||||
// Each batch will be scheduled as a single pod with a container for each test case.
|
// Each batch will be scheduled as a single pod with a container for each test case.
|
||||||
// Pods will be scheduled sequentially since the start-up cost of containers is high
|
// Pods will be scheduled sequentially since the start-up cost of containers is high
|
||||||
|
@ -17,13 +17,18 @@ limitations under the License.
|
|||||||
package windows
|
package windows
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/kubernetes/pkg/controller/deployment/util"
|
"k8s.io/kubernetes/pkg/controller/deployment/util"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
|
|
||||||
|
semver "github.com/blang/semver/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// waits for a deployment to be created and the desired replicas
|
// waits for a deployment to be created and the desired replicas
|
||||||
@ -44,3 +49,20 @@ func waitForDeployment(getDeploymentFunc func() (*appsv1.Deployment, error), int
|
|||||||
return util.DeploymentComplete(deployment, &deployment.Status), nil
|
return util.DeploymentComplete(deployment, &deployment.Status), nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gets the container runtime and version for a node
|
||||||
|
func getNodeContainerRuntimeAndVersion(n v1.Node) (string, semver.Version, error) {
|
||||||
|
containerRuntimeVersionString := n.Status.NodeInfo.DeepCopy().ContainerRuntimeVersion
|
||||||
|
parts := strings.Split(containerRuntimeVersionString, "://")
|
||||||
|
|
||||||
|
if len(parts) != 2 {
|
||||||
|
return "", semver.Version{}, fmt.Errorf("could not get container runtime and version from '%s'", containerRuntimeVersionString)
|
||||||
|
}
|
||||||
|
|
||||||
|
v, err := semver.ParseTolerant(parts[1])
|
||||||
|
if err != nil {
|
||||||
|
return "", semver.Version{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts[0], v, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user