Skip to content

Commit af3e254

Browse files
authored
Improve Kruise E2E image registry and fix image pulling (#894)
Signed-off-by: FillZpp <[email protected]>
1 parent 2a7eb6d commit af3e254

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+921
-869
lines changed

.github/workflows/e2e-1.16.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
env:
1212
# Common versions
13-
GO_VERSION: '1.16'
13+
GO_VERSION: '1.17'
1414
KIND_IMAGE: 'kindest/node:v1.16.15'
1515
KIND_CLUSTER_NAME: 'ci-testing'
1616

@@ -70,7 +70,6 @@ jobs:
7070
run: |
7171
export KUBECONFIG=/home/runner/.kube/config
7272
make ginkgo
73-
./scripts/generate_bindata.sh
7473
./bin/ginkgo -timeout 60m -v --focus='\[apps\] StatefulSet' test/e2e
7574
7675
pullimages-containerrecreate:
@@ -127,7 +126,6 @@ jobs:
127126
run: |
128127
export KUBECONFIG=/home/runner/.kube/config
129128
make ginkgo
130-
./scripts/generate_bindata.sh
131129
./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest)' test/e2e
132130
133131
advanced-daemonset:
@@ -184,7 +182,6 @@ jobs:
184182
run: |
185183
export KUBECONFIG=/home/runner/.kube/config
186184
make ginkgo
187-
./scripts/generate_bindata.sh
188185
./bin/ginkgo -timeout 60m -v --focus='\[apps\] DaemonSet' test/e2e
189186
190187
sidecarset:
@@ -241,7 +238,6 @@ jobs:
241238
run: |
242239
export KUBECONFIG=/home/runner/.kube/config
243240
make ginkgo
244-
./scripts/generate_bindata.sh
245241
./bin/ginkgo -timeout 60m -v --focus='\[apps\] SidecarSet' test/e2e
246242
247243
other:
@@ -298,7 +294,6 @@ jobs:
298294
run: |
299295
export KUBECONFIG=/home/runner/.kube/config
300296
make ginkgo
301-
./scripts/generate_bindata.sh
302297
set +e
303298
./bin/ginkgo -timeout 60m -v --skip='\[apps\] (StatefulSet|PullImage|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' test/e2e
304299
# retVal=$?

.github/workflows/e2e-1.18.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
env:
1212
# Common versions
13-
GO_VERSION: '1.16'
13+
GO_VERSION: '1.17'
1414
KIND_IMAGE: 'kindest/node:v1.18.0'
1515
KIND_CLUSTER_NAME: 'ci-testing'
1616

@@ -69,5 +69,4 @@ jobs:
6969
run: |
7070
export KUBECONFIG=/home/runner/.kube/config
7171
make ginkgo
72-
./scripts/generate_bindata.sh
7372
./bin/ginkgo -timeout 60m -v --focus='\[apps\] EphemeralJob' test/e2e

.github/workflows/e2e-1.22.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
env:
1212
# Common versions
13-
GO_VERSION: '1.16'
13+
GO_VERSION: '1.17'
1414
KIND_IMAGE: 'kindest/node:v1.22.0'
1515
KIND_CLUSTER_NAME: 'ci-testing'
1616

