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

fix/Nil panic in control service #2655

Merged
merged 1 commit into from
Nov 21, 2023
Merged

Conversation

carpawell
Copy link
Member

Split service creation on two steps:

  1. service creation with key initialization and basic health checks;
  2. service real initialization that includes internals reading (such as storage engine, tree service, etc).

The first one handles incoming requests when the app starts, the second one is responsible for the full work mode (storage engine initializations may take time in the real runs with the real objects stored).

Copy link

codecov bot commented Nov 21, 2023

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (67c5b02) 30.62% compared to head (77404cc) 30.61%.

Files Patch % Lines
cmd/neofs-node/main.go 0.00% 8 Missing ⚠️
cmd/neofs-node/control.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2655      +/-   ##
==========================================
- Coverage   30.62%   30.61%   -0.01%     
==========================================
  Files         406      406              
  Lines       30070    30066       -4     
==========================================
- Hits         9208     9206       -2     
+ Misses      20085    20082       -3     
- Partials      777      778       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@cthulhu-rider cthulhu-rider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall LGTM, left few suggestions


func (s *Server) ready() error {
if !s.available.Load() {
return status.Error(codes.Unavailable, "node has not started fully yet")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me node is smth higher level. I'd report service has not been completely initialized yet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -13,6 +14,12 @@ import (
// Server is an entity that serves
// Control service on storage node.
type Server struct {
// initialization sync; control service
// is the first service to run so no other
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first service to run is strange to see on the individual service: this field doesnt "know" what the app does, the app knows how Service behaves

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can understand you but think that is too much of an abstraction then, do not think the control service can be reused anywhere else, only for the node and only as a main controlling service

this field doesnt "know" what the app does

yes, but we need this service to be split now. not because it is good for it but because we need it for its caller and this comment would allow a future reader to understand it faster

anyway, fixed the comment

@@ -70,6 +58,17 @@ func initControlService(c *cfg) {
c.wg.Done()
})
}()

c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why async worker? U know exactly when all needed components are ready

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think that is our common pattern but it was about IR, fixed

}
// MarkReady marks server available. Before this call none of the other calls
// are available except for the health checks.
func (s *Server) MarkReady(e *engine.StorageEngine, nm netmap.Source, c container.Source, r *replicator.Replicator, st NodeState, tr TreeService) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to require all prms to be non-nil and insta panic otherwise

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Split service creation on two steps:
1. service creation with key initialization and basic health checks;
2. service real initialization that includes internals reading (such as storage
engine, tree service, etc).

The first one handles incoming requests when the app starts, the second one is
responsible for the full work mode (storage engine initializations may take
time in the real runs with the real objects stored).

Signed-off-by: Pavel Karpy <[email protected]>
@carpawell carpawell force-pushed the fix/control-svc-panic branch from 2825376 to 77404cc Compare November 21, 2023 17:32
Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what useful can we do with the control service if it's not ready yet?

@carpawell
Copy link
Member Author

So, what useful can we do with the control service if it's not ready yet?

Health checks (the can be improved, see #2585 (comment)) and closing #2585.

@roman-khimov roman-khimov merged commit 60e564f into master Nov 21, 2023
6 of 10 checks passed
@roman-khimov roman-khimov deleted the fix/control-svc-panic branch November 21, 2023 19:42
@roman-khimov
Copy link
Member

OK, we can have some more in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants