diff --git a/pkg/common/log/log.go b/pkg/common/log/log.go index fc0b9b89c7cdb89e24c32b8c86a5dce8a7b6249c..6839f07ba719f081647da57070b0db25d77c2e2f 100644 --- a/pkg/common/log/log.go +++ b/pkg/common/log/log.go @@ -186,14 +186,14 @@ func rotateLog(line int64) string { } func writeLine(line string) { + lock.Lock() + defer lock.Unlock() + if logDriver == stdio { fmt.Printf("%s", line) return } - lock.Lock() - defer lock.Unlock() - f, err := os.OpenFile(rotateLog(int64(len(line))), os.O_CREATE|os.O_APPEND|os.O_WRONLY, constant.DefaultFileMode) if err != nil { return @@ -311,18 +311,3 @@ func (e *Entry) Errorf(f string, args ...interface{}) { } output(e.level(logError), f, args...) } - -// EmptyLog is an empty log structure without any log processing -type EmptyLog struct{} - -// Warnf write logs -func (e *EmptyLog) Warnf(f string, args ...interface{}) {} - -// Infof write logs -func (e *EmptyLog) Infof(f string, args ...interface{}) {} - -// Debugf write verbose logs -func (e *EmptyLog) Debugf(f string, args ...interface{}) {} - -// Errorf write error logs -func (e *EmptyLog) Errorf(f string, args ...interface{}) {} diff --git a/pkg/common/util/file.go b/pkg/common/util/file.go index 970a18148d347233ce5e68a10380e9b66eb9e603..5a67b72ed8ecca264915d7560a5a394d87ddae29 100644 --- a/pkg/common/util/file.go +++ b/pkg/common/util/file.go @@ -125,7 +125,7 @@ func WriteFile(path, content string) error { dirPath := filepath.Dir(path) if !PathExist(dirPath) { if err := os.MkdirAll(dirPath, constant.DefaultDirMode); err != nil { - return fmt.Errorf("error create dir %v: %v", dirPath, err) + return fmt.Errorf("error creating dir %v: %v", dirPath, err) } } return ioutil.WriteFile(path, []byte(content), constant.DefaultFileMode) @@ -146,10 +146,10 @@ func AppendFile(path, content string) error { } }() if err != nil { - return fmt.Errorf("error open file: %v", err) + return fmt.Errorf("error opening file: %v", err) } if _, err := f.WriteString(content); err != nil { - return fmt.Errorf("error write file: %v", err) + return fmt.Errorf("error writing file: %v", err) } return nil } diff --git a/pkg/common/util/math.go b/pkg/common/util/math.go index c0031b35532666c5fa1277dbfc719a008290f228..d4d38138b47978e296e1ea44c4dee9a51af56fe0 100644 --- a/pkg/common/util/math.go +++ b/pkg/common/util/math.go @@ -2,7 +2,7 @@ // rubik licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: -// http://license.coscl.org.cn/MulanPSL2 +// http://license.coscl.org.cn/MulanPSL2 // THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR // PURPOSE. @@ -10,7 +10,6 @@ // Author: Jiaqi Yang // Date: 2023-02-08 // Description: This file is used for math - package util import ( @@ -24,7 +23,7 @@ import ( func Div(dividend, divisor float64, args ...interface{}) float64 { var ( format = "" - accuracy float64 = 0 + accuracy float64 = 1e-9 maxValue = math.MaxFloat64 ) const ( @@ -47,9 +46,7 @@ func Div(dividend, divisor float64, args ...interface{}) float64 { format = value } } - if divisor == 0 { - return maxValue - } + if math.Abs(divisor) <= accuracy { return maxValue } diff --git a/pkg/services/dyncache/dynamic.go b/pkg/services/dyncache/dynamic.go index d74efc74d7633c0871475069c7faddf272e8c2bd..6b18f626b62902bdc9917df1647c8661d03048c6 100644 --- a/pkg/services/dyncache/dynamic.go +++ b/pkg/services/dyncache/dynamic.go @@ -26,9 +26,9 @@ import ( "isula.org/rubik/pkg/core/typedef/cgroup" ) -// StartDynamic will continuously run to detect online pod cache miss and +// startDynamic will continuously run to detect online pod cache miss and // limit offline pod cache usage -func (c *DynCache) StartDynamic() { +func (c *DynCache) startDynamic() { if !c.dynamicExist() { return } diff --git a/pkg/services/dyncache/dynamic_test.go b/pkg/services/dyncache/dynamic_test.go index 54a101157d44fcef1895f0b98a423a01ffd29bfb..6508eca6fb28643d571ef64d9b8275b74d5e254a 100644 --- a/pkg/services/dyncache/dynamic_test.go +++ b/pkg/services/dyncache/dynamic_test.go @@ -27,7 +27,7 @@ import ( "isula.org/rubik/tests/try" ) -// TestCacheLimit_StartDynamic tests StartDynamic of CacheLimit +// TestCacheLimit_StartDynamic tests startDynamic of CacheLimit func TestCacheLimit_StartDynamic(t *testing.T) { if !perf.Support() { t.Skipf("%s only run on physical machine", t.Name()) @@ -273,7 +273,7 @@ func TestCacheLimit_StartDynamic(t *testing.T) { if tt.preHook != nil { tt.preHook(t, c, tt.fields.FakePods) } - c.StartDynamic() + c.startDynamic() if tt.postHook != nil { tt.postHook(t, c, tt.fields.FakePods) } diff --git a/pkg/services/dyncache/dyncache.go b/pkg/services/dyncache/dyncache.go index ee6a8ab6e85e88f0474f9c29049eb09c56e55cfc..2e14e04b94ef50fef8cd81a7ae33aac1c5daa34b 100644 --- a/pkg/services/dyncache/dyncache.go +++ b/pkg/services/dyncache/dyncache.go @@ -123,7 +123,7 @@ func (i DynCacheFactory) Name() string { // NewObj to create object of dyncache. func (i DynCacheFactory) NewObj() (interface{}, error) { - return NewDynCache(i.ObjName), nil + return newDynCache(i.ObjName), nil } func newConfig() *Config { @@ -146,8 +146,8 @@ func newConfig() *Config { } } -// NewDynCache return cache limit instance with default settings -func NewDynCache(name string) *DynCache { +// newDynCache return cache limit instance with default settings +func newDynCache(name string) *DynCache { return &DynCache{ ServiceBase: helper.ServiceBase{ Name: name, @@ -168,9 +168,12 @@ func (c *DynCache) IsRunner() bool { // PreStart will do some pre-setting actions func (c *DynCache) PreStart(viewer api.Viewer) error { + if viewer == nil { + return fmt.Errorf("invalid pods viewer") + } c.Viewer = viewer - if err := c.InitCacheLimitDir(); err != nil { + if err := c.initCacheLimitDir(); err != nil { return err } return nil @@ -183,8 +186,8 @@ func (c *DynCache) GetConfig() interface{} { // Run implement service run function func (c *DynCache) Run(ctx context.Context) { - go wait.Until(c.SyncCacheLimit, time.Second, ctx.Done()) - wait.Until(c.StartDynamic, time.Millisecond*time.Duration(c.config.AdjustInterval), ctx.Done()) + go wait.Until(c.syncCacheLimit, time.Second, ctx.Done()) + wait.Until(c.startDynamic, time.Millisecond*time.Duration(c.config.AdjustInterval), ctx.Done()) } // SetConfig sets and checks Config diff --git a/pkg/services/dyncache/dyncache_init.go b/pkg/services/dyncache/dyncache_init.go index fc9926d8eb1496d3e76252d19e3991a462298316..86a5dce4903aed3e3d208c130d3e8a0d6a1903c4 100644 --- a/pkg/services/dyncache/dyncache_init.go +++ b/pkg/services/dyncache/dyncache_init.go @@ -38,9 +38,8 @@ type limitSet struct { mbPercent int } -// InitCacheLimitDir init multi-level cache limit directories -func (c *DynCache) InitCacheLimitDir() error { - log.Debugf("init cache limit directory") +// initCacheLimitDir init multi-level cache limit directories +func (c *DynCache) initCacheLimitDir() error { const ( defaultL3PercentMax = 100 defaultMbPercentMax = 100 diff --git a/pkg/services/dyncache/dyncache_init_test.go b/pkg/services/dyncache/dyncache_init_test.go index 0a738ddf1ac573589c9cf8a7f7079e86281d2fad..aebe0e237178a71ef83fd111b6ca8dcf6ead38d5 100644 --- a/pkg/services/dyncache/dyncache_init_test.go +++ b/pkg/services/dyncache/dyncache_init_test.go @@ -43,7 +43,7 @@ func genNumaNodes(path string, num int) { } } -// TestCacheLimit_InitCacheLimitDir tests InitCacheLimitDir of CacheLimit +// TestCacheLimit_InitCacheLimitDir tests initCacheLimitDir of CacheLimit func TestCacheLimit_InitCacheLimitDir(t *testing.T) { if !perf.Support() { t.Skipf("%s only run on physical machine", t.Name()) @@ -218,8 +218,8 @@ func TestCacheLimit_InitCacheLimitDir(t *testing.T) { if tt.preHook != nil { tt.preHook(t, c) } - if err := c.InitCacheLimitDir(); (err != nil) != tt.wantErr { - t.Errorf("CacheLimit.InitCacheLimitDir() error = %v, wantErr %v", err, tt.wantErr) + if err := c.initCacheLimitDir(); (err != nil) != tt.wantErr { + t.Errorf("CacheLimit.initCacheLimitDir() error = %v, wantErr %v", err, tt.wantErr) } if tt.postHook != nil { tt.postHook(t, c) diff --git a/pkg/services/dyncache/dyncache_test.go b/pkg/services/dyncache/dyncache_test.go index 79216537d23ab8c37a5ae3093565e6bf5f92a79b..86a8c6eaf5c8a7ca9afc0bc3f7f1121a0211b25f 100644 --- a/pkg/services/dyncache/dyncache_test.go +++ b/pkg/services/dyncache/dyncache_test.go @@ -28,7 +28,7 @@ const ( moduleName = "dynCache" ) -// TestCacheLimit_StartDynamic tests StartDynamic of CacheLimit +// TestCacheLimit_StartDynamic tests startDynamic of CacheLimit func TestCacheLimit_Validate(t *testing.T) { const num2 = 2 type fields struct { @@ -236,7 +236,7 @@ func TestNewCacheLimit(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := NewDynCache(moduleName); !reflect.DeepEqual(got, tt.want) { + if got := newDynCache(moduleName); !reflect.DeepEqual(got, tt.want) { t.Errorf("NewCacheLimit() = %v, want %v", got, tt.want) } }) diff --git a/pkg/services/dyncache/sync.go b/pkg/services/dyncache/sync.go index 0d92f35453fa40e65d9c316301dc5435f70ccb60..5d461581c10a7d7b4d7cd5449da362f78cba8b04 100644 --- a/pkg/services/dyncache/sync.go +++ b/pkg/services/dyncache/sync.go @@ -46,7 +46,7 @@ var validLevel = map[string]bool{ } // SyncCacheLimit will continuously set cache limit with corresponding offline pods -func (c *DynCache) SyncCacheLimit() { +func (c *DynCache) syncCacheLimit() { for _, p := range c.listOfflinePods() { if err := c.syncLevel(p); err != nil { log.Errorf("failed to sync cache limit level: %v", err) diff --git a/pkg/services/dyncache/sync_test.go b/pkg/services/dyncache/sync_test.go index 7079f8d259e099ac21b350d780f481ef32b5ecf1..e20c5a3872144fa191886560e504c0bc9e9015cd 100644 --- a/pkg/services/dyncache/sync_test.go +++ b/pkg/services/dyncache/sync_test.go @@ -253,7 +253,7 @@ func TestCacheLimit_SyncCacheLimit(t *testing.T) { if tt.preHook != nil { tt.preHook(t, c, tt.fields.FakePods) } - c.SyncCacheLimit() + c.syncCacheLimit() cleanFakePods(tt.fields.FakePods) }) } diff --git a/pkg/services/dynmemory/dynmemory.go b/pkg/services/dynmemory/dynmemory.go index ede767c777ea607f5f81af3f8fe0c8971f571f18..f8b0978eed011551fe8763f55e1270a0537a6682 100644 --- a/pkg/services/dynmemory/dynmemory.go +++ b/pkg/services/dynmemory/dynmemory.go @@ -45,6 +45,9 @@ type DynMemory struct { // PreStart is an interface for calling a collection of methods when the service is pre-started func (dynMem *DynMemory) PreStart(viewer api.Viewer) error { + if viewer == nil { + return fmt.Errorf("invalid pods viewer") + } if dynMem.dynMemoryAdapter == nil { return nil } diff --git a/pkg/services/iocost/iocost.go b/pkg/services/iocost/iocost.go index 2efc1c13947af5d4b0122c17ff91c3666d1feadf..3513a35bb287cd5e3475c790b2efbf6e6c3f7aa6 100644 --- a/pkg/services/iocost/iocost.go +++ b/pkg/services/iocost/iocost.go @@ -154,6 +154,9 @@ func (io *IOCost) loadConfig(nodeConfig *NodeConfig) error { // PreStart is the pre-start action func (io *IOCost) PreStart(viewer api.Viewer) error { + if viewer == nil { + return fmt.Errorf("invalid pods viewer") + } return io.dealExistedPods(viewer) } diff --git a/pkg/services/preemption/preemption.go b/pkg/services/preemption/preemption.go index 28ec36e12bef605691535088f15b5632dd98c2b3..6dae21f83baaa5c18416f217db1b1228d26fb64a 100644 --- a/pkg/services/preemption/preemption.go +++ b/pkg/services/preemption/preemption.go @@ -59,6 +59,10 @@ func (i PreemptionFactory) NewObj() (interface{}, error) { // SetConfig to config Preemption configure func (q *Preemption) SetConfig(f helper.ConfigHandler) error { + if f == nil { + return fmt.Errorf("no config handler function callback") + } + var c PreemptionConfig if err := f(q.Name, &c); err != nil { return err @@ -72,6 +76,9 @@ func (q *Preemption) SetConfig(f helper.ConfigHandler) error { // PreStart is the pre-start action func (q *Preemption) PreStart(viewer api.Viewer) error { + if viewer == nil { + return fmt.Errorf("invalid pods viewer") + } for _, pod := range viewer.ListPodsWithOptions() { if err := q.SetQoSLevel(pod); err != nil { log.Errorf("failed to set the qos level for the previously started pod %v: %v", pod.Name, err) @@ -85,7 +92,7 @@ func (q *Preemption) AddPod(pod *typedef.PodInfo) error { if err := q.SetQoSLevel(pod); err != nil { return err } - if err := q.ValidateConfig(pod); err != nil { + if err := q.validateConfig(pod); err != nil { return err } return nil @@ -100,7 +107,7 @@ func (q *Preemption) UpdatePod(old, new *typedef.PodInfo) error { case newQos > oldQos: return fmt.Errorf("does not support pod qos level setting from low to high") default: - if err := q.ValidateConfig(new); err != nil { + if err := q.validateConfig(new); err != nil { if err := q.SetQoSLevel(new); err != nil { return fmt.Errorf("failed to update the qos level of pod %s(%s): %v", new.Name, new.UID, err) } @@ -114,9 +121,9 @@ func (q *Preemption) DeletePod(pod *typedef.PodInfo) error { return nil } -// ValidateConfig will validate pod's qos level between value from +// validateConfig will validate pod's qos level between value from // cgroup file and the one from pod info -func (q *Preemption) ValidateConfig(pod *typedef.PodInfo) error { +func (q *Preemption) validateConfig(pod *typedef.PodInfo) error { targetLevel := getQoSLevel(pod) for _, r := range q.config.Resource { if err := pod.GetCgroupAttr(supportCgroupTypes[r]).Expect(targetLevel); err != nil { @@ -138,7 +145,7 @@ func (q *Preemption) SetQoSLevel(pod *typedef.PodInfo) error { } qosLevel := getQoSLevel(pod) if qosLevel == constant.Online { - log.Infof("pod %s has already been set to online", pod.Name) + log.Infof("pod %s(%s) has already been set to online(%d)", pod.Name, pod.UID, qosLevel) return nil } @@ -152,7 +159,7 @@ func (q *Preemption) SetQoSLevel(pod *typedef.PodInfo) error { } } } - log.Infof("the qos level of pod %s(%s) is set to %d successfully", pod.Name, pod.UID, qosLevel) + log.Infof("pod %s(%s) is set to offline(%d) successfully", pod.Name, pod.UID, qosLevel) return nil } @@ -170,7 +177,7 @@ func getQoSLevel(pod *typedef.PodInfo) int { // Validate will validate the qos service config func (conf *PreemptionConfig) Validate() error { if len(conf.Resource) == 0 { - return fmt.Errorf("empty qos config") + return fmt.Errorf("empty resource preemption configuration") } for _, r := range conf.Resource { if _, ok := supportCgroupTypes[r]; !ok { diff --git a/pkg/services/psi/psi.go b/pkg/services/psi/psi.go index 44e16eab1081b11eec2eda37a6b51f621b60a494..29db5876962137d45c7834036c86e640ec7df2cb 100644 --- a/pkg/services/psi/psi.go +++ b/pkg/services/psi/psi.go @@ -118,6 +118,10 @@ func (m *Manager) Run(ctx context.Context) { // SetConfig sets and checks Config func (m *Manager) SetConfig(f helper.ConfigHandler) error { + if f == nil { + return fmt.Errorf("no config handler function callback") + } + var conf = NewConfig() if err := f(m.Name, conf); err != nil { return err @@ -136,6 +140,9 @@ func (m *Manager) IsRunner() bool { // PreStart is the pre-start action func (m *Manager) PreStart(viewer api.Viewer) error { + if viewer == nil { + return fmt.Errorf("invalid pods viewer") + } m.Viewer = viewer return nil } diff --git a/pkg/services/quotaburst/quotaburst.go b/pkg/services/quotaburst/quotaburst.go index 615ecbfde988fe992d5e3b207184f50a563e366e..a3faefc094a786a6b04d4c4cae348d1c854ef97c 100644 --- a/pkg/services/quotaburst/quotaburst.go +++ b/pkg/services/quotaburst/quotaburst.go @@ -71,6 +71,9 @@ func (conf *Burst) DeletePod(podInfo *typedef.PodInfo) error { // PreStart is the pre-start action func (conf *Burst) PreStart(viewer api.Viewer) error { + if viewer == nil { + return fmt.Errorf("invalid pods viewer") + } pods := viewer.ListPodsWithOptions() for _, pod := range pods { if err := setPodQuotaBurst(pod); err != nil { diff --git a/pkg/services/quotaturbo/quotaturbo.go b/pkg/services/quotaturbo/quotaturbo.go index 3814973ffa362cbb8ad368bf12d1d8186572ab35..48c1c1de3ac705cc36074cd857ba9086636d3660 100644 --- a/pkg/services/quotaturbo/quotaturbo.go +++ b/pkg/services/quotaturbo/quotaturbo.go @@ -105,25 +105,23 @@ func (qt *QuotaTurbo) syncCgroups(conts map[string]*typedef.ContainerInfo) { existedCgroupPathMap[id] = struct{}{} if _, found := conts[id]; !found { if err := qt.client.RemoveCgroup(path); err != nil { - log.Errorf("error removing container %v: %v", id, err) + log.Errorf("failed to remove container %v: %v", id, err) } else { - log.Infof("remove container %v", id) + log.Infof("remove container %v successfully", id) } } } for id, cont := range conts { - /* - Currently, modifying the cpu limit and container id of the container will cause the container to restart, - so it is considered that the cgroup path and cpulimit will not change during the life cycle of the container - */ + // Currently, modifying the cpu limit and container id of the container will cause the container to restart, + // so it is considered that the cgroup path and cpulimit will not change during the life cycle of the container if _, ok := existedCgroupPathMap[id]; ok { continue } // add container to quotaturbo if err := qt.client.AddCgroup(cont.Path, cont.LimitResources[typedef.ResourceCPU]); err != nil { - log.Errorf("error adding container %v: %v", cont.Name, err) + log.Errorf("failed to add container %v: %v", cont.Name, err) } else { - log.Infof("add container %v", id) + log.Infof("add container %v successfully", id) } } } @@ -132,7 +130,7 @@ func (qt *QuotaTurbo) syncCgroups(conts map[string]*typedef.ContainerInfo) { func (qt *QuotaTurbo) AdjustQuota(conts map[string]*typedef.ContainerInfo) { qt.syncCgroups(conts) if err := qt.client.AdjustQuota(); err != nil { - log.Errorf("error occur when adjust quota: %v", err) + log.Errorf("an error occurred while adjusting the quota: %v", err) } } @@ -174,6 +172,10 @@ func (conf *Config) Validate() error { // SetConfig sets and checks Config func (qt *QuotaTurbo) SetConfig(f helper.ConfigHandler) error { + if f == nil { + return fmt.Errorf("no config handler function callback") + } + var conf = NewConfig() if err := f(qt.Name, conf); err != nil { return err @@ -197,6 +199,9 @@ func (qt *QuotaTurbo) IsRunner() bool { // PreStart is the pre-start action func (qt *QuotaTurbo) PreStart(viewer api.Viewer) error { + if viewer == nil { + return fmt.Errorf("invalid pods viewer") + } // 1. set the parameters of the quotaturbo client qt.client.WithOptions( quotaturbo.WithCgroupRoot(cgroup.GetMountDir()), @@ -224,7 +229,7 @@ func (qt *QuotaTurbo) Terminate(viewer api.Viewer) error { func recoverOnePodQuota(pod *typedef.PodInfo) { const unlimited = "-1" if err := pod.SetCgroupAttr(cpuQuotaKey, unlimited); err != nil { - log.Errorf("failed to set the cpu quota of the pod %v to -1: %v", pod.UID, err) + log.Errorf("failed to set the cpu quota of the pod %v to unlimited(-1): %v", pod.UID, err) return } @@ -238,10 +243,10 @@ func recoverOnePodQuota(pod *typedef.PodInfo) { if cont.LimitResources[typedef.ResourceCPU] == 0 { unlimitedContExistd = true if err := cont.SetCgroupAttr(cpuQuotaKey, unlimited); err != nil { - log.Errorf("failed to set the cpu quota of the container %v to -1: %v", cont.ID, err) + log.Errorf("failed to set the cpu quota of the container %v to unlimited(-1): %v", cont.ID, err) continue } - log.Debugf("set the cpu quota of the container %v to -1", cont.ID) + log.Debugf("set the cpu quota of the container %v to unlimited(-1)", cont.ID) continue } @@ -250,7 +255,8 @@ func recoverOnePodQuota(pod *typedef.PodInfo) { log.Errorf("failed to get cpu period of container %v : %v", cont.ID, err) continue } - + // the value range of cpu.cfs_period_us is 1000 (1ms) to 1000000 (1s), + // the number of CPUs configured to the container will not exceed the number of physical machine cores contQuota := int64(cont.LimitResources[typedef.ResourceCPU] * float64(period)) podQuota += contQuota if err := cont.SetCgroupAttr(cpuQuotaKey, util.FormatInt64(contQuota)); err != nil { @@ -261,7 +267,7 @@ func recoverOnePodQuota(pod *typedef.PodInfo) { } if !unlimitedContExistd { if err := pod.SetCgroupAttr(cpuQuotaKey, util.FormatInt64(podQuota)); err != nil { - log.Errorf("failed to set the cpu quota of the pod %v to -1: %v", pod.UID, err) + log.Errorf("failed to set the cpu quota of the pod %v to unlimited(-1): %v", pod.UID, err) return } log.Debugf("set the cpu quota of the pod %v to %v", pod.UID, podQuota) diff --git a/pkg/services/service.go b/pkg/services/service.go index 7fdaac1e941d9c40def7de166b07ad59f3d01acd..f0d8eda975ef1eb329e1aebca16a7f3e24bb2869 100644 --- a/pkg/services/service.go +++ b/pkg/services/service.go @@ -73,18 +73,18 @@ type FeatureSpec struct { func InitServiceComponents(specs []FeatureSpec) { for _, spec := range specs { if !spec.Default { - log.Warnf("feature is disabled by default:%v", spec.Name) + log.Warnf("feature is disabled by default: %v", spec.Name) continue } initFunc, found := serviceComponents[spec.Name] if !found { - log.Errorf("initialize service failed, name:%v", spec.Name) + log.Errorf("initialize service failed: %v", spec.Name) continue } if err := initFunc(spec.Name); err != nil { - log.Warnf("initialize component failed, name:%v,error:%v", spec.Name, err) + log.Warnf("initialize component failed: %v, error:%v", spec.Name, err) } } } diff --git a/pkg/version/version.go b/pkg/version/version.go index e8163fbce6ee954747df985691c5710d2580fe82..13bc473c8656ec48e782c7230943f9022aff6976 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -32,13 +32,8 @@ var ( ) func init() { - var showVersion bool const maxArgLen = 2 if len(os.Args) == maxArgLen && os.Args[1] == "-v" { - showVersion = true - } - - if showVersion { fmt.Println("Version: ", Version) fmt.Println("Release: ", Release) fmt.Println("Go Version: ", runtime.Version())