Skip to content

Commit

Permalink
Add ImageListPullJob to simplify ImagePullJob (openkruise#1222)
Browse files Browse the repository at this point in the history
calculate status for imagelistpulljob



make generate manifests



add imagelistpulljob.status.status



make generate manifests



regist webhook handler

delete image pull job which is not existed in ImageListPullJob.Spec.Images



support the same behavior as image pull job for TTLSecondsAfterFinished and CompletionTime fields



resourceVersionExpectations



add ut



verify the maximum number of images cannot > 255



make generate manifests



add failled image pull job status



simplify imageListPullJobStatus and spec



fix mdlint



define ImagePullJobTemplate & fix imageliststatus when completionPolicy.Type is Never



fix,some print info



trigger ci



fix some issues of code



fix some logic of Expectations



Check for duplicate values of spec.images



move proposal doc to other PR



trigger ci&& modify comment



add e2e



remove phase field from status and and remove the unnecessary deepcopy

add ut for computeImagePullJobActions and fix some bugs
  • Loading branch information
diannaowa committed May 19, 2023
1 parent 3a80fd2 commit f3d5a85
Show file tree
Hide file tree
Showing 20 changed files with 1,676 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e-1.16.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
export KUBECONFIG=/home/runner/.kube/config
make ginkgo
set +e
./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest)' test/e2e
./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest|PullImages)' test/e2e
retVal=$?
restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}')
if [ "${restartCount}" -eq "0" ];then
Expand Down Expand Up @@ -456,7 +456,7 @@ jobs:
export KUBECONFIG=/home/runner/.kube/config
make ginkgo
set +e
./bin/ginkgo -timeout 90m -v --skip='\[apps\] (StatefulSet|PullImage|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' --skip='\[policy\] PodUnavailableBudget' test/e2e
./bin/ginkgo -timeout 90m -v --skip='\[apps\] (StatefulSet|PullImage|PullImages|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' --skip='\[policy\] PodUnavailableBudget' test/e2e
retVal=$?
restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}')
if [ "${restartCount}" -eq "0" ];then
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-1.24.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
export KUBECONFIG=/home/runner/.kube/config
make ginkgo
set +e
./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest)' test/e2e
./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest|PullImages)' test/e2e
retVal=$?
restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}')
if [ "${restartCount}" -eq "0" ];then
Expand Down Expand Up @@ -502,7 +502,7 @@ jobs:
export KUBECONFIG=/home/runner/.kube/config
make ginkgo
set +e
./bin/ginkgo -timeout 90m -v --skip='\[apps\] (StatefulSet|PullImage|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' --skip='\[policy\] PodUnavailableBudget' test/e2e
./bin/ginkgo -timeout 90m -v --skip='\[apps\] (StatefulSet|PullImage|PullImages|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' --skip='\[policy\] PodUnavailableBudget' test/e2e
retVal=$?
restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}')
if [ "${restartCount}" -eq "0" ];then
Expand Down
16 changes: 16 additions & 0 deletions apis/apps/defaults/v1alpha1.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,19 @@ func SetDefaultsImagePullJob(obj *v1alpha1.ImagePullJob) {
obj.Spec.PullPolicy.BackoffLimit = utilpointer.Int32Ptr(3)
}
}

