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

Flow API: Custom resume endpoint and blackboxed cdc status endpoint #1711

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

Amogh-Bharadwaj
Copy link
Contributor

@Amogh-Bharadwaj Amogh-Bharadwaj commented May 13, 2024

Endpoints:

Custom sync:

/v1/flows/cdc/sync

Status:

/v1/mirrors/{flow_job_name}?include_flow_info=true|false

Authentication

Authentication for both endpoints is the SHA256 hash of the peerdb instance password

API Endpoint to Resume Mirror With Specified Syncs

This PR introduces an endpoint in our Flow API to resume mirrors with a request of custom number of syncs.

  • The number of syncs the client can request is, for now, a number between 1 and the MaxSyncsPerCDCFlow which is currently 32.
  • Syncs in this case refers to one sync flow - normalise flow pair.
  • This endpoint requires the mirror to be paused before hand.
  • Request validation checks the above along with whether the mirror name exists, etc.

Implementation:

Extends CDCFlowConfigUpdate to include number of syncs information.

message CDCFlowConfigUpdate {
  repeated TableMapping additional_tables = 1;
  uint32 batch_size = 2;
  uint64 idle_timeout = 3;
  int32 number_of_syncs = 4;
}
  • This is picked up in CDC flow after processing FlowConfigUpdate:
if state.FlowConfigUpdate != nil {
	err = processCDCFlowConfigUpdate(ctx, logger, cfg, state, mirrorNameSearch)
        if err != nil {
		return state, err
	}
	syncCountLimit = int(state.SyncFlowOptions.NumberOfSyncs)
  • Limit check is done when listening for normalise flow finishing:
normDoneChan.AddToSelector(mainLoopSelector, func(x struct{}, _ bool) {
	if syncCount == syncCountLimit {
		logger.Info("sync count limit reached, pausing",
		slog.Int("limit", syncCountLimit),
		slog.Int("count", syncCount))
		state.ActiveSignal = model.PauseSignal
	}

Functional testing:

  • Tested with a paused mirror with low sync interval via HTTP requests to this endpoint
  • Resume mirror via the normal UI button route will stick to existing behaviour of MaxSyncsPerCDCFlow=32 sync flows.
Screenshot 2024-05-10 at 5 25 18 PM Screenshot 2024-05-10 at 5 25 42 PM Screenshot 2024-05-10 at 5 27 36 PM

Mirror Status Endpoint

Existing mirror status endpoint now has a flag in the request to include flow information. The UI sets this flag. If not set, response only contains flow name and running status, along with clean error messages.

This endpoint is also gated by authorization

Functionally tested

@Amogh-Bharadwaj Amogh-Bharadwaj marked this pull request as ready for review May 13, 2024 08:04
@CLAassistant
Copy link

CLAassistant commented May 21, 2024

CLA assistant check
All committers have signed the CLA.

@Amogh-Bharadwaj Amogh-Bharadwaj force-pushed the api/custom-resume-endpoint branch 2 times, most recently from dcc8e69 to 85da32c Compare May 27, 2024 14:04
flow/connectors/core.go Outdated Show resolved Hide resolved
@Amogh-Bharadwaj Amogh-Bharadwaj changed the title Flow API: Custom resume endpoint Flow API: Custom resume endpoint and blackboxed cdc status endpoint May 27, 2024
@Amogh-Bharadwaj
Copy link
Contributor Author

Description updated with new status endpoint

protos/route.proto Outdated Show resolved Hide resolved
protos/route.proto Show resolved Hide resolved
flow/cmd/custom_sync.go Show resolved Hide resolved
flow/cmd/custom_sync.go Outdated Show resolved Hide resolved
flow/cmd/custom_sync.go Outdated Show resolved Hide resolved
flow/cmd/custom_sync.go Outdated Show resolved Hide resolved
protos/flow.proto Show resolved Hide resolved
flow/workflows/cdc_flow.go Show resolved Hide resolved
flow/cmd/custom_sync.go Outdated Show resolved Hide resolved
@Amogh-Bharadwaj
Copy link
Contributor Author

Updated description and functionally tested post changes

docker-compose-dev.yml Outdated Show resolved Hide resolved
@Amogh-Bharadwaj Amogh-Bharadwaj marked this pull request as draft May 30, 2024 16:12
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.

None yet

5 participants