Skip to content

Refactor/fix lint error #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -3,11 +3,11 @@ ORG = polarismesh
REPO = polaris-controller
SIDECAR_INIT_REPO = polaris-sidecar-init
ENVOY_SIDECAR_INIT_REPO = polaris-envoy-bootstrap-generator
IMAGE_TAG = v1.7.1
IMAGE_TAG = v1.7.2
PLATFORMS = linux/amd64,linux/arm64

.PHONY: all
all: build-amd64 build-arm64 build-multi-arch-image \
all: fmt build-amd64 build-arm64 build-multi-arch-image \
build-sidecar-init build-envoy-sidecar-init push-image

.PHONY: build-amd64
@@ -49,3 +49,20 @@ clean:
rm -rf bin
rm -rf polaris-controller-release*

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...

.PHONY: generate-multi-arch-image
generate-multi-arch-image: fmt build-amd64 build-arm64
@echo "------------------"
@echo "--> Generate multi-arch docker image to registry for polaris-controller"
@echo "------------------"
@docker buildx build -f ./docker/Dockerfile --tag $(ORG)/$(REPO):$(IMAGE_TAG) --platform $(PLATFORMS) ./

.PHONY: push-multi-arch-image
push-multi-arch-image: generate-multi-arch-image
@echo "------------------"
@echo "--> Push multi-arch docker image to registry for polaris-controller"
@echo "------------------"
@docker image push $(ORG)/$(REPO):$(IMAGE_TAG) --platform $(PLATFORMS)
4 changes: 2 additions & 2 deletions cmd/polaris-controller/app/config.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
package app