@@ -70,7 +70,6 @@ jobs:
7070
run: |
7171
export KUBECONFIG=/home/runner/.kube/config
7272
make ginkgo
73-
./scripts/generate_bindata.sh
7473
./bin/ginkgo -timeout 60m -v --focus='\[apps\] StatefulSet' test/e2e
7574
7675
pullimages-containerrecreate:
@@ -127,7 +126,6 @@ jobs:
127126
run: |
128127
export KUBECONFIG=/home/runner/.kube/config
129128
make ginkgo
130-
./scripts/generate_bindata.sh
131129
./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest)' test/e2e
132130
133131
advanced-daemonset:
@@ -184,7 +182,6 @@ jobs:
184182
run: |
185183
export KUBECONFIG=/home/runner/.kube/config
186184
make ginkgo
187-
./scripts/generate_bindata.sh
188185
./bin/ginkgo -timeout 60m -v --focus='\[apps\] DaemonSet' test/e2e
189186
190187
sidecarset:
@@ -241,7 +238,6 @@ jobs:
241238
run: |
242239
export KUBECONFIG=/home/runner/.kube/config
243240
make ginkgo
244-
./scripts/generate_bindata.sh
245241
./bin/ginkgo -timeout 60m -v --focus='\[apps\] SidecarSet' test/e2e
246242
247243
other:
@@ -298,7 +294,6 @@ jobs:
298294
run: |
299295
export KUBECONFIG=/home/runner/.kube/config
300296
make ginkgo
301-
./scripts/generate_bindata.sh
302297
set +e
303298
./bin/ginkgo -timeout 60m -v --skip='\[apps\] (StatefulSet|PullImage|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' test/e2e
304299
# retVal=$?

Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ go_check:
2727
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
2828
@scripts/generate_client.sh
2929
@scripts/generate_openapi.sh
30-
@scripts/generate_bindata.sh
3130
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./apis/..."
3231

3332
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
@@ -121,7 +120,7 @@ TMP_DIR=$$(mktemp -d) ;\
121120
cd $$TMP_DIR ;\
122121
go mod init tmp ;\
123122
echo "Downloading $(2)" ;\
124-
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
123+
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
125124
rm -rf $$TMP_DIR ;\
126125
mv $(PROJECT_DIR)/bin/$(3) $(1);\
127126
}

config/manager/manager.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ spec:
4545
resources:
4646
limits:
4747
cpu: 100m
48-
memory: 50Mi
48+
memory: 200Mi
4949
requests:
5050
cpu: 100m
51-
memory: 50Mi
51+
memory: 200Mi
5252
terminationGracePeriodSeconds: 10
5353
---
5454
apiVersion: v1
@@ -108,7 +108,7 @@ spec:
108108
resources:
109109
limits:
110110
cpu: 100m
111-
memory: 50Mi
111+
memory: 100Mi
112112
requests:
113113
cpu: "0"
114114
memory: "0"

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/openkruise/kruise
22

3-
go 1.15
3+
go 1.16
44

