Commit Graph

43 Commits

Author SHA1 Message Date
Qiutong Song
4196fad027 Add integration tests with failpoint
Signed-off-by: Qiutong Song <songqt01@gmail.com>
2022-09-27 14:45:18 +00:00
Derek McGowan
6acde90772
Merge pull request #7069 from fuweid/failpoint-in-runc-shimv2
test: introduce failpoint control to runc-shimv2 and cni
2022-07-26 23:12:20 -07:00
Maksym Pavlenko
2b92c70fa4 Fix command line parsing for image list
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-07-25 14:19:40 -07:00
Maksym Pavlenko
552d763447 Use image lists in client tests
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-07-25 10:47:00 -07:00
Wei Fu
3c5e80b63e integration: Add injected failpoint testing for RunPodSandbox
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-22 23:25:40 +08:00
Daniel Canter
44e12dc5d8 Windows snapshotter touch ups and new functionality
This change does a couple things to remove some cruft/unused functionality
in the Windows snapshotter, as well as add a way to specify the rootfs
size in bytes for a Windows container via a new field added in the CRI api in
k8s 1.24. Setting the rootfs/scratch volume size was assumed to be working
prior to this but turns out not to be the case.

Previously I'd added a change to pass any annotations in the containerd
snapshot form (containerd.io/snapshot/*) as labels for the containers
rootfs snapshot. This was added as a means for a client to be able to provide
containerd.io/snapshot/io.microsoft.container.storage.rootfs.size-gb as an
annotation and have that be translated to a label and ultimately set the
size for the scratch volume in Windows. However, this actually only worked if
interfacing with the CRI api directly (crictl) as Kubernetes itself will
fail to validate annotations that if split by "/" end up with > 2 parts,
which the snapshot labels will (containerd.io / snapshot / foobarbaz).

With this in mind, passing the annotations and filtering to
containerd.io/snapshot/* is moot, so I've removed this code in favor of
a new `snapshotterOpts()` function that will return platform specific
snapshotter options if ones exist. Now on Windows we can just check if
RootfsSizeInBytes is set on the WindowsContainerResources struct and
then return a snapshotter option that sets the right label.

So all in all this change:
- Gets rid of code to pass CRI annotations as labels down to snapshotters.

- Gets rid of the functionality to create a 1GB sized scratch disk if
the client provided a size < 20GB. This code is not used currently and
has a few logical shortcomings as it won't be able to create the disk
if a container is already running and using the same base layer. WCIFS
(driver that handles the unioning of windows container layers together)
holds open handles to some files that we need to delete to create the
1GB scratch disk is the underlying problem.

- Deprecates the containerd.io/snapshot/io.microsoft.container.storage.rootfs.size-gb
label in favor of a new containerd.io/snapshot/windows/rootfs.sizebytes label.
The previous label/annotation wasn't being used by us, and from a cursory
github search wasn't being used by anyone else either. Now that there is a CRI
field to specify the size, this should just be a field that users can set
on their pod specs and don't need to concern themselves with what it eventually
gets translated to, but non-CRI clients can still use the new label/deprecated
label as usual.

- Add test to cri integration suite to validate expanding the rootfs size.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2022-06-06 14:57:07 -07:00
Daniel Canter
978ff393d2 Add validations for Windows HostProcess CRI configs
HostProcess containers require every container in the pod to be a
host process container and have the corresponding field set. The Kubelet
usually enforces this so we'd error before even getting here but we recently
found a bug in this logic so better to be safe than sorry.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2022-05-27 21:17:07 -07:00
Kazuyoshi Kato
2ca54ee8ae
Merge pull request #6180 from claudiubelu/integration/windows-ip-leak
integration: Adds Windows equivalent for TestSandboxRemoveWithoutIPLeakage
2022-04-25 11:27:31 -07:00
Paul "TBBle" Hampson
6a25be94e9 CRI integration test for Windows Device mounts
This test takes advantage of the fact that when you tell Windows to
mount the GUID_DEVINTERFACE_DISPLAY_ADAPTER class, it will also mount
the host's device store into the container, even if there is no real GPU
on the host.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2022-03-12 08:16:43 +11:00
Shengjing Zhu
f1f69d4eeb integration: remove duplicated util pkg
Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2022-02-28 20:36:01 +08:00
haoyun
bbe46b8c43 feat: replace github.com/pkg/errors to errors
Signed-off-by: haoyun <yun.hao@daocloud.io>
Co-authored-by: zounengren <zouyee1989@gmail.com>
2022-01-07 10:27:03 +08:00
Claudiu Belu
894af07e37 integration: Adds Windows equivalent for TestSandboxRemoveWithoutIPLeakage
Adds an equivalent TestSandboxRemoveWithoutIPLeakage for Windows, in which
we assert that the IPs are not leaked when a Pod's HNS namespace dissapears
and the Pod is deleted afterwards.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
2022-01-03 00:26:47 -08:00
Gabriel Adrian Samfira
0ff87a8929
Replace tskill with taskkill
This offers a more reliable way of killing a process. The /IM flag
allows us to specify the "image name" of the process we're killing.
This means we can use wildcards, foce kill a process and all the child
processes it may have spawned.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2021-12-20 18:33:36 +02:00
Kazuyoshi Kato
2ee3ce510c Use insecure.NewCredentials instead of grpc.WithInsecure
grpc.WithInsecure is being deprecated.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-12-16 23:10:06 +00:00
Derek McGowan
60ffa3ff7d
Merge pull request #5579 from claudiubelu/integration/restart-containerd
integration: Enables Windows containerd restart test
2021-10-08 10:33:10 -07:00
haoyun
d16942cf16 feat: enable cri remote client to call with grpc calloptions
Signed-off-by: haoyun <yun.hao@daocloud.io>
2021-09-30 23:02:53 +08:00
Phil Estes
5162238c7d
Merge pull request #5853 from claudiubelu/integration/windows-hostprocess
integration: Adds Windows HostProcess tests
2021-09-26 20:35:00 -04:00
Claudiu Belu
f42513112f integration: Adds Windows HostProcess tests
Windows HostProcess containers can run containerized workloads on a Windows host.
These containers operate as normal processes but have access to the host network
namespace, storage, and devices when given the appropriate user privileges.

HostProcess containers support the ability to run as one of the following Windows
service accounts: LocalSystem, LocalService, NetworkService.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
2021-09-07 00:30:28 -07:00
Claudiu Belu
abf4de4985 integration: Enables Windows containerd restart test
The test sets container's Linux.SecurityContext.NamespaceOptions.Pid = NamespaceMode_CONTAINER,
which will ensure that the container keeps running even if the sandbox container dies. We do
not have that option on Windows.

Adds additional logging in the test, so it is easier to figure out which assertion failed.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
2021-09-04 13:52:33 -07:00
Sebastiaan van Stijn
2ac9968401
replace uses of os/exec with golang.org/x/sys/execabs
Go 1.15.7 contained a security fix for CVE-2021-3115, which allowed arbitrary
code to be executed at build time when using cgo on Windows. This issue also
affects Unix users who have “.” listed explicitly in their PATH and are running
“go get” outside of a module or with module mode disabled.

This issue is not limited to the go command itself, and can also affect binaries
that use `os.Command`, `os.LookPath`, etc.

From the related blogpost (ttps://blog.golang.org/path-security):

> Are your own programs affected?
>
> If you use exec.LookPath or exec.Command in your own programs, you only need to
> be concerned if you (or your users) run your program in a directory with untrusted
> contents. If so, then a subprocess could be started using an executable from dot
> instead of from a system directory. (Again, using an executable from dot happens
> always on Windows and only with uncommon PATH settings on Unix.)
>
> If you are concerned, then we’ve published the more restricted variant of os/exec
> as golang.org/x/sys/execabs. You can use it in your program by simply replacing

This patch replaces all uses of `os/exec` with `golang.org/x/sys/execabs`. While
some uses of `os/exec` should not be problematic (e.g. part of tests), it is
probably good to be consistent, in case code gets moved around.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-25 18:11:09 +02:00
Phil Estes
cf600abecc
Merge pull request #5619 from mikebrow/cri-add-v1-proxy-alpha
[CRI] move up to CRI v1 and support v1alpha in parallel
2021-07-09 14:07:24 -04:00
Mike Brown
a5c417ac06 move up to CRI v1 and support v1alpha in parallel
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
2021-06-28 09:34:12 -05:00
Claudiu Belu
a78bdf22df tests: Refactors PodSandbox creation
Most of the tests creating and using Pod Sandboxes in the same way. We can create
a common function that will do that for us, so we can have less duplicated code,
and make it easier to add new tests in the future.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
2021-06-03 16:02:38 +00:00
Claudiu Belu
93e268f625 tests: Symlink volume tests
There was a known issue regarding how the symlink files mounted as
volumes were being handled on Windows. This commit adds tests that
will check against those issue to ensure there won't be any
regressions.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
2021-06-03 13:26:22 +00:00
Claudiu Belu
09a0c9471b tests: Adds support for Windows cri-integration tests
Currently, the cri-integration tests do not work on Windows due to various reasons.
One of the reasons is because all the tests are using Linux-specific images.
Previous commits refactored the image pulling / usage in the cri-integration tests,
making it easier to update, and easier to configure a custom registry to pull images
with Windows support.

For Windows runs, custom registries can be created, which will also contain Windows
images, and the cri-integration tests can be configured to use those registries by
specifying the "--repo-list" argument, a YAML file which will contain an alternative
mapping of the default registries. This is similar to how E2E tests are handled for
Windows runs in Kubernetes.

Some of the tests are Skipped, as they do not pass yet on Windows.

Windows does not collect inodes used stats, thus, the tests that were expecting non-zero
inodes stats were failing.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
2021-05-14 11:27:35 +00:00
Claudiu Belu
5847340a7d tests: Refactors container image usage
Currently, the cri-integration tests do not work on Windows due to various reasons.
One of the reasons is because all the tests are using Linux-specific images. This
commit refactors the image pulling / usage in the cri-integration tests, making it
easier to update, and easier to configure the a custom registry to pull those images
from.

For Windows runs, custom registries can be created, which will also contain Windows
images, and the cri-integration tests can be configured to use those registries by
specifying the "--image-list" argument, a TOML file which will contain an alternative
mapping of the default images.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
2021-04-27 08:44:21 +00:00
pacoxu
ffff688663 upgrade pause image to 3.5 for non-root
Signed-off-by: pacoxu <paco.xu@daocloud.io>
2021-03-16 23:20:35 +08:00
Iceber Gu
f37ae8fc35
move to v3.4.1 for the pause image
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-03-07 15:21:20 +08:00
Mike Brown
c876b15b54 getting cri integration up and running
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
2020-10-19 10:02:05 -05:00
Maksym Pavlenko
3d02441a79 Refactor pkg packages
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2020-10-08 17:30:17 -07:00
Maksym Pavlenko
3508ddd3dd Refactor CRI packages
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2020-10-07 14:45:57 -07:00
Derek McGowan
b22b627300
Move cri server packages under pkg/cri
Organizes the cri related server packages under pkg/cri

Signed-off-by: Derek McGowan <derek@mcg.dev>
2020-10-07 13:09:37 -07:00
Derek McGowan
1c60ae7f87
Use local version of cri packages
Signed-off-by: Derek McGowan <derek@mcg.dev>
2020-10-07 10:59:40 -07:00
Derek McGowan
07c98d0bf1 Fix lint in Unix environments
Signed-off-by: Derek McGowan <derek@mcg.dev>
2020-10-05 17:46:01 -07:00
Derek McGowan
77cf032195 Enable golangci on Windows
Signed-off-by: Derek McGowan <derek@mcg.dev>
2020-10-01 09:01:16 -07:00
Derek McGowan
a3c0e8859c Align lint checks with containerd
Signed-off-by: Derek McGowan <derek@mcg.dev>
2020-09-30 23:17:46 -07:00
Davanum Srinivas
6007c354a6
Copy kubernetes/pkg/kubelet/util
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-06-22 14:48:25 -04:00
Davanum Srinivas
bb828a9f84
Make copy of pkg/kubelet/cri/remote
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-06-22 14:00:08 -04:00
Davanum Srinivas
41f184f15b
Update vendor.conf to kubernetes 1.19.0-beta.2
update streaming import path
switch remote package path

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-06-22 08:44:49 -04:00
Mike Brown
1b60224e2e use containerd/project header test
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
2020-04-22 19:35:37 -05:00
Sebastiaan van Stijn
a3e7f68fa5
vendor: update kubernetes v1.18.0-beta.1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-06 16:18:37 +01:00
Mike Brown
c9ed98462d move to v3.2 for the pause image
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
2020-02-14 12:55:52 -06:00
Lantao Liu
2a9a982ae3 Fix integration test for golang 1.13
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-10-09 10:51:02 -07:00