From 653c1debadf36277c77f4de761ebd6273c01c023 Mon Sep 17 00:00:00 2001 From: wangdepeng Date: Thu, 23 May 2024 14:04:45 +0800 Subject: [PATCH] fix: uninstall anp failed and failed to upload agent cert to tenant Signed-off-by: wangdepeng --- pkg/kubenest/tasks/anp.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/kubenest/tasks/anp.go b/pkg/kubenest/tasks/anp.go index 451434c3f..e257a3811 100644 --- a/pkg/kubenest/tasks/anp.go +++ b/pkg/kubenest/tasks/anp.go @@ -29,14 +29,14 @@ func NewAnpTask() workflow.Task { Run: runAnp, RunSubTasks: true, Tasks: []workflow.Task{ - { - Name: "deploy-anp-server", - Run: runAnpServer, - }, { Name: "Upload-ProxyAgentCert", Run: runUploadProxyAgentCert, }, + { + Name: "deploy-anp-server", + Run: runAnpServer, + }, { Name: "deploy-anp-agent", Run: runAnpAgent, @@ -220,7 +220,9 @@ func getAnpAgentManifest(client clientset.Interface, name string, namespace stri // get apiServer hostIp proxyServerHost, err := getDeploymentPodIPs(client, namespace, fmt.Sprintf("%s-%s", name, "apiserver")) if err != nil { - return "", nil, fmt.Errorf("error when get apiserver hostIp, err: %w", err) + klog.Warningf("Failed to get apiserver hostIp, err: %v", err) + // ignore if can't get the hostIp when uninstall the deployment + proxyServerHost = []string{"127.0.0.1"} } anpAgentManifeattBytes, err := util.ParseTemplate(apiserver.AnpAgentManifest, struct { @@ -319,6 +321,7 @@ func runUploadProxyAgentCert(r workflow.RunData) error { certList := data.CertList() certsData := make(map[string][]byte, len(certList)) for _, c := range certList { + // only upload apisever cert if strings.Contains(c.KeyName(), "apiserver") { certsData[c.KeyName()] = c.KeyData() certsData[c.CertName()] = c.CertData()