Skip to content

Commit a260314

Browse files
authored
chore: update client version (#3267)
* chore: update client version Signed-off-by: Gaius <gaius.qi@gmail.com> * feat: update client verison Signed-off-by: Gaius <gaius.qi@gmail.com> --------- Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent 3ddf37a commit a260314

File tree

10 files changed

+106
-10
lines changed

10 files changed

+106
-10
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ Join the conversation and help the community.
7171
- **Twitter**: [@dragonfly_oss](https://twitter.com/dragonfly_oss)
7272
- **DingTalk**: [22880028764](https://qr.dingtalk.com/action/joingroup?code=v1,k1,pkV9IbsSyDusFQdByPSK3HfCG61ZCLeb8b/lpQ3uUqI=&_dt_no_comment=1&origin=11)
7373

74-
<!-- markdownlint-disable -->
75-
<div align="center">
76-
<img src="docs/images/community/dingtalk-group.jpeg" width="300" title="dingtalk">
77-
</div>
78-
<!-- markdownlint-restore -->
79-
8074
## Contributing
8175

8276
You should check out our

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module d7y.io/dragonfly/v2
33
go 1.21
44

55
require (
6-
d7y.io/api/v2 v2.0.112
6+
d7y.io/api/v2 v2.0.113
77
github.com/MysteriousPotato/go-lockable v1.0.0
88
github.com/RichardKnop/machinery v1.10.8
99
github.com/Showmax/go-fqdn v1.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo
5151
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
5252
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
5353
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
54-
d7y.io/api/v2 v2.0.112 h1:I3HCB3GH1tWbp3pFSPIlx7r+XpPcl8UBcNz0A3Ftink=
55-
d7y.io/api/v2 v2.0.112/go.mod h1:L35KjMvZmedXQ6UGHieIddUT1ZZjUAJUqJ9lf52r4fw=
54+
d7y.io/api/v2 v2.0.113 h1:09Zo115B6wQI3Jn+RSUpLfzAmIA+0xgY3a03Ti6X+sw=
55+
d7y.io/api/v2 v2.0.113/go.mod h1:NMBc/M0ekCHgfn4wCJfLDXdDm/2wKMB0HOxpyUREGAk=
5656
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
5757
github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
5858
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=

internal/dflog/logger.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ func WithTaskAndPeerID(taskID, peerID string) *SugaredLoggerOnWith {
171171
}
172172
}
173173

174+
func WithHostAndTaskID(hostID, taskID string) *SugaredLoggerOnWith {
175+
return &SugaredLoggerOnWith{
176+
withArgs: []any{"hostID", hostID, "taskID", taskID},
177+
}
178+
}
179+
174180
func WithHostnameAndIP(hostname, ip string) *SugaredLoggerOnWith {
175181
return &SugaredLoggerOnWith{
176182
withArgs: []any{"hostname", hostname, "ip", ip},

pkg/rpc/scheduler/client/client_v2.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ type V2 interface {
134134
// Checks information of task.
135135
StatTask(context.Context, *schedulerv2.StatTaskRequest, ...grpc.CallOption) (*commonv2.Task, error)
136136

137+
// LeaveTask releases task in scheduler.
138+
LeaveTask(context.Context, *schedulerv2.LeaveTaskRequest, ...grpc.CallOption) error
139+
137140
// AnnounceHost announces host to scheduler.
138141
AnnounceHost(context.Context, *schedulerv2.AnnounceHostRequest, ...grpc.CallOption) error
139142

@@ -215,6 +218,20 @@ func (v *v2) StatTask(ctx context.Context, req *schedulerv2.StatTaskRequest, opt
215218
)
216219
}
217220

221+
// LeaveTask releases task in scheduler.
222+
func (v *v2) LeaveTask(ctx context.Context, req *schedulerv2.LeaveTaskRequest, opts ...grpc.CallOption) error {
223+
ctx, cancel := context.WithTimeout(ctx, contextTimeout)
224+
defer cancel()
225+
226+
_, err := v.SchedulerClient.LeaveTask(
227+
context.WithValue(ctx, pkgbalancer.ContextKey, req.TaskId),
228+
req,
229+
opts...,
230+
)
231+
232+
return err
233+
}
234+
218235
// AnnounceHost announces host to scheduler.
219236
func (v *v2) AnnounceHost(ctx context.Context, req *schedulerv2.AnnounceHostRequest, opts ...grpc.CallOption) error {
220237
ctx, cancel := context.WithTimeout(ctx, contextTimeout)

pkg/rpc/scheduler/client/mocks/client_v2_mock.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scheduler/metrics/metrics.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,20 @@ var (
194194
Help: "Counter of the number of failed of the stat task.",
195195
})
196196

197+
LeaveTaskCount = promauto.NewCounter(prometheus.CounterOpts{
198+
Namespace: types.MetricsNamespace,
199+
Subsystem: types.SchedulerMetricsName,
200+
Name: "leave_task_total",
201+
Help: "Counter of the number of the leaving task.",
202+
})
203+
204+
LeaveTaskFailureCount = promauto.NewCounter(prometheus.CounterOpts{
205+
Namespace: types.MetricsNamespace,
206+
Subsystem: types.SchedulerMetricsName,
207+
Name: "leave_task_failure_total",
208+
Help: "Counter of the number of failed of the leaving task.",
209+
})
210+
197211
AnnounceHostCount = promauto.NewCounterVec(prometheus.CounterOpts{
198212
Namespace: types.MetricsNamespace,
199213
Subsystem: types.SchedulerMetricsName,

scheduler/rpcserver/scheduler_server_v2.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ func (s *schedulerServerV2) StatTask(ctx context.Context, req *schedulerv2.StatT
124124
return resp, nil
125125
}
126126

127+
// LeaveTask releases task in scheduler.
128+
func (s *schedulerServerV2) LeaveTask(ctx context.Context, req *schedulerv2.LeaveTaskRequest) (*emptypb.Empty, error) {
129+
// Collect LeaseTaskCount metrics.
130+
metrics.LeaveTaskCount.Inc()
131+
if err := s.service.LeaveTask(ctx, req); err != nil {
132+
// Collect LeaseTaskFailureCount metrics.
133+
metrics.LeaveTaskFailureCount.Inc()
134+
return nil, err
135+
}
136+
137+
return new(emptypb.Empty), nil
138+
}
139+
127140
// AnnounceHost announces host to scheduler.
128141
func (s *schedulerServerV2) AnnounceHost(ctx context.Context, req *schedulerv2.AnnounceHostRequest) (*emptypb.Empty, error) {
129142
// Collect AnnounceHostCount metrics.

scheduler/service/service_v2.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,39 @@ func (v *V2) StatTask(ctx context.Context, req *schedulerv2.StatTaskRequest) (*c
462462
return resp, nil
463463
}
464464

465+
// LeaveTask releases task in scheduler.
466+
func (v *V2) LeaveTask(ctx context.Context, req *schedulerv2.LeaveTaskRequest) error {
467+
log := logger.WithHostAndTaskID(req.GetHostId(), req.GetTaskId())
468+
log.Infof("leave task request: %#v", req)
469+
470+
host, loaded := v.resource.HostManager().Load(req.GetHostId())
471+
if !loaded {
472+
msg := fmt.Sprintf("host %s not found", req.GetHostId())
473+
log.Error(msg)
474+
return status.Error(codes.NotFound, msg)
475+
}
476+
477+
host.Peers.Range(func(key, value any) bool {
478+
peer, ok := value.(*resource.Peer)
479+
if !ok {
480+
host.Log.Errorf("invalid peer %s %#v", key, value)
481+
return true
482+
}
483+
484+
if peer.Task.ID == req.GetTaskId() {
485+
if err := peer.FSM.Event(ctx, resource.PeerEventLeave); err != nil {
486+
msg := fmt.Sprintf("peer fsm event failed: %s", err.Error())
487+
peer.Log.Error(msg)
488+
return true
489+
}
490+
}
491+
492+
return true
493+
})
494+
495+
return nil
496+
}
497+
465498
// AnnounceHost announces host to scheduler.
466499
func (v *V2) AnnounceHost(ctx context.Context, req *schedulerv2.AnnounceHostRequest) error {
467500
logger.WithHostID(req.Host.GetId()).Infof("announce host request: %#v", req.GetHost())

0 commit comments

Comments
 (0)