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: generalize watermark fetching as an interface of ISB service. Fixes #252 #263

Merged
merged 11 commits into from
Oct 25, 2022

Conversation

KeranYang
Copy link
Member

@KeranYang KeranYang commented Oct 24, 2022

Description

Fixes #252 This change is to NOT hardcode JetStream as ISB service when fetching watermarks. When the ISB service is Redis, we use noop KV watchers(for both heartbeat and offset timeline) for fetching watermarks.

Testing

Before the change, if we use Redis as ISB service, when creating a simple-pipeline, the simple-pipeline-daemon-xxx pod crashes with following error:

Error: failed to create grpc server: failed to create watermark fetcher  failed to get nats connection, environment variable "NUMAFLOW_ISBSVC_JETSTREAM_URL" not found
Usage:
  numaflow daemon-server [flags]

Flags:
  -h, --help                 help for daemon-server
      --isbsvc-type string   ISB Service type, e.g. jetstream (default "jetstream")

panic: failed to create grpc server: failed to create watermark fetcher  failed to get nats connection, environment variable "NUMAFLOW_ISBSVC_JETSTREAM_URL" not found

goroutine 1 [running]:
github.com/numaproj/numaflow/cmd/commands.Execute()
	/Users/kyang5/Desktop/development/numaflow/numaflow/cmd/commands/root.go:17 +0x45
main.main()
	/Users/kyang5/Desktop/development/numaflow/numaflow/cmd/main.go:8 +0x17

And numaflow UI shows empty page for simple-pipeline.

After the change, when using Redis as ISB, we can start the simple-pipeline-daemon-xxx pod successfully. On the UI, we show default watermark -1 across ALL vertices.
redis

Signed-off-by: Keran Yang [email protected]

Explain what this PR does.

@KeranYang KeranYang changed the title refactor: generalize watermark fetching as an interface of ISB service refactor: generalize watermark fetching as an interface of ISB service Fixes #252 Oct 24, 2022
@KeranYang KeranYang marked this pull request as ready for review October 25, 2022 16:21
@KeranYang
Copy link
Member Author

On issue #252 , there is also the following request

  1. Single jetstream connection, and need to handle close.

@whynowy Hey Derek, regarding the request above, is it already resolved by https://github.com/numaproj/numaflow/pull/238/files?

@@ -21,6 +25,21 @@ type jetStreamSvc struct {
js *jsclient.JetStreamContext
}

func (jss *jetStreamSvc) CreateWatermarkFetcher(ctx context.Context, pipelineName string, bufferName string) (fetch.Fetcher, error) {
Copy link
Member

Choose a reason for hiding this comment

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

pipelineName is already a property of the struct, not needed in the function signature.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Addressed.

@@ -21,6 +25,21 @@ type jetStreamSvc struct {
js *jsclient.JetStreamContext
}

func (jss *jetStreamSvc) CreateWatermarkFetcher(ctx context.Context, pipelineName string, bufferName string) (fetch.Fetcher, error) {
hbBucketName := JetStreamProcessorBucket(pipelineName, bufferName)
hbWatch, err := jetstream.NewKVJetStreamKVWatch(ctx, pipelineName, hbBucketName, jsclient.NewInClusterJetStreamClient())
Copy link
Member

Choose a reason for hiding this comment

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

Use the jetstream client in the struct.

return nil, err
}
otBucketName := JetStreamOTBucket(pipelineName, bufferName)
otWatch, err := jetstream.NewKVJetStreamKVWatch(ctx, pipelineName, otBucketName, jsclient.NewInClusterJetStreamClient())
Copy link
Member

Choose a reason for hiding this comment

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

same here.

@vigith vigith changed the title refactor: generalize watermark fetching as an interface of ISB service Fixes #252 refactor: generalize watermark fetching as an interface of ISB service. Fixes #252 Oct 25, 2022
vigith
vigith previously approved these changes Oct 25, 2022
hbWatch, err := jetstream.NewKVJetStreamKVWatch(ctx, pipelineName, hbBucketName, jsclient.NewInClusterJetStreamClient())
func (jss *jetStreamSvc) CreateWatermarkFetcher(ctx context.Context, bufferName string) (fetch.Fetcher, error) {
hbBucketName := JetStreamProcessorBucket(jss.pipelineName, bufferName)
hbWatch, err := jetstream.NewKVJetStreamKVWatch(ctx, jss.pipelineName, hbBucketName, jsclient.NewInClusterJetStreamClient())
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 you need a new client, can't we get it from jss.jsClient

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. There are two types of jsClient - defaultJetStreamClient and inClusterJetStreamClient. Searching across the code base I see defaultJetStreamClient is only used in unit test files so I think it's safe to get jsClient from jss.jsClient. Will address.

@vigith vigith dismissed their stale review October 25, 2022 19:45

reuse client

Signed-off-by: Keran Yang <[email protected]>
@@ -21,6 +25,21 @@ type jetStreamSvc struct {
js *jsclient.JetStreamContext
}

func (jss *jetStreamSvc) CreateWatermarkFetcher(ctx context.Context, bufferName string) (fetch.Fetcher, error) {
Copy link
Member

@whynowy whynowy Oct 25, 2022

Choose a reason for hiding this comment

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

Nit: move this function to the place after NewISBJetStreamSvc(, let it sit together with other interface functions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, addressed.

Signed-off-by: Keran Yang <[email protected]>
@KeranYang KeranYang merged commit 8ff9e28 into numaproj:main Oct 25, 2022
whynowy pushed a commit that referenced this pull request Oct 27, 2022
Fixes #252 (#263)

### Description
Fixes #252 This change is to NOT hardcode JetStream as ISB service when fetching watermarks. When the ISB service is Redis, we use noop KV watchers(for both heartbeat and offset timeline) for fetching watermarks.

Signed-off-by: Keran Yang <[email protected]>
@KeranYang KeranYang deleted the generic-watermark-fetching branch November 15, 2022 19:51
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.

Do not hard code to use JetStream in pipeline_watermark_query.go
3 participants