Skip to content

Commit ef94eb4

Browse files
committed
minor revise for better output
1 parent 34750be commit ef94eb4

File tree

7 files changed

+9
-13
lines changed

7 files changed

+9
-13
lines changed

client/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ func dial(ctx context.Context, addr string, authConfig types.AuthConfig) (*grpc.
4646
grpc.WithTransportCredentials(insecure.NewCredentials()),
4747
grpc.WithKeepaliveParams(keepalive.ClientParameters{Time: 6 * 60 * time.Second, Timeout: time.Second}),
4848
grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`), // This sets the initial balancing policy, see https://github.com/grpc/grpc-go/blob/v1.40.x/examples/features/load_balancing/client/main.go
49-
grpc.WithUnaryInterceptor(interceptor.NewUnaryRetry(interceptor.RetryOptions{Max: 1})),
50-
grpc.WithStreamInterceptor(interceptor.NewStreamRetry(interceptor.RetryOptions{Max: 1})),
49+
grpc.WithUnaryInterceptor(interceptor.NewUnaryRetry(interceptor.RetryOptions{Max: 0})),
50+
grpc.WithStreamInterceptor(interceptor.NewStreamRetry(interceptor.RetryOptions{Max: 0})),
5151
}
5252
if authConfig.Username != "" {
5353
opts = append(opts, grpc.WithPerRPCCredentials(auth.NewCredential(authConfig)))

cluster/calcium/node.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (c *Calcium) AddNode(ctx context.Context, opts *types.AddNodeOptions) (*typ
4949
return err
5050
}
5151
node.Resource.Capacity = res
52-
_ = c.pool.Invoke(func() { c.doSendNodeMetrics(ctx, node) })
52+
_ = c.pool.Invoke(func() { c.doSendNodeMetrics(context.TODO(), node) })
5353
return nil
5454
},
5555
// rollback: remove node with resource plugins
@@ -232,7 +232,7 @@ func (c *Calcium) SetNode(ctx context.Context, opts *types.SetNodeOptions) (*typ
232232
// actually we can ignore err here, if update success
233233
n.Resource.Capacity, n.Resource.Usage, n.Resource.Diffs, _ = c.rmgr.GetNodeResourceInfo(ctx, node.Name, nil, false)
234234
// use send to update the usage
235-
_ = c.pool.Invoke(func() { c.doSendNodeMetrics(ctx, n) })
235+
_ = c.pool.Invoke(func() { c.doSendNodeMetrics(context.TODO(), n) })
236236
return nil
237237
},
238238
// rollback: update node resource capacity in reverse

cluster/calcium/pod.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
// AddPod add pod
1111
func (c *Calcium) AddPod(ctx context.Context, podname, desc string) (*types.Pod, error) {
12-
logger := log.WithFunc("calcium.AddPod").WithField("podname", podname).WithField("desc", desc)
12+
logger := log.WithFunc("calcium.AddPod").WithField("podname", podname)
1313
if podname == "" {
1414
logger.Error(ctx, types.ErrEmptyPodName)
1515
return nil, types.ErrEmptyPodName

resource/cobalt/metrics.go

-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@ func (m Manager) GetMetricsDescription(ctx context.Context) ([]*plugintypes.Metr
1414
var metricsDescriptions []*plugintypes.MetricsDescription
1515
resps, err := call(ctx, m.plugins, func(plugin plugins.Plugin) (*plugintypes.GetMetricsDescriptionResponse, error) {
1616
resp, err := plugin.GetMetricsDescription(ctx)
17-
if err != nil {
18-
log.Errorf(ctx, err, "plugin %+v failed to get metrics description", plugin.Name())
19-
}
2017
return resp, err
2118
})
2219

2320
if err != nil {
24-
log.Error(ctx, err, "failed to get metrics description")
2521
return nil, err
2622
}
2723

resource/cobalt/node.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ func (m Manager) AddNode(ctx context.Context, nodename string, opts types.Resour
3131
func(ctx context.Context) error {
3232
resps, err := call(ctx, m.plugins, func(plugin plugins.Plugin) (*plugintypes.AddNodeResponse, error) {
3333
r := opts[plugin.Name()]
34+
logger.WithField("plugin", plugin.Name()).WithField("node", nodename).Infof(ctx, "%v", litter.Sdump(r))
3435
resp, err := plugin.AddNode(ctx, nodename, r, nodeInfo)
3536
if err != nil {
36-
logger.Errorf(ctx, err, "node %+v plugin %+v failed to add node, req: %+v", nodename, plugin.Name(), litter.Sdump(opts))
37+
logger.Errorf(ctx, err, "node %+v plugin %+v failed to add node, req: %+v", nodename, plugin.Name(), litter.Sdump(r))
3738
}
3839
return resp, err
3940
})
@@ -48,7 +49,6 @@ func (m Manager) AddNode(ctx context.Context, nodename string, opts types.Resour
4849
for plugin, resp := range resps {
4950
res[plugin.Name()] = resp.Capacity
5051
}
51-
5252
return nil
5353
},
5454
// rollback: remove node

resource/plugins/binary/binary.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Plugin struct {
1818

1919
// NewPlugin .
2020
func NewPlugin(ctx context.Context, path string, config coretypes.Config) (*Plugin, error) {
21-
p, err := filepath.Abs(ppath.Join(config.ResourcePlugin.Dir, path))
21+
p, err := filepath.Abs(path)
2222
if err != nil {
2323
return nil, err
2424
}

utils/transaction.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func Txn(ctx context.Context, cond contextFunc, then contextFunc, rollback func(
2525
return
2626
}
2727
if rollback == nil {
28-
logger.Error(ctx, nil, "txn failed but no rollback function")
28+
logger.Warn(ctx, "txn failed but no rollback function")
2929
return
3030
}
3131

0 commit comments

Comments
 (0)