feat: update d7y.io/api/v2 to v2.1.42 and report scheduler config to … (#4214)
feat: update d7y.io/api/v2 to v2.1.42 and report scheduler config to manager Signed-off-by: chlins <chlins.zhang@gmail.com>
This commit is contained in:
parent
93dc9ef852
commit
364530212d
2
go.mod
2
go.mod
|
|
@ -4,7 +4,7 @@ go 1.23.8
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.google.com/go/storage v1.50.0
|
cloud.google.com/go/storage v1.50.0
|
||||||
d7y.io/api/v2 v2.1.39
|
d7y.io/api/v2 v2.1.42
|
||||||
github.com/MysteriousPotato/go-lockable v1.0.0
|
github.com/MysteriousPotato/go-lockable v1.0.0
|
||||||
github.com/Showmax/go-fqdn v1.0.0
|
github.com/Showmax/go-fqdn v1.0.0
|
||||||
github.com/VividCortex/mysqlerr v1.0.0
|
github.com/VividCortex/mysqlerr v1.0.0
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -63,8 +63,8 @@ cloud.google.com/go/storage v1.50.0 h1:3TbVkzTooBvnZsk7WaAQfOsNrdoM8QHusXA1cpk6Q
|
||||||
cloud.google.com/go/storage v1.50.0/go.mod h1:l7XeiD//vx5lfqE3RavfmU9yvk5Pp0Zhcv482poyafY=
|
cloud.google.com/go/storage v1.50.0/go.mod h1:l7XeiD//vx5lfqE3RavfmU9yvk5Pp0Zhcv482poyafY=
|
||||||
cloud.google.com/go/trace v1.11.2 h1:4ZmaBdL8Ng/ajrgKqY5jfvzqMXbrDcBsUGXOT9aqTtI=
|
cloud.google.com/go/trace v1.11.2 h1:4ZmaBdL8Ng/ajrgKqY5jfvzqMXbrDcBsUGXOT9aqTtI=
|
||||||
cloud.google.com/go/trace v1.11.2/go.mod h1:bn7OwXd4pd5rFuAnTrzBuoZ4ax2XQeG3qNgYmfCy0Io=
|
cloud.google.com/go/trace v1.11.2/go.mod h1:bn7OwXd4pd5rFuAnTrzBuoZ4ax2XQeG3qNgYmfCy0Io=
|
||||||
d7y.io/api/v2 v2.1.39 h1:BxbccbEUooXuCr8aqRr5hNQONFdL7DOWo5pz2CnBg/0=
|
d7y.io/api/v2 v2.1.42 h1:JLBWPcVvTqClLedfRipHSIVkxEJFPQ5Mz1vnNo1Sklw=
|
||||||
d7y.io/api/v2 v2.1.39/go.mod h1:5DPjID9MNDgw0mOqf49KF6Mho4x2v+C3uKmWWQYCWUs=
|
d7y.io/api/v2 v2.1.42/go.mod h1:IbhylQWRkqRka+oUl73Fzz331fHFIAwS2m4cMNpFWdk=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
|
|
|
||||||
|
|
@ -470,6 +470,13 @@ func (s *managerServerV2) UpdateScheduler(ctx context.Context, req *managerv2.Up
|
||||||
schedulerFeatures = req.GetFeatures()
|
schedulerFeatures = req.GetFeatures()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var schedulerConfig models.JSONMap
|
||||||
|
if len(req.Config) > 0 {
|
||||||
|
if err := json.Unmarshal(req.Config, &schedulerConfig); err != nil {
|
||||||
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := s.db.WithContext(ctx).Model(&scheduler).Updates(models.Scheduler{
|
if err := s.db.WithContext(ctx).Model(&scheduler).Updates(models.Scheduler{
|
||||||
IDC: req.GetIdc(),
|
IDC: req.GetIdc(),
|
||||||
Location: req.GetLocation(),
|
Location: req.GetLocation(),
|
||||||
|
|
@ -478,6 +485,7 @@ func (s *managerServerV2) UpdateScheduler(ctx context.Context, req *managerv2.Up
|
||||||
SchedulerClusterID: uint(req.GetSchedulerClusterId()),
|
SchedulerClusterID: uint(req.GetSchedulerClusterId()),
|
||||||
Features: schedulerFeatures,
|
Features: schedulerFeatures,
|
||||||
LastKeepAliveAt: time.Now(),
|
LastKeepAliveAt: time.Now(),
|
||||||
|
Config: schedulerConfig,
|
||||||
}).Error; err != nil {
|
}).Error; err != nil {
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
}
|
}
|
||||||
|
|
@ -516,6 +524,13 @@ func (s *managerServerV2) createScheduler(ctx context.Context, req *managerv2.Up
|
||||||
schedulerFeatures = req.GetFeatures()
|
schedulerFeatures = req.GetFeatures()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var schedulerConfig models.JSONMap
|
||||||
|
if len(req.Config) > 0 {
|
||||||
|
if err := json.Unmarshal(req.Config, &schedulerConfig); err != nil {
|
||||||
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scheduler := models.Scheduler{
|
scheduler := models.Scheduler{
|
||||||
Hostname: req.GetHostname(),
|
Hostname: req.GetHostname(),
|
||||||
IDC: req.GetIdc(),
|
IDC: req.GetIdc(),
|
||||||
|
|
@ -525,6 +540,7 @@ func (s *managerServerV2) createScheduler(ctx context.Context, req *managerv2.Up
|
||||||
Features: schedulerFeatures,
|
Features: schedulerFeatures,
|
||||||
SchedulerClusterID: uint(req.GetSchedulerClusterId()),
|
SchedulerClusterID: uint(req.GetSchedulerClusterId()),
|
||||||
LastKeepAliveAt: time.Now(),
|
LastKeepAliveAt: time.Now(),
|
||||||
|
Config: schedulerConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.db.WithContext(ctx).Create(&scheduler).Error; err != nil {
|
if err := s.db.WithContext(ctx).Create(&scheduler).Error; err != nil {
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,12 @@ package announcer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
managerv2 "d7y.io/api/v2/pkg/apis/manager/v2"
|
managerv2 "d7y.io/api/v2/pkg/apis/manager/v2"
|
||||||
|
|
||||||
logger "d7y.io/dragonfly/v2/internal/dflog"
|
logger "d7y.io/dragonfly/v2/internal/dflog"
|
||||||
|
managertypes "d7y.io/dragonfly/v2/manager/types"
|
||||||
managerclient "d7y.io/dragonfly/v2/pkg/rpc/manager/client"
|
managerclient "d7y.io/dragonfly/v2/pkg/rpc/manager/client"
|
||||||
"d7y.io/dragonfly/v2/scheduler/config"
|
"d7y.io/dragonfly/v2/scheduler/config"
|
||||||
)
|
)
|
||||||
|
|
@ -59,6 +61,14 @@ func New(cfg *config.Config, managerClient managerclient.V2, schedulerFeatures [
|
||||||
opt(a)
|
opt(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Report scheduler configuration to manager.
|
||||||
|
config, err := json.Marshal(&managertypes.SchedulerConfig{
|
||||||
|
ManagerKeepAliveInterval: a.config.Manager.KeepAlive.Interval,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// Register to manager.
|
// Register to manager.
|
||||||
if _, err := a.managerClient.UpdateScheduler(context.Background(), &managerv2.UpdateSchedulerRequest{
|
if _, err := a.managerClient.UpdateScheduler(context.Background(), &managerv2.UpdateSchedulerRequest{
|
||||||
SourceType: managerv2.SourceType_SCHEDULER_SOURCE,
|
SourceType: managerv2.SourceType_SCHEDULER_SOURCE,
|
||||||
|
|
@ -69,6 +79,7 @@ func New(cfg *config.Config, managerClient managerclient.V2, schedulerFeatures [
|
||||||
Location: &a.config.Host.Location,
|
Location: &a.config.Host.Location,
|
||||||
SchedulerClusterId: uint64(a.config.Manager.SchedulerClusterID),
|
SchedulerClusterId: uint64(a.config.Manager.SchedulerClusterID),
|
||||||
Features: schedulerFeatures,
|
Features: schedulerFeatures,
|
||||||
|
Config: config,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,7 @@ func TestAnnouncer_Serve(t *testing.T) {
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
},
|
},
|
||||||
mock: func(data []byte, m *managerclientmocks.MockV2MockRecorder) {
|
mock: func(data []byte, m *managerclientmocks.MockV2MockRecorder) {
|
||||||
|
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
m.UpdateScheduler(gomock.Any(), gomock.Eq(&managerv2.UpdateSchedulerRequest{
|
m.UpdateScheduler(gomock.Any(), gomock.Eq(&managerv2.UpdateSchedulerRequest{
|
||||||
SourceType: managerv2.SourceType_SCHEDULER_SOURCE,
|
SourceType: managerv2.SourceType_SCHEDULER_SOURCE,
|
||||||
|
|
@ -170,6 +171,7 @@ func TestAnnouncer_Serve(t *testing.T) {
|
||||||
Location: &mockLocation,
|
Location: &mockLocation,
|
||||||
SchedulerClusterId: uint64(1),
|
SchedulerClusterId: uint64(1),
|
||||||
Features: managertypes.DefaultSchedulerFeatures,
|
Features: managertypes.DefaultSchedulerFeatures,
|
||||||
|
Config: []byte("{\"manager_keep_alive_interval\":50000000}"),
|
||||||
})).Times(1),
|
})).Times(1),
|
||||||
m.KeepAlive(gomock.Eq(50*time.Millisecond), gomock.Eq(&managerv2.KeepAliveRequest{
|
m.KeepAlive(gomock.Eq(50*time.Millisecond), gomock.Eq(&managerv2.KeepAliveRequest{
|
||||||
SourceType: managerv2.SourceType_SCHEDULER_SOURCE,
|
SourceType: managerv2.SourceType_SCHEDULER_SOURCE,
|
||||||
|
|
@ -244,6 +246,7 @@ func TestAnnouncer_announceToManager(t *testing.T) {
|
||||||
Location: &mockLocation,
|
Location: &mockLocation,
|
||||||
SchedulerClusterId: uint64(1),
|
SchedulerClusterId: uint64(1),
|
||||||
Features: managertypes.DefaultSchedulerFeatures,
|
Features: managertypes.DefaultSchedulerFeatures,
|
||||||
|
Config: []byte("{\"manager_keep_alive_interval\":50000000}"),
|
||||||
})).Times(1),
|
})).Times(1),
|
||||||
m.KeepAlive(gomock.Eq(50*time.Millisecond), gomock.Eq(&managerv2.KeepAliveRequest{
|
m.KeepAlive(gomock.Eq(50*time.Millisecond), gomock.Eq(&managerv2.KeepAliveRequest{
|
||||||
SourceType: managerv2.SourceType_SCHEDULER_SOURCE,
|
SourceType: managerv2.SourceType_SCHEDULER_SOURCE,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue