From 3f5a6d33b98d9b8b415e42ed3c195211fcf94011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A5=9A=E5=B2=B3?= Date: Thu, 23 Jun 2022 14:43:30 +0800 Subject: [PATCH] add compatible logic for old controller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 楚岳 --- pkg/addon/addon.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/addon/addon.go b/pkg/addon/addon.go index 2ee101589..cc03e0fe9 100644 --- a/pkg/addon/addon.go +++ b/pkg/addon/addon.go @@ -1525,10 +1525,19 @@ func fetchVelaCoreImageTag(ctx context.Context, k8sClient client.Client) (string if err := k8sClient.List(ctx, deployList, client.MatchingLabels{oam.LabelControllerName: oam.ApplicationControllerName}); err != nil { return "", err } + deploy := appsv1.Deployment{} if len(deployList.Items) == 0 { - return "", errors.New("can't find a running KubeVela instance, please install it first") + // backward compatible logic old version which vela-core controller has no this label + if err := k8sClient.Get(ctx, types2.NamespacedName{Namespace: types.DefaultKubeVelaNS, Name: types.KubeVelaControllerDeployment}, &deploy); err != nil { + if apierrors.IsNotFound(err) { + return "", errors.New("can't find a running KubeVela instance, please install it first") + } + return "", err + } + } else { + deploy = deployList.Items[0] } - deploy := deployList.Items[0] + var tag string for _, c := range deploy.Spec.Template.Spec.Containers { if c.Name == types.DefaultKubeVelaReleaseName {