// SetDefaultsImageListPullJob set default values for ImageListPullJob.
func SetDefaultsImageListPullJob(obj *v1alpha1.ImageListPullJob) {
if obj.Spec.CompletionPolicy.Type == "" {
obj.Spec.CompletionPolicy.Type = v1alpha1.Always
}
if obj.Spec.PullPolicy == nil {
obj.Spec.PullPolicy = &v1alpha1.PullPolicy{}
}
if obj.Spec.PullPolicy.TimeoutSeconds == nil {
obj.Spec.PullPolicy.TimeoutSeconds = utilpointer.Int32Ptr(600)
}
if obj.Spec.PullPolicy.BackoffLimit == nil {
obj.Spec.PullPolicy.BackoffLimit = utilpointer.Int32Ptr(3)
}
}
8 changes: 1 addition & 7 deletions apis/apps/v1alpha1/imagelistpulljob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ type ImageListPullJobStatus struct {
// +optional
Succeeded int32 `json:"succeeded"`

// Phase Indicates the completion progress of the job,the format is Succeeded/Completed
// Succeeded: The number of ImagePullJobs which reached status.Succeeded==status.Desired
// Completed: The number of ImagePullJobs which are finished
// +optional
Phase string `json:"phase"`

// The status of ImagePullJob which has the failed nodes(status.Failed>0) .
// +optional
FailedImageStatuses []*FailedImageStatus `json:"failedImageStatuses,omitempty"`
Expand All @@ -89,7 +83,7 @@ type FailedImageStatus struct {
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="TOTAL",type="integer",JSONPath=".status.desired",description="Number of image pull job"
// +kubebuilder:printcolumn:name="SUCCEEDED",type="integer",JSONPath=".status.succeeded",description="Number of image pull job succeeded"
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.phase",description="status.succeeded/status.completed"
// +kubebuilder:printcolumn:name="COMPLETED",type="integer",JSONPath=".status.completed",description="Number of ImagePullJobs which are finished"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC."

// ImageListPullJob is the Schema for the imagelistpulljobs API
Expand Down
14 changes: 4 additions & 10 deletions config/crd/bases/apps.kruise.io_imagelistpulljobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ spec:
jsonPath: .status.succeeded
name: SUCCEEDED
type: integer
- description: status.succeeded/status.completed
jsonPath: .status.phase
name: STATUS
type: string
- description: Number of ImagePullJobs which are finished
jsonPath: .status.completed
name: COMPLETED
type: integer
- description: CreationTimestamp is a timestamp representing the server time when
this object was created. It is not guaranteed to be set in happens-before
order across separate operations. Clients may not set this value. It is represented
Expand Down Expand Up @@ -277,12 +277,6 @@ spec:
type: string
type: object
type: array
phase:
description: 'Phase Indicates the completion progress of the job,the
format is Succeeded/Completed Succeeded: The number of ImagePullJobs
which reached status.Succeeded==status.Desired Completed: The number
of ImagePullJobs which are finished'
type: string
startTime:
description: Represents time when the job was acknowledged by the
job controller. It is not guaranteed to be set in happens-before
Expand Down
1 change: 1 addition & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resources:
- bases/apps.kruise.io_persistentpodstates.yaml
- bases/apps.kruise.io_podprobemarkers.yaml
- bases/apps.kruise.io_nodepodprobes.yaml
- bases/apps.kruise.io_imagelistpulljobs.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand Down
26 changes: 26 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,32 @@ rules:
- get
- patch
- update
- apiGroups:
- apps.kruise.io
resources:
- imagelistpulljobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps.kruise.io
resources:
- imagelistpulljobs/finalizers
verbs:
- update
- apiGroups:
- apps.kruise.io
resources:
- imagelistpulljobs/status
verbs:
- get
- patch
- update
- apiGroups:
- apps.kruise.io
resources:
Expand Down
42 changes: 42 additions & 0 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,27 @@ webhooks:
resources:
- daemonsets
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /mutate-apps-kruise-io-v1alpha1-imagelistpulljob
failurePolicy: Fail
name: mimagelistpulljob.kb.io
rules:
- apiGroups:
- apps.kruise.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- imagelistpulljobs
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down Expand Up @@ -453,6 +474,27 @@ webhooks:
resources:
- daemonsets
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-apps-kruise-io-v1alpha1-imagelistpulljob
failurePolicy: Fail
name: vimagelistpulljob.kb.io
rules:
- apiGroups:
- apps.kruise.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- imagelistpulljobs
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/openkruise/kruise/pkg/controller/containerrecreaterequest"
"github.com/openkruise/kruise/pkg/controller/daemonset"
"github.com/openkruise/kruise/pkg/controller/ephemeraljob"
"github.com/openkruise/kruise/pkg/controller/imagelistpulljob"
"github.com/openkruise/kruise/pkg/controller/imagepulljob"
"github.com/openkruise/kruise/pkg/controller/nodeimage"
"github.com/openkruise/kruise/pkg/controller/nodepodprobe"
Expand Down Expand Up @@ -65,6 +66,7 @@ func init() {
controllerAddFuncs = append(controllerAddFuncs, sidecarterminator.Add)
controllerAddFuncs = append(controllerAddFuncs, podprobemarker.Add)
controllerAddFuncs = append(controllerAddFuncs, nodepodprobe.Add)
controllerAddFuncs = append(controllerAddFuncs, imagelistpulljob.Add)
}

func SetupWithManager(m manager.Manager) error {
Expand Down
Loading

0 comments on commit f3d5a85

Please sign in to comment.