From a7db4edbdefed833f5773bd91cc06c175bbac09c Mon Sep 17 00:00:00 2001 From: jamesge Date: Thu, 27 Jun 2024 15:41:39 +0800 Subject: [PATCH] fix: hook pod do not reconcile as expected when no web process found (#1425) --- operator/api/v1alpha1/bkapp_types.go | 1 + operator/api/v1alpha2/bkapp_types.go | 1 + .../controllers/bkapp/hooks/resources/hooks.go | 16 ++-------------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/operator/api/v1alpha1/bkapp_types.go b/operator/api/v1alpha1/bkapp_types.go index 28b9920032..6247a359fb 100644 --- a/operator/api/v1alpha1/bkapp_types.go +++ b/operator/api/v1alpha1/bkapp_types.go @@ -199,6 +199,7 @@ const ( ScalingPolicyDefault ScalingPolicy = "default" ) +// ProbeSet defines the probes configuration type ProbeSet struct { // liveness is the configuration for liveness probes. // +optional diff --git a/operator/api/v1alpha2/bkapp_types.go b/operator/api/v1alpha2/bkapp_types.go index c1d043d0ef..314348a0c5 100644 --- a/operator/api/v1alpha2/bkapp_types.go +++ b/operator/api/v1alpha2/bkapp_types.go @@ -232,6 +232,7 @@ const ( ScalingPolicyDefault ScalingPolicy = "default" ) +// ProbeSet defines the probes configuration type ProbeSet struct { // liveness is the configuration for liveness probes. // +optional diff --git a/operator/pkg/controllers/bkapp/hooks/resources/hooks.go b/operator/pkg/controllers/bkapp/hooks/resources/hooks.go index aa91670787..72776c2630 100644 --- a/operator/pkg/controllers/bkapp/hooks/resources/hooks.go +++ b/operator/pkg/controllers/bkapp/hooks/resources/hooks.go @@ -106,18 +106,6 @@ func BuildPreReleaseHook(bkapp *paasv1alpha2.BkApp, status *paasv1alpha2.HookSta return nil } - proc := bkapp.Spec.GetWebProcess() - if proc == nil { - return nil - } - - // Use the web process's image and pull policy to run the hook. - // This behavior might be changed in the future when paasv1alpha1.BkApp is fully removed. - image, pullPolicy, err := paasv1alpha2.NewProcImageGetter(bkapp).Get("web") - if err != nil { - return nil - } - if status == nil { status = &paasv1alpha2.HookStatus{ Type: paasv1alpha2.HookPreRelease, @@ -155,12 +143,12 @@ func BuildPreReleaseHook(bkapp *paasv1alpha2.BkApp, status *paasv1alpha2.HookSta Spec: corev1.PodSpec{ Containers: []corev1.Container{ { - Image: image, + Image: bkapp.Spec.Build.Image, Command: kubeutil.ReplaceCommandEnvVariables(command), Args: kubeutil.ReplaceCommandEnvVariables(args), Env: common.GetAppEnvs(bkapp), Name: "hook", - ImagePullPolicy: pullPolicy, + ImagePullPolicy: bkapp.Spec.Build.ImagePullPolicy, // pre-hook 使用默认资源配置 Resources: envs.NewProcResourcesGetter(bkapp).Default(), // TODO: 挂载点