[#1361] linter: fix funlen and ignoring grpc deprecated warnings
Some checks failed
DCO action / DCO (pull_request) Successful in 55s
Tests and linters / Run gofumpt (pull_request) Successful in 2m5s
Vulncheck / Vulncheck (pull_request) Successful in 2m22s
Tests and linters / gopls check (pull_request) Failing after 2m42s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m50s
Tests and linters / Staticcheck (pull_request) Failing after 3m7s
Build / Build Components (pull_request) Successful in 3m28s
Tests and linters / Lint (pull_request) Successful in 4m48s
Tests and linters / Tests (pull_request) Successful in 9m51s
Tests and linters / Tests with -race (pull_request) Successful in 11m30s

Signed-off-by: Aleksey Savaitan <a.savaitan@yadro.com>
This commit is contained in:
Aleksey Savaitan 2024-09-12 17:42:20 +03:00
parent a37154b0f0
commit c46c605341
4 changed files with 36 additions and 24 deletions

View file

@ -24,6 +24,7 @@ func _client(ctx context.Context) (tree.TreeServiceClient, error) {
return nil, err return nil, err
} }
//nolint staticcheck
opts := []grpc.DialOption{ opts := []grpc.DialOption{
grpc.WithBlock(), grpc.WithBlock(),
grpc.WithChainUnaryInterceptor( grpc.WithChainUnaryInterceptor(
@ -44,6 +45,7 @@ func _client(ctx context.Context) (tree.TreeServiceClient, error) {
const defaultClientConnectTimeout = time.Second * 2 const defaultClientConnectTimeout = time.Second * 2
ctx, cancel := context.WithTimeout(ctx, defaultClientConnectTimeout) ctx, cancel := context.WithTimeout(ctx, defaultClientConnectTimeout)
//nolint staticcheck
cc, err := grpc.DialContext(ctx, netAddr.URIAddr(), opts...) cc, err := grpc.DialContext(ctx, netAddr.URIAddr(), opts...)
cancel() cancel()

View file

@ -1278,7 +1278,6 @@ func (c *cfg) reloadConfig(ctx context.Context) {
// all the components are expected to support // all the components are expected to support
// Logger's dynamic reconfiguration approach // Logger's dynamic reconfiguration approach
var components []dCmp
// Logger // Logger
@ -1288,6 +1287,36 @@ func (c *cfg) reloadConfig(ctx context.Context) {
return return
} }
components := c.getComponents(ctx, logPrm)
// Storage Engine
var rcfg engine.ReConfiguration
for _, optsWithID := range c.shardOpts(ctx) {
rcfg.AddShard(optsWithID.configID, append(optsWithID.shOpts, shard.WithTombstoneSource(c.createTombstoneSource())))
}
err = c.cfgObject.cfgLocalStorage.localStorage.Reload(ctx, rcfg)
if err != nil {
c.log.Error(logs.FrostFSNodeStorageEngineConfigurationUpdate, zap.Error(err))
return
}
for _, component := range components {
err = component.reloadFunc()
if err != nil {
c.log.Error(logs.FrostFSNodeUpdatedConfigurationApplying,
zap.String("component", component.name),
zap.Error(err))
}
}
c.log.Info(logs.FrostFSNodeConfigurationHasBeenReloadedSuccessfully)
}
func (c *cfg) getComponents(ctx context.Context, logPrm *logger.Prm) []dCmp {
var components []dCmp
components = append(components, dCmp{"logger", logPrm.Reload}) components = append(components, dCmp{"logger", logPrm.Reload})
components = append(components, dCmp{"runtime", func() error { components = append(components, dCmp{"runtime", func() error {
setRuntimeParameters(c) setRuntimeParameters(c)
@ -1321,29 +1350,7 @@ func (c *cfg) reloadConfig(ctx context.Context) {
components = append(components, dCmp{cmp.name, func() error { return cmp.reload(ctx) }}) components = append(components, dCmp{cmp.name, func() error { return cmp.reload(ctx) }})
} }
// Storage Engine return components
var rcfg engine.ReConfiguration
for _, optsWithID := range c.shardOpts(ctx) {
rcfg.AddShard(optsWithID.configID, append(optsWithID.shOpts, shard.WithTombstoneSource(c.createTombstoneSource())))
}
err = c.cfgObject.cfgLocalStorage.localStorage.Reload(ctx, rcfg)
if err != nil {
c.log.Error(logs.FrostFSNodeStorageEngineConfigurationUpdate, zap.Error(err))
return
}
for _, component := range components {
err = component.reloadFunc()
if err != nil {
c.log.Error(logs.FrostFSNodeUpdatedConfigurationApplying,
zap.String("component", component.name),
zap.Error(err))
}
}
c.log.Info(logs.FrostFSNodeConfigurationHasBeenReloadedSuccessfully)
} }
func (c *cfg) reloadPools() error { func (c *cfg) reloadPools() error {

View file

@ -87,6 +87,7 @@ func dialTreeService(ctx context.Context, netmapAddr string) (*grpc.ClientConn,
return nil, err return nil, err
} }
//nolint staticcheck
opts := []grpc.DialOption{ opts := []grpc.DialOption{
grpc.WithBlock(), grpc.WithBlock(),
grpc.WithChainUnaryInterceptor( grpc.WithChainUnaryInterceptor(
@ -104,6 +105,7 @@ func dialTreeService(ctx context.Context, netmapAddr string) (*grpc.ClientConn,
} }
ctx, cancel := context.WithTimeout(ctx, defaultClientConnectTimeout) ctx, cancel := context.WithTimeout(ctx, defaultClientConnectTimeout)
//nolint staticcheck
cc, err := grpc.DialContext(ctx, netAddr.URIAddr(), opts...) cc, err := grpc.DialContext(ctx, netAddr.URIAddr(), opts...)
cancel() cancel()

View file

@ -333,6 +333,7 @@ func (s *Service) synchronizeTree(ctx context.Context, cid cid.ID, from uint64,
} }
func (*Service) dialCtx(egCtx context.Context, a network.Address) (*grpc.ClientConn, error) { func (*Service) dialCtx(egCtx context.Context, a network.Address) (*grpc.ClientConn, error) {
//nolint staticcheck
return grpc.DialContext(egCtx, a.URIAddr(), return grpc.DialContext(egCtx, a.URIAddr(),
grpc.WithChainUnaryInterceptor( grpc.WithChainUnaryInterceptor(
metrics.NewUnaryClientInterceptor(), metrics.NewUnaryClientInterceptor(),