import (
"io/ioutil"
"os"

"gopkg.in/yaml.v2"

@@ -65,7 +65,7 @@ type controllerConfig struct {
}

func readConfFromFile() (*controllerConfig, error) {
buf, err := ioutil.ReadFile(MeshFile)
buf, err := os.ReadFile(MeshFile)
if err != nil {
log.Errorf("read file error, %v", err)
return nil, err
4 changes: 3 additions & 1 deletion cmd/polaris-controller/app/options/serve.go
Original file line number Diff line number Diff line change
@@ -95,7 +95,9 @@ func RunServer(
defer close(stoppedCh)
<-stopCh
ctx, cancel := context.WithTimeout(context.Background(), shutDownTimeout)
server.Shutdown(ctx)
if err := server.Shutdown(ctx); err != nil {
log.Warnf("server Shutdown error:%+v", err)
}
cancel()
}()

6 changes: 3 additions & 3 deletions cmd/polaris-controller/app/polaris-controller-manager.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ package app
import (
"context"
"fmt"
"io/ioutil"
"io"
"math/rand"
"net"
"net/http"
@@ -239,8 +239,8 @@ func assignFlags(rootCmd *cobra.Command) {

func closeGrpcLog() {
var (
infoW = ioutil.Discard
warningW = ioutil.Discard
infoW = io.Discard
warningW = io.Discard
errorW = os.Stderr
)
grpclog.SetLoggerV2(grpclog.NewLoggerV2(infoW, warningW, errorW))
2 changes: 1 addition & 1 deletion cmd/polaris-controller/main.go
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ import (
)

func main() {
rand.Seed(time.Now().UnixNano())
rand.New(rand.NewSource(time.Now().UnixNano()))

command := app.NewPolarisControllerManagerCommand()
logs.InitLogs()
2 changes: 1 addition & 1 deletion common/log/config.go
Original file line number Diff line number Diff line change
@@ -293,7 +293,7 @@ func Configure(optionsMap map[string]*Options) error {

// capture gRPC logging
if options.LogGrpc {
grpclog.SetLogger(zapgrpc.NewLogger(captureLogger.WithOptions(zap.AddCallerSkip(2))))
grpclog.SetLoggerV2(zapgrpc.NewLogger(captureLogger.WithOptions(zap.AddCallerSkip(2))))
}
}
}
4 changes: 2 additions & 2 deletions pkg/cache/config_cache.go
Original file line number Diff line number Diff line change
@@ -40,11 +40,11 @@ func (csm *CachedConfigFileMap) Delete(key string) {
func (csm *CachedConfigFileMap) Load(key string) (value *v1.ConfigMap, ok bool) {
v, ok := csm.sm.Load(key)
if v != nil {
value, ok2 := v.(*v1.ConfigMap)
result, ok2 := v.(*v1.ConfigMap)
if !ok2 {
ok = false
}
return value, ok
return result, ok
}
return value, ok
}
4 changes: 2 additions & 2 deletions pkg/cache/service_cache.go
Original file line number Diff line number Diff line change
@@ -40,11 +40,11 @@ func (csm *CachedServiceMap) Delete(key string) {
func (csm *CachedServiceMap) Load(key string) (value *v1.Service, ok bool) {
v, ok := csm.sm.Load(key)
if v != nil {
value, ok2 := v.(*v1.Service)
result, ok2 := v.(*v1.Service)
if !ok2 {
ok = false
}
return value, ok
return result, ok
}
return value, ok
}
8 changes: 3 additions & 5 deletions pkg/controller/apis.go
Original file line number Diff line number Diff line change
@@ -275,7 +275,8 @@ func (p *PolarisController) compareInstanceUpdate(service *v1.Service, spec *add
// ttl 默认是5s
ttl, err := strconv.Atoi(ttlStr)
if err != nil {
ttl = 5
log.SyncNamingScope().Errorf("annotation 'polarismesh.cn/ttl' value: %s, converted to type int error %v",
ttlStr, err)
} else {
if ttl > 0 && ttl <= 60 {
healthCheck.Type = util.IntPtr(0)
@@ -317,10 +318,7 @@ func (p *PolarisController) compareInstanceUpdate(service *v1.Service, spec *add
}

if newMetadataStr == "" {
if isPolarisInstanceHasCustomMeta(oldMetadata) {
return true
}
return false
return isPolarisInstanceHasCustomMeta(oldMetadata)
}
newMetaMap := make(map[string]string)
err := json.Unmarshal([]byte(newMetadataStr), &newMetaMap)
4 changes: 0 additions & 4 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
@@ -285,10 +285,6 @@ func (p *PolarisController) process(t *Task) error {
return err
}

func (p *PolarisController) handleErr(err error, task *Task) {

}

// CounterPolarisService
func (p *PolarisController) CounterPolarisService() {
serviceList, err := p.serviceLister.List(labels.Everything())
2 changes: 1 addition & 1 deletion pkg/controller/endpoint.go
Original file line number Diff line number Diff line change
@@ -192,7 +192,7 @@ func (p *PolarisController) processSyncInstance(service *v1.Service) (err error)
fmt.Sprintf("%s Current polaris instance is %v", serviceMsg, currentIPs),
fmt.Sprintf("%s addIns %v deleteIns %v updateIns %v", serviceMsg, addIns, deleteIns, updateIns),
}
log.SyncNamingScope().Infof(strings.Join(msg, "\n"))
log.SyncNamingScope().Info(strings.Join(msg, "\n"))

var addInsErr, deleteInsErr, updateInsErr error

2 changes: 1 addition & 1 deletion pkg/controller/namespace.go
Original file line number Diff line number Diff line change
@@ -68,11 +68,11 @@ func (p *PolarisController) onNamespaceUpdate(old, cur interface{}) {
// 3. 无 sync -> 有 sync,将 ns 下 service、configmap 加入队列,标志为 polaris 要处理的,即添加
// 4. 有 sync -> 无 sync,将 ns 下 service、configmap 加入队列,标志为 polaris 不需要处理的,即删除

operation := OperationEmpty
if !isOldSync && !isCurSync {
// 情况 1
return
}
var operation Operation
if isCurSync {
// 情况 2、3
operation = OperationAdd
515 changes: 257 additions & 258 deletions pkg/inject/api/annotation/annotations.gen.go

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions pkg/inject/pkg/config/mesh/mesh.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
package mesh

import (
"io/ioutil"
"os"

"github.com/hashicorp/go-multierror"
"gopkg.in/yaml.v2"
@@ -54,7 +54,9 @@ func DefaultMeshConfig() MeshConfig {
// ApplyMeshConfig returns a new MeshConfig decoded from the
// input YAML with the provided defaults applied to omitted configuration values.
func ApplyMeshConfig(str string, defaultConfig MeshConfig) (*MeshConfig, error) {
yaml.Unmarshal([]byte(str), &defaultConfig)
if err := yaml.Unmarshal([]byte(str), &defaultConfig); err != nil {
return nil, err
}
return &defaultConfig, nil
}

@@ -66,7 +68,7 @@ func ApplyMeshConfigDefaults(yaml string) (*MeshConfig, error) {

// ReadMeshConfig gets mesh configuration from a config file
func ReadMeshConfig(filename string) (*MeshConfig, error) {
yaml, err := ioutil.ReadFile(filename)
yaml, err := os.ReadFile(filename)
if err != nil {
return nil, multierror.Prefix(err, "cannot read mesh config file")
}
10 changes: 7 additions & 3 deletions pkg/inject/pkg/kube/inject/apply/javaagent/patch.go
Original file line number Diff line number Diff line change
@@ -24,14 +24,15 @@ import (
"strings"
"text/template"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/polarismesh/polaris-controller/common/log"
"github.com/polarismesh/polaris-controller/pkg/inject/pkg/kube/inject"
"github.com/polarismesh/polaris-controller/pkg/inject/pkg/kube/inject/apply/base"
"github.com/polarismesh/polaris-controller/pkg/polarisapi"
"github.com/polarismesh/polaris-controller/pkg/util"
utils "github.com/polarismesh/polaris-controller/pkg/util"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Java Agent 场景下的特殊 annonations 信息
@@ -253,7 +254,10 @@ func (pb *PodPatchBuilder) updateContainer(opt *inject.PatchOptions, sidecarMode
if properties, ok := annonations[customJavaAgentPluginConfig]; ok {
customProperties := map[string]string{}
if properties != "" {
json.Unmarshal([]byte(properties), &customProperties)
if err := json.Unmarshal([]byte(properties), &customProperties); err != nil {
log.InjectScope().Errorf("updateContainer for pod=[%s, %s] json error: %+v", pod.Namespace,
pod.Name, err)
}
}
// 先从 configmap 中获取 java-agent 不同 plugin-type 的默认配置信息
for k, v := range customProperties {
2 changes: 2 additions & 0 deletions pkg/inject/pkg/kube/inject/inject.go
Original file line number Diff line number Diff line change
@@ -255,6 +255,7 @@ func validateStatusPort(port string) error {
return nil
}

// nolint
// validateUInt32 validates that the given annotation value is a positive integer.
func validateUInt32(value string) error {
_, err := strconv.ParseUint(value, 10, 32)
@@ -825,6 +826,7 @@ func potentialPodName(metadata *metav1.ObjectMeta) string {
return ""
}

// nolint
// rewriteCniPodSpec will check if values from the sidecar injector Helm
// values need to be inserted as Pod annotations so the CNI will apply
// the proper redirection rules.
27 changes: 15 additions & 12 deletions pkg/inject/pkg/kube/inject/webhook.go
Original file line number Diff line number Diff line change
@@ -21,8 +21,9 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"path/filepath"
"sort"
"strings"
@@ -110,10 +111,10 @@ type InjectConfigInfo struct {

// env will be used for other things besides meshConfig - when webhook is running in Istiod it can take advantage
// of the config and endpoint cache.
// nolint directives: interfacer
// nolint
func loadConfig(injectMeshFile, injectDnsFile, injectJavaFile, meshFile, valuesFile string) (*InjectConfigInfo, error) {
// 处理 polaris-sidecar mesh 模式的注入
meshData, err := ioutil.ReadFile(injectMeshFile)
meshData, err := os.ReadFile(injectMeshFile)
if err != nil {
return nil, err
}
@@ -124,7 +125,7 @@ func loadConfig(injectMeshFile, injectDnsFile, injectJavaFile, meshFile, valuesF
}

// 处理 polaris-sidecar dns 模式的注入
dnsData, err := ioutil.ReadFile(injectDnsFile)
dnsData, err := os.ReadFile(injectDnsFile)
if err != nil {
return nil, err
}
@@ -135,7 +136,7 @@ func loadConfig(injectMeshFile, injectDnsFile, injectJavaFile, meshFile, valuesF
}

// 处理 java-agent 模式的注入
javaAgentData, err := ioutil.ReadFile(injectJavaFile)
javaAgentData, err := os.ReadFile(injectJavaFile)
if err != nil {
return nil, err
}
@@ -145,7 +146,7 @@ func loadConfig(injectMeshFile, injectDnsFile, injectJavaFile, meshFile, valuesF
return nil, err
}

valuesConfig, err := ioutil.ReadFile(valuesFile)
valuesConfig, err := os.ReadFile(valuesFile)
if err != nil {
return nil, err
}
@@ -285,17 +286,15 @@ func NewWebhook(p WebhookParameters) (*Webhook, error) {
defaultSidecarMode: p.DefaultSidecarMode,
}

var mux *http.ServeMux
if p.Mux != nil {
p.Mux.HandleFunc("/inject", wh.serveInject)
mux = p.Mux
} else {
wh.server = &http.Server{
Addr: fmt.Sprintf(":%v", p.Port),
// mtls disabled because apiserver webhook cert usage is still TBD.
TLSConfig: &tls.Config{GetCertificate: wh.getCert},
}
mux = http.NewServeMux()
mux := http.NewServeMux()
mux.HandleFunc("/inject", wh.serveInject)
wh.server.Handler = mux
}
@@ -366,7 +365,7 @@ func (wh *Webhook) Run(stop <-chan struct{}) {
log.InjectScope().Errorf("Watcher error: %v", err)
case <-healthC:
content := []byte(`ok`)
if err := ioutil.WriteFile(wh.healthCheckFile, content, 0o644); err != nil {
if err := os.WriteFile(wh.healthCheckFile, content, 0o644); err != nil {
log.InjectScope().Errorf("Health check update of %q failed: %v", wh.healthCheckFile, err)
}
case <-stop:
@@ -409,6 +408,7 @@ func enableMtls(pod *corev1.Pod) bool {
return false
}

// nolint
// addPolarisConfigToInitContainerEnv 将polaris-sidecar 的配置注入到init container中
func (wh *Webhook) addPolarisConfigToInitContainerEnv(add *corev1.Container) error {
cfgTpl, err := wh.k8sClient.CoreV1().ConfigMaps(common.PolarisControllerNamespace).
@@ -447,9 +447,11 @@ func (wh *Webhook) addPolarisConfigToInitContainerEnv(add *corev1.Container) err
return nil
}

// nolint
// currently we assume that polaris-security deploy into polaris-system namespace.
const rootNamespace = "polaris-system"

// nolint
// ensureRootCertExist ensure that we have rootca pem secret in current namespace
func (wh *Webhook) ensureRootCertExist(pod *corev1.Pod) error {
if !enableMtls(pod) {
@@ -504,6 +506,7 @@ func escapeJSONPointerValue(in string) string {
return strings.Replace(step, "/", "~1", -1)
}

// nolint
// adds labels to the target spec, will not overwrite label's value if it already exists
func addLabels(target map[string]string, added map[string]string) []Rfc6902PatchOperation {
patches := []Rfc6902PatchOperation{}
@@ -854,7 +857,7 @@ func (wh *Webhook) injectV1beta1(ar *v1beta1.AdmissionReview) *v1beta1.Admission
}
proxyCfg := wh.meshConfig.DefaultConfig
spec, annotations, iStatus, err := InjectionData(config.Template, wh.valuesConfig, tempVersion, typeMetadata,
deployMeta, &pod.Spec, &pod.ObjectMeta, proxyCfg) // nolint: lll
deployMeta, &pod.Spec, &pod.ObjectMeta, proxyCfg)
if err != nil {
handleError(fmt.Sprintf("Injection data: err=%v spec=%v\n", err, iStatus))
return toV1beta1AdmissionResponse(err)
@@ -1028,7 +1031,7 @@ func (wh *Webhook) injectV1(ar *v1.AdmissionReview) *v1.AdmissionResponse {
func (wh *Webhook) serveInject(w http.ResponseWriter, r *http.Request) {
var body []byte
if r.Body != nil {
if data, err := ioutil.ReadAll(r.Body); err == nil {
if data, err := io.ReadAll(r.Body); err == nil {
body = data
}
}
4 changes: 2 additions & 2 deletions pkg/polarisapi/config_api.go
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ func CreateConfigMap(configMap *v1.ConfigMap) (ConfigResponse, error) {
if err != nil {
return ConfigResponse{}, err
}
if err := releaseConfigMap(req); err != nil {
if err = releaseConfigMap(req); err != nil {
return ConfigResponse{}, err
}
return resp, err
@@ -62,7 +62,7 @@ func UpdateConfigMap(configMap *v1.ConfigMap) (ConfigResponse, error) {
if err != nil {
return ConfigResponse{}, err
}
if err := releaseConfigMap(req); err != nil {
if err = releaseConfigMap(req); err != nil {
return ConfigResponse{}, err
}
return resp, err
29 changes: 12 additions & 17 deletions pkg/polarisapi/service_api.go
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"math"
"net/http"
"strconv"
@@ -92,8 +92,7 @@ func AddInstances(instances []Instance, size int, msg string) (err error) {
return
}

_, body, times, err :=
polarisHttpRequest(requestID, http.MethodPost, url, requestByte)
_, body, times, err := polarisHttpRequest(requestID, http.MethodPost, url, requestByte)
if err != nil {
log.SyncNamingScope().Errorf("Failed request %s [%d/%d], err %v. (%s)", msg, i+1, page, err, requestID)
polarisErrors.Append(PError{
@@ -207,8 +206,7 @@ func DeleteInstances(instances []Instance, size int, msg string) (err error) {
return
}
var response AddResponse
statusCode, body, times, err :=
polarisHttpRequest(requestID, http.MethodPost, url, requestByte)
statusCode, body, times, err := polarisHttpRequest(requestID, http.MethodPost, url, requestByte)

if err != nil {
log.SyncNamingScope().Errorf("Failed to request %s [%d/%d], err %v. (%s)",
@@ -365,8 +363,7 @@ func UpdateInstances(instances []Instance, size int, msg string) (err error) {
return polarisErrors.GetError()
}

func dealUpdateInstanceResponse(response AddResponse, msg string,
i int, page int, polarisErrors *PErrors) {
func dealUpdateInstanceResponse(response AddResponse, msg string, i int, page int, polarisErrors *PErrors) {
// 添加成功或者权限错误,都跳过
if response.Code == 200000 {
log.SyncNamingScope().Infof("Success add all %s [%d/%d], info %s.", msg, i+1, page, response.Info)
@@ -542,7 +539,7 @@ func CreateService(service *v1.Service) (CreateServicesResponse, error) {
}
if response.Code != ExistedResource {
log.SyncNamingScope().Errorf("Failed to create service %s %v", serviceMsg, response.Info)
return response, fmt.Errorf("create namespace failed: " + response.Info)
return response, fmt.Errorf("create namespace failed: %s", response.Info)
}
}

@@ -606,7 +603,7 @@ func CreateServiceAlias(service *v1.Service) (CreateServiceAliasResponse, error)
}
if response.Code != ExistedResource {
log.SyncNamingScope().Errorf("Failed to create service alias %s %v", serviceAliasMsg, response.Info)
return response, fmt.Errorf("create service alias failed: " + response.Info)
return response, fmt.Errorf("create service alias failed: %s", response.Info)
}
}

@@ -651,7 +648,7 @@ func UpdateService(service *v1.Service, request []Service) (int, PutServicesResp
return statusCode, PutServicesResponse{}, err
}
log.SyncNamingScope().Errorf("Failed to update result %s %v", serviceMsg, response.Info)
return statusCode, response, fmt.Errorf("Put service failed: " + response.Info)
return statusCode, response, fmt.Errorf("Put service failed: %s ", response.Info)
}

return statusCode, response, nil
@@ -700,7 +697,7 @@ func CreateNamespaces(namespace string) (CreateNamespacesResponse, error) {
if response.Responses == nil || len(response.Responses) == 0 ||
response.Responses[0].Code != ExistedResource {
log.SyncNamingScope().Errorf("Failed to create namespace %s ,error response: %v", namespace, response)
return response, fmt.Errorf("create namespace failed: " + response.Info)
return response, fmt.Errorf("create namespace failed: %s", response.Info)
}
}

@@ -744,10 +741,8 @@ func splitArray(instances []Instance, size int) [][]Instance {
}

// polarisHttpRequest
func polarisHttpRequest(
requestID string, method string,
url string, requestByte []byte) (int, []byte, time.Duration, error) {

func polarisHttpRequest(requestID string, method string, url string, requestByte []byte) (int, []byte, time.Duration,
error) {
startTime := time.Now()
req, err := http.NewRequest(method, url, bytes.NewReader(requestByte))
if err != nil {
@@ -773,7 +768,7 @@ func polarisHttpRequest(

defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)

if err != nil {
log.Errorf("Failed to get request %v", err)
@@ -803,7 +798,7 @@ func lookAccessToken() (string, error) {
return "", err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Errorf("Failed to get request %v", err)
return "", err
2 changes: 2 additions & 0 deletions pkg/util/flag/flags.go
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ type IPVar struct {
Val *string
}

// nolint
// Set sets the flag value
func (v IPVar) Set(s string) error {
if len(s) == 0 {
@@ -83,6 +84,7 @@ type IPPortVar struct {
Val *string
}

// nolint
// Set sets the flag value
func (v IPPortVar) Set(s string) error {
if len(s) == 0 {
33 changes: 17 additions & 16 deletions pkg/util/helper.go
Original file line number Diff line number Diff line change
@@ -47,22 +47,23 @@ const (
func WaitForAPIServer(client clientset.Interface, timeout time.Duration) error {
var lastErr error

err := wait.PollImmediate(time.Second, timeout, func() (bool, error) {
healthStatus := 0
result := client.Discovery().RESTClient().Get().AbsPath("/healthz").Do(context.TODO()).StatusCode(&healthStatus)
if result.Error() != nil {
lastErr = fmt.Errorf("failed to get apiserver /healthz status: %v", result.Error())
return false, nil
}
if healthStatus != http.StatusOK {
content, _ := result.Raw()
lastErr = fmt.Errorf("APIServer isn't healthy: %v", string(content))
log.Warnf("APIServer isn't healthy yet: %v. Waiting a little while.", string(content))
return false, nil
}

return true, nil
})
err := wait.PollUntilContextTimeout(context.Background(), time.Second, timeout, true,
func(ctx context.Context) (bool, error) {
healthStatus := 0
result := client.Discovery().RESTClient().Get().AbsPath("/healthz").Do(context.TODO()).StatusCode(&healthStatus)
if result.Error() != nil {
lastErr = fmt.Errorf("failed to get apiserver /healthz status: %v", result.Error())
return false, nil
}
if healthStatus != http.StatusOK {
content, _ := result.Raw()
lastErr = fmt.Errorf("APIServer isn't healthy: %v", string(content))
log.Warnf("APIServer isn't healthy yet: %v. Waiting a little while.", string(content))
return false, nil
}

return true, nil
})

if err != nil {
return fmt.Errorf("%v: %v", err, lastErr)
3 changes: 3 additions & 0 deletions pkg/util/scheduler.go
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ import (
"sync"
"sync/atomic"
"time"

"github.com/polarismesh/polaris-controller/common/log"
)

func NewExecutor(size int) *TaskExecutor {
@@ -130,6 +132,7 @@ func (w *worker) addDelay(delay time.Duration, f func(), isInterval bool) {
defer func() {
if err := recover(); err != nil {
// do nothing
log.Warnf("addDelay error:%+v", err)
}
}()
f()