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

Refactor collector mains #2060

Merged
merged 17 commits into from
Feb 11, 2020
Merged

Refactor collector mains #2060

merged 17 commits into from
Feb 11, 2020

Conversation

jpkrohling
Copy link
Contributor

@jpkrohling jpkrohling commented Feb 7, 2020

Which problem is this PR solving?

Short description of the changes

  • Each commit is a refactoring unit and can be analyzed alone: each commit passes the tests from make test and both all-in-one and collector start successfully
  • The first 4 commits are in preparation for the fourth, to avoid cyclic imports
  • The fifth commit is similar to Improved graceful shutdown - Agent #2031, but without some of the graceful shutdown parts
  • Then, a few changes based on the reviews for Improved graceful shutdown - Agent #2031
  • The remaining commits are further smaller refactoring, moving the servers to a specific package, plus consolidating the old grpcserver into server/grpc.go.
  • And finally, split the server's networking parts from the serving parts, so that they are more testable. Tests not included.

I think this PR is already big enough on its own, so, I won't continue the refactoring of all-in-one as part of this commit.

@jpkrohling jpkrohling requested a review from a team as a code owner February 7, 2020 15:56
}

// Close the component and all its underlying dependencies
func (c *Collector) Close() error {
Copy link
Member

Choose a reason for hiding this comment

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

You either forget to return error or you can change the signature without error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The return type is part of the io.Closer interface.

Copy link
Member

Choose a reason for hiding this comment

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

Then return the error. There are several return assignments in this function and none error being returned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no error that we would want to bubble up from here. For instance, when issuing a Close(), we don't want to break the routine when the HTTP server failed to close, as that would result in the Zipkin server not being closed.

Copy link
Member

Choose a reason for hiding this comment

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

It does not mean that the error has to be returned immediatelly. It can be wrapped and returned at the end of the function. Hopefully, this function is not used by many clients...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting idea. If the HTTP server and Zipkin fails, Zipkin will end up wrapping the HTTP server failure. Not sure that's intuitive from the perspective of the admin looking at the logs.

Hopefully, this function is not used by many clients...

It's being used by the main.go of both the Collector and All In One.

cmd/collector/app/processor/span.go Outdated Show resolved Hide resolved
cmd/collector/app/server/grpc.go Show resolved Hide resolved
cmd/collector/app/server/thrift.go Outdated Show resolved Hide resolved
cmd/collector/app/server/zipkin.go Show resolved Hide resolved
cmd/collector/app/server/zipkin.go Outdated Show resolved Hide resolved
@pavolloffay pavolloffay changed the title Refactor mains Refactor collector mains Feb 10, 2020
@codecov
Copy link

codecov bot commented Feb 10, 2020

Codecov Report

Merging #2060 into master will decrease coverage by 1.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2060      +/-   ##
==========================================
- Coverage   97.41%   96.38%   -1.04%     
==========================================
  Files         209      214       +5     
  Lines       10351    10525     +174     
==========================================
+ Hits        10083    10144      +61     
- Misses        224      325     +101     
- Partials       44       56      +12     
Impacted Files Coverage Δ
cmd/collector/app/handler/thrift_span_handler.go 94.73% <0.00%> (ø)
cmd/collector/app/server/thrift.go 0.00% <0.00%> (ø)
cmd/collector/app/server/grpc.go 67.85% <0.00%> (ø)
cmd/collector/app/server/http.go 0.00% <0.00%> (ø)
cmd/collector/app/server/zipkin.go 0.00% <0.00%> (ø)
cmd/collector/app/collector.go 73.80% <0.00%> (ø)
cmd/collector/app/server/test.go 50.00% <0.00%> (ø)
cmd/query/app/server.go 94.52% <0.00%> (+2.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2411e5...2e8d8cb. Read the comment docs.

@jpkrohling
Copy link
Contributor Author

Review addressed + conflicts solved.

Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
@jpkrohling
Copy link
Contributor Author

The rename of processor.SpanProcessor has been reverted and the PR has been rebased.

@jpkrohling
Copy link
Contributor Author

Coverage is failing, which is kinda expected, as the refactored code didn't have any tests at all, except for the gRPC server, which was kept.

Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

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

LGTM, except the function signatures which return an error but in reality they do not return any error - serveZipkin, serverThrift

cmd/collector/app/server/http.go Outdated Show resolved Hide resolved
cmd/collector/app/server/zipkin.go Show resolved Hide resolved
cmd/collector/app/server/zipkin.go Outdated Show resolved Hide resolved
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
@jpkrohling jpkrohling merged commit 3ae21ef into jaegertracing:master Feb 11, 2020
@@ -0,0 +1,93 @@
// Copyright (c) 2020 The Jaeger Authors.
Copy link
Member

Choose a reason for hiding this comment

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

This file seems to be replacing cmd/collector/app/grpcserver/grpc_server.go, which was deleted (git didn't recognize it as a move).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you mean to set the copyright headers to // Copyright (c) 2018 The Jaeger Authors. here, as it was in the grpc_server.go file?

}

grpcPortStr := ":" + strconv.Itoa(params.Port)
listener, err := net.Listen("tcp", grpcPortStr)
Copy link
Member

Choose a reason for hiding this comment

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

Future TODO: similar to query-service that runs both http and grpc servers on the same port, we could do the same for collector.

type HTTPServerParams struct {
Port int
Handler handler.JaegerBatchesHandler
RecoveryHandler func(http.Handler) http.Handler
Copy link
Member

Choose a reason for hiding this comment

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

why does this need to be exposed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I get the question. The HTTPServerParams instance is created by the Collector#Start in cmd/collector/app...

Copy link
Member

Choose a reason for hiding this comment

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

the recovery handler is a mechanical thing that can be added silently, it's weird to have it exposed via API like this.

@jpkrohling
Copy link
Contributor Author

I'll work on @yurishkuro's comments as soon as #2031 is merged, as there's potential for conflicts here.

jpkrohling added a commit that referenced this pull request Feb 28, 2020
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
@jpkrohling jpkrohling deleted the RefactorMains branch July 28, 2021 19:22
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.

4 participants