From f83072522fc4571442d87ef7889de88c2f415bfe Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Thu, 31 Aug 2023 16:58:36 +0800 Subject: [PATCH] address the comment Signed-off-by: Ryan Leung --- pkg/mcs/scheduling/server/cluster.go | 4 +++- pkg/mcs/server/server.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/mcs/scheduling/server/cluster.go b/pkg/mcs/scheduling/server/cluster.go index 7f851afcb39..18cc55fbc16 100644 --- a/pkg/mcs/scheduling/server/cluster.go +++ b/pkg/mcs/scheduling/server/cluster.go @@ -22,6 +22,7 @@ import ( // Cluster is used to manage all information for scheduling purpose. type Cluster struct { + ctx context.Context *core.BasicCluster persistConfig *config.PersistConfig ruleManager *placement.RuleManager @@ -45,6 +46,7 @@ func NewCluster(ctx context.Context, persistConfig *config.PersistConfig, storag } ruleManager := placement.NewRuleManager(storage, basicCluster, persistConfig) c := &Cluster{ + ctx: ctx, BasicCluster: basicCluster, ruleManager: ruleManager, labelerManager: labelerManager, @@ -146,7 +148,7 @@ func (c *Cluster) AllocID() (uint64, error) { c.checkMembershipCh <- struct{}{} return 0, errors.New("API server leader is not found") } - resp, err := cli.AllocID(context.Background(), &pdpb.AllocIDRequest{Header: &pdpb.RequestHeader{ClusterId: c.clusterID}}) + resp, err := cli.AllocID(c.ctx, &pdpb.AllocIDRequest{Header: &pdpb.RequestHeader{ClusterId: c.clusterID}}) if err != nil { c.checkMembershipCh <- struct{}{} return 0, err diff --git a/pkg/mcs/server/server.go b/pkg/mcs/server/server.go index c5f05687d95..95b806e20ef 100644 --- a/pkg/mcs/server/server.go +++ b/pkg/mcs/server/server.go @@ -61,7 +61,7 @@ func (bs *BaseServer) Context() context.Context { return bs.ctx } -// GetDelegateClient returns grpc client connection talking to the forwarded host +// GetDelegateClient returns grpc client connection talking to the forwarded host. func (bs *BaseServer) GetDelegateClient(ctx context.Context, tlsCfg *grpcutil.TLSConfig, forwardedHost string) (*grpc.ClientConn, error) { client, ok := bs.clientConns.Load(forwardedHost) if !ok {