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: introduce handshake to client and gRPC server #42

Merged
merged 8 commits into from
Apr 11, 2023
Merged

feat: introduce handshake to client and gRPC server #42

merged 8 commits into from
Apr 11, 2023

Conversation

whynowy
Copy link
Member

@whynowy whynowy commented Apr 4, 2023

Description

This PR introduces a handshake to the client (numa container) and the gRPC server (UDF/UDSink), it is used to provide the server information such as protocol (UDS, TCP), language, version (SDK), etc. The client (Numaflow) is supposed to
get the information before starting gRPC connections. These information can be used to:

  • Determine what is the right protocol to connect to the gRPC server.
  • What is the language and the version of the SDK (for backward compatibility purpose)

File-based information exchange is done before starting the gRPC server.

Similarly in Python and Java SDKs, we need to implement same mechanism, and populate the right information.

In terms of checking lib version at runtime:

Python

>>> from importlib.metadata import version
>>> version('lxml')
'4.3.1'

Java

# Make sure the correct version information is stored in jar-file MANIFEST.MF
getClass().getPackage().getImplementationVersion()

NodeJS is supposed to have a way to get the version info.
https://stackoverflow.com/questions/29741373/check-package-version-at-runtime-in-nodejs

@whynowy whynowy requested a review from a team April 4, 2023 06:52
@ashwinidulams
Copy link

do we have explicit ordering for udf and numa containers today?

Comment on lines +17 to +19
Go Language = "go"
Python Language = "python"
Java Language = "java"
Copy link
Member

Choose a reason for hiding this comment

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

why do we need to track each language on numaflow-go?

Copy link
Member Author

Choose a reason for hiding this comment

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

Our sdk versions are not consistent. We should have a mapping in numaflow code to track all the versions for compatibility check.

@vigith
Copy link
Member

vigith commented Apr 4, 2023

The info-server is used only in the bootup; will it have any purpose after that? If this is only for a one-time information exchange, should we just pass it over a file or something as an initial handshake mechanism?

@whynowy
Copy link
Member Author

whynowy commented Apr 4, 2023

do we have explicit ordering for udf and numa containers today?

There's no starting order for normal containers, so our numa container does a waituntilready during startup.

@whynowy
Copy link
Member Author

whynowy commented Apr 4, 2023

The info-server is used only in the bootup; will it have any purpose after that? If this is only for a one-time information exchange, should we just pass it over a file or something as an initial handshake mechanism?

It works with file. Thinking shall we get it integrated with the prometheus support together numaproj/numaflow#324.

@vigith
Copy link
Member

vigith commented Apr 4, 2023

The info-server is used only in the bootup; will it have any purpose after that? If this is only for a one-time information exchange, should we just pass it over a file or something as an initial handshake mechanism?

It works with file. Thinking shall we get it integrated with the prometheus support together numaproj/numaflow#324.

I do not think it is wise to integrate numaproj/numaflow#324 since it is very opinionated. Let's keep this as lightweight as possible so that the resource usage will be minimal and only on the bootup.

@whynowy whynowy marked this pull request as draft April 5, 2023 15:17
@whynowy whynowy marked this pull request as ready for review April 10, 2023 23:52
@whynowy whynowy requested a review from vigith April 10, 2023 23:52
@whynowy whynowy changed the title feat: introduce info server feat: introduce handshake to client and gRPC server Apr 10, 2023
)

func GetSDKVersion() string {
version := "unknown"
Copy link
Member

Choose a reason for hiding this comment

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

is an empty string a better value than "unknown"?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated.

// Also check if the file is ready to read
// It takes some time for the server to write the server info file
// TODO: use a better way to wait for the file to be ready
b, err := os.ReadFile(options.svrInfoFilePath)
Copy link
Member

Choose a reason for hiding this comment

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

will a file.stat > 0 length be a good check?

return ctx.Err()
default:
time.Sleep(100 * time.Millisecond)
b, err = os.ReadFile(options.svrInfoFilePath)
Copy link
Member

Choose a reason for hiding this comment

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

how do we handle partial/in-progress writes, eg. numaflow starting reading early before the entire file has been flushed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to write an END mark.

// TODO: use a better way to wait for the file to be ready
retry := 0
b, err := os.ReadFile(options.svrInfoFilePath)
for len(b) == 0 && err == nil && retry < 10 {
Copy link
Member

Choose a reason for hiding this comment

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

will we break the loop too early because we read partial data?

.
Signed-off-by: Derek Wang <[email protected]>
@whynowy whynowy merged commit 7775e68 into main Apr 11, 2023
@whynowy whynowy deleted the info branch April 11, 2023 16:47
KeranYang added a commit to KeranYang/numaflow-java that referenced this pull request Apr 13, 2023
KeranYang added a commit to numaproj/numaflow-java that referenced this pull request Apr 14, 2023
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