55
require (
66
github.com/alibaba/pouch v0.0.0-20190328125340-37051654f368

pkg/controller/imagepulljob/imagepulljob_event_handler.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ package imagepulljob
1818

1919
import (
2020
"reflect"
21-
"strings"
2221

2322
appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1"
23+
daemonutil "github.com/openkruise/kruise/pkg/daemon/util"
2424
utilimagejob "github.com/openkruise/kruise/pkg/util/imagejob"
2525
v1 "k8s.io/api/core/v1"
2626
"k8s.io/apimachinery/pkg/types"
@@ -106,11 +106,13 @@ func (e *nodeImageEventHandler) handleUpdate(nodeImage, oldNodeImage *appsv1alph
106106
}
107107
diffSet := diffJobs(newJobs, oldJobs)
108108
for _, j := range newJobs {
109-
for _, cImage := range changedImages.List() {
110-
if j.Spec.Image == cImage || strings.HasPrefix(j.Spec.Image, cImage+":") {
111-
diffSet[types.NamespacedName{Namespace: j.Namespace, Name: j.Name}] = struct{}{}
112-
break
113-
}
109+
imageName, _, err := daemonutil.NormalizeImageRefToNameTag(j.Spec.Image)
110+
if err != nil {
111+
klog.Warningf("Invalid image %s in job %s/%s", j.Spec.Image, j.Namespace, j.Name)
112+
continue
113+
}
114+
if changedImages.Has(imageName) {
115+
diffSet[types.NamespacedName{Namespace: j.Namespace, Name: j.Name}] = struct{}{}
114116
}
115117
}
116118
for name := range diffSet {

pkg/daemon/criruntime/factory.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
runtimeimage "github.com/openkruise/kruise/pkg/daemon/criruntime/imageruntime"
2626
daemonutil "github.com/openkruise/kruise/pkg/daemon/util"
27-
"google.golang.org/grpc"
2827
criapi "k8s.io/cri-api/pkg/apis"
2928
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
3029
"k8s.io/klog/v2"
@@ -98,14 +97,12 @@ func NewFactory(varRunPath string, accountManager daemonutil.ImagePullAccountMan
9897
continue
9998
}
10099
case ContainerRuntimeContainerd:
101-
var conn *grpc.ClientConn
102-
addr, _, _ := kubeletutil.GetAddressAndDialer(cfg.runtimeRemoteURI)
103-
conn, err = getContainerdConn(addr)
100+
addr, _, err := kubeletutil.GetAddressAndDialer(cfg.runtimeRemoteURI)
104101
if err != nil {
105-
klog.Warningf("Failed to get connection for %v (%s, %s): %v", cfg.runtimeType, cfg.runtimeURI, cfg.runtimeRemoteURI, err)
102+
klog.Warningf("Failed to get address for %v (%s, %s): %v", cfg.runtimeType, cfg.runtimeURI, cfg.runtimeRemoteURI, err)
106103
continue
107104
}
108-
imageService, err = runtimeimage.NewContainerdImageService(conn, accountManager)
105+
imageService, err = runtimeimage.NewContainerdImageService(addr, accountManager)
109106
if err != nil {
110107
klog.Warningf("Failed to new image service for %v (%s, %s): %v", cfg.runtimeType, cfg.runtimeURI, cfg.runtimeRemoteURI, err)
111108
continue

pkg/daemon/criruntime/imageruntime/containerd.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ const (
5454

5555
// NewContainerdImageService returns containerd-type ImageService
5656
func NewContainerdImageService(
57-
conn *grpc.ClientConn,
57+
runtimeURI string,
5858
accountManager daemonutil.ImagePullAccountManager,
5959
) (ImageService, error) {
60-
snapshotter, httpProxy, err := getDefaultValuesFromCRIStatus(conn)
60+
client, err := containerd.New(runtimeURI)
6161
if err != nil {
6262
return nil, err
6363
}
64-
65-
client, err := containerd.NewWithConn(conn)
64+
conn := client.Conn()
65+
snapshotter, httpProxy, err := getDefaultValuesFromCRIStatus(conn)
6666
if err != nil {
6767
return nil, err
6868
}

pkg/daemon/criruntime/util.go

-50
This file was deleted.

scripts/generate_bindata.sh

-51
This file was deleted.

test/e2e/apps/broadcastjob.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var _ = SIGDescribe("BroadcastJob", func() {
8282

8383
framework.KruiseDescribe("BroadcastJob dispatching", func() {
8484

85-
ginkgo.It("succeeds for parallelism < number of node", func() {
85+
framework.ConformanceIt("succeeds for parallelism < number of node", func() {
8686
ginkgo.By("Create Fake Node " + randStr)
8787
fakeNode, err := nodeTester.CreateFakeNode(randStr)
8888
gomega.Expect(err).NotTo(gomega.HaveOccurred())
@@ -96,7 +96,7 @@ var _ = SIGDescribe("BroadcastJob", func() {
9696
Tolerations: []v1.Toleration{{Key: framework.E2eFakeKey, Operator: v1.TolerationOpEqual, Value: randStr, Effect: v1.TaintEffectNoSchedule}},
9797
Containers: []v1.Container{{
9898
Name: "box",
99-
Image: "busybox:latest",
99+
Image: BusyboxImage,
100100
Command: []string{"/bin/sh", "-c", "sleep 5"},
101101
}},
102102
RestartPolicy: v1.RestartPolicyNever,

0 commit comments

Comments
 (0)