Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] support refresh the config of syncer without redeploy servicec… #1468

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
5 changes: 3 additions & 2 deletions syncer/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import (
"fmt"
"path/filepath"

"github.com/go-chassis/go-archaius"

"github.com/apache/servicecomb-service-center/pkg/log"
"github.com/apache/servicecomb-service-center/pkg/util"
"github.com/go-chassis/go-archaius"
)

var config Config
Expand All @@ -45,7 +46,7 @@ type Peer struct {
}

func Init() error {
err := archaius.AddFile(filepath.Join(util.GetAppRoot(), "conf", "syncer.yaml"))
err := archaius.AddFile(filepath.Join(util.GetAppRoot(), "conf", "syncer", "syncer.yaml"))
if err != nil {
log.Warn(fmt.Sprintf("can not add syncer config file source, error: %s", err))
return err
Expand Down
6 changes: 6 additions & 0 deletions syncer/service/admin/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ func getPeerStatus(peerName string, clientConn *grpc.ClientConn) string {
reply, err := set.EventServiceClient.Health(context.Background(), &v1sync.HealthRequest{})
if err != nil || reply == nil {
log.Error("get peer health failed", err)
err1 := config.Reload()
if err1 != nil {
log.Error("reload syncer config fail", err1)
return rpc.HealthStatusAbnormal
}
Init()
return rpc.HealthStatusAbnormal
}
reportClockDiff(peerName, local, reply.LocalTimestamp)
Expand Down
15 changes: 13 additions & 2 deletions syncer/service/replicator/replicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
"context"
"fmt"

"github.com/go-chassis/foundation/gopool"
"google.golang.org/grpc"

"github.com/apache/servicecomb-service-center/client"
"github.com/apache/servicecomb-service-center/pkg/log"
"github.com/apache/servicecomb-service-center/pkg/rpc"
Expand All @@ -29,8 +32,6 @@ import (
syncerclient "github.com/apache/servicecomb-service-center/syncer/client"
"github.com/apache/servicecomb-service-center/syncer/config"
"github.com/apache/servicecomb-service-center/syncer/service/replicator/resource"
"github.com/go-chassis/foundation/gopool"
"google.golang.org/grpc"
)

const (
Expand Down Expand Up @@ -165,6 +166,16 @@ func (r *replicatorManager) replicate(ctx context.Context, el *v1sync.EventList)
for _, in := range els {
res, err := set.EventServiceClient.Sync(ctx, in)
if err != nil {
err1 := config.Reload()
if err1 != nil {
log.Error("reload syncer config fail", err1)
return nil, err
}
err2 := InitSyncClient()
if err2 != nil {
log.Error("reInit syncClient fail", err2)
return nil, err
}
return nil, err
}

Expand Down