mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Merge pull request #128514 from hoskeri/shop-local-proxy-local
e2e_node: Pass e2eCriProxy instead of updating global.
This commit is contained in:
commit
74209418c4
@ -48,19 +48,19 @@ var _ = SIGDescribe(feature.CriProxy, framework.WithSerial(), func() {
|
|||||||
|
|
||||||
ginkgo.Context("Inject a pull image error exception into the CriProxy", func() {
|
ginkgo.Context("Inject a pull image error exception into the CriProxy", func() {
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
if err := resetCRIProxyInjector(); err != nil {
|
if err := resetCRIProxyInjector(e2eCriProxy); err != nil {
|
||||||
ginkgo.Skip("Skip the test since the CRI Proxy is undefined.")
|
ginkgo.Skip("Skip the test since the CRI Proxy is undefined.")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.AfterEach(func() {
|
ginkgo.AfterEach(func() {
|
||||||
err := resetCRIProxyInjector()
|
err := resetCRIProxyInjector(e2eCriProxy)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("Pod failed to start due to an image pull error.", func(ctx context.Context) {
|
ginkgo.It("Pod failed to start due to an image pull error.", func(ctx context.Context) {
|
||||||
expectedErr := fmt.Errorf("PullImage failed")
|
expectedErr := fmt.Errorf("PullImage failed")
|
||||||
err := addCRIProxyInjector(func(apiName string) error {
|
err := addCRIProxyInjector(e2eCriProxy, func(apiName string) error {
|
||||||
if apiName == criproxy.PullImage {
|
if apiName == criproxy.PullImage {
|
||||||
return expectedErr
|
return expectedErr
|
||||||
}
|
}
|
||||||
@ -86,19 +86,19 @@ var _ = SIGDescribe(feature.CriProxy, framework.WithSerial(), func() {
|
|||||||
|
|
||||||
ginkgo.Context("Inject a pull image timeout exception into the CriProxy", func() {
|
ginkgo.Context("Inject a pull image timeout exception into the CriProxy", func() {
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
if err := resetCRIProxyInjector(); err != nil {
|
if err := resetCRIProxyInjector(e2eCriProxy); err != nil {
|
||||||
ginkgo.Skip("Skip the test since the CRI Proxy is undefined.")
|
ginkgo.Skip("Skip the test since the CRI Proxy is undefined.")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.AfterEach(func() {
|
ginkgo.AfterEach(func() {
|
||||||
err := resetCRIProxyInjector()
|
err := resetCRIProxyInjector(e2eCriProxy)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("Image pull time exceeded 10 seconds", func(ctx context.Context) {
|
ginkgo.It("Image pull time exceeded 10 seconds", func(ctx context.Context) {
|
||||||
const delayTime = 10 * time.Second
|
const delayTime = 10 * time.Second
|
||||||
err := addCRIProxyInjector(func(apiName string) error {
|
err := addCRIProxyInjector(e2eCriProxy, func(apiName string) error {
|
||||||
if apiName == criproxy.PullImage {
|
if apiName == criproxy.PullImage {
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ var _ = SIGDescribe("Pull Image", feature.CriProxy, framework.WithSerial(), func
|
|||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func(ctx context.Context) {
|
ginkgo.BeforeEach(func(ctx context.Context) {
|
||||||
if err := resetCRIProxyInjector(); err != nil {
|
if err := resetCRIProxyInjector(e2eCriProxy); err != nil {
|
||||||
ginkgo.Skip("Skip the test since the CRI Proxy is undefined.")
|
ginkgo.Skip("Skip the test since the CRI Proxy is undefined.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ var _ = SIGDescribe("Pull Image", feature.CriProxy, framework.WithSerial(), func
|
|||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.AfterEach(func(ctx context.Context) {
|
ginkgo.AfterEach(func(ctx context.Context) {
|
||||||
err := resetCRIProxyInjector()
|
err := resetCRIProxyInjector(e2eCriProxy)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
ginkgo.By("cleanup pods")
|
ginkgo.By("cleanup pods")
|
||||||
@ -82,7 +82,7 @@ var _ = SIGDescribe("Pull Image", feature.CriProxy, framework.WithSerial(), func
|
|||||||
timeout := 20 * time.Second
|
timeout := 20 * time.Second
|
||||||
callCh := make(chan struct{})
|
callCh := make(chan struct{})
|
||||||
callStatus := make(map[int]chan struct{})
|
callStatus := make(map[int]chan struct{})
|
||||||
err := addCRIProxyInjector(func(apiName string) error {
|
err := addCRIProxyInjector(e2eCriProxy, func(apiName string) error {
|
||||||
if apiName == criproxy.PullImage {
|
if apiName == criproxy.PullImage {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
callID := len(callStatus)
|
callID := len(callStatus)
|
||||||
@ -142,7 +142,7 @@ var _ = SIGDescribe("Pull Image", feature.CriProxy, framework.WithSerial(), func
|
|||||||
var testpods []*v1.Pod
|
var testpods []*v1.Pod
|
||||||
|
|
||||||
ginkgo.BeforeEach(func(ctx context.Context) {
|
ginkgo.BeforeEach(func(ctx context.Context) {
|
||||||
if err := resetCRIProxyInjector(); err != nil {
|
if err := resetCRIProxyInjector(e2eCriProxy); err != nil {
|
||||||
ginkgo.Skip("Skip the test since the CRI Proxy is undefined.")
|
ginkgo.Skip("Skip the test since the CRI Proxy is undefined.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ var _ = SIGDescribe("Pull Image", feature.CriProxy, framework.WithSerial(), func
|
|||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.AfterEach(func(ctx context.Context) {
|
ginkgo.AfterEach(func(ctx context.Context) {
|
||||||
err := resetCRIProxyInjector()
|
err := resetCRIProxyInjector(e2eCriProxy)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
ginkgo.By("cleanup pods")
|
ginkgo.By("cleanup pods")
|
||||||
@ -166,7 +166,7 @@ var _ = SIGDescribe("Pull Image", feature.CriProxy, framework.WithSerial(), func
|
|||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
callCh := make(chan struct{})
|
callCh := make(chan struct{})
|
||||||
callStatus := make(map[int]chan struct{})
|
callStatus := make(map[int]chan struct{})
|
||||||
err := addCRIProxyInjector(func(apiName string) error {
|
err := addCRIProxyInjector(e2eCriProxy, func(apiName string) error {
|
||||||
if apiName == criproxy.PullImage {
|
if apiName == criproxy.PullImage {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
callID := len(callStatus)
|
callID := len(callStatus)
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
libcontainercgroups "github.com/opencontainers/runc/libcontainer/cgroups"
|
libcontainercgroups "github.com/opencontainers/runc/libcontainer/cgroups"
|
||||||
|
"k8s.io/kubernetes/test/e2e_node/criproxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsCgroup2UnifiedMode returns whether we are running in cgroup v2 unified mode.
|
// IsCgroup2UnifiedMode returns whether we are running in cgroup v2 unified mode.
|
||||||
@ -31,19 +32,19 @@ func IsCgroup2UnifiedMode() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// addCRIProxyInjector registers an injector function for the CRIProxy.
|
// addCRIProxyInjector registers an injector function for the CRIProxy.
|
||||||
func addCRIProxyInjector(injector func(apiName string) error) error {
|
func addCRIProxyInjector(proxy *criproxy.RemoteRuntime, injector func(apiName string) error) error {
|
||||||
if e2eCriProxy != nil {
|
if proxy == nil {
|
||||||
e2eCriProxy.AddInjector(injector)
|
return fmt.Errorf("failed to add injector because the CRI Proxy is undefined")
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return fmt.Errorf("failed to add injector because the CRI Proxy is undefined")
|
proxy.AddInjector(injector)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// resetCRIProxyInjector resets all injector functions for the CRIProxy.
|
// resetCRIProxyInjector resets all injector functions for the CRIProxy.
|
||||||
func resetCRIProxyInjector() error {
|
func resetCRIProxyInjector(proxy *criproxy.RemoteRuntime) error {
|
||||||
if e2eCriProxy != nil {
|
if proxy == nil {
|
||||||
e2eCriProxy.ResetInjectors()
|
return fmt.Errorf("failed to reset injector because the CRI Proxy is undefined")
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return fmt.Errorf("failed to reset injector because the CRI Proxy is undefined")
|
proxy.ResetInjectors()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user