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

[Connector API] Allow Connector status transition to the same status for CONNECTED, CONFIGURED, ERROR #109671

Merged
merged 6 commits into from
Jun 24, 2024

Conversation

jedrazb
Copy link
Member

@jedrazb jedrazb commented Jun 13, 2024

Changes

Update valid status transitions for Connector. We should allow transition to same status for following statuses:

  • CONNECTED (e.g. starting a sync if connector status is already connected)
  • CONFIGURED (when sending multiple reqs to update configuration)
  • ERROR (when multiple concurrent running jobs report error, e.g. content sync and access control job)

Validations

  • unit tests
  • manual test

@jedrazb jedrazb marked this pull request as ready for review June 13, 2024 11:55
@elasticsearchmachine elasticsearchmachine added the Team:SearchOrg Meta label for the Search Org (Enterprise Search) label Jun 13, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ent-search-eng (Team:SearchOrg)

@jedrazb
Copy link
Member Author

jedrazb commented Jun 13, 2024

@elasticmachine merge upstream

Copy link
Member

@artem-shelkovnikov artem-shelkovnikov left a comment

Choose a reason for hiding this comment

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

While it makes sense, I'm hesitant - some transitions are natural (CONNECTED -> CONNECTED is okay), but some are... weird?

CREATED -> CREATED - can it even happen?
ERROR -> ERROR - I guess it's when connector consistently errors out?
CONFIGURED -> CONFIGURED - I guess it happens if you edit configuration and then quickly edit it again, before it's transitioned to CONNECTED?

return VALID_TRANSITIONS.getOrDefault(current, Collections.emptySet());
Set<ConnectorStatus> nextStates = new HashSet<>(VALID_TRANSITIONS.getOrDefault(current, Collections.emptySet()));
// Transition to the same state is allowed
nextStates.add(current);
Copy link
Member

Choose a reason for hiding this comment

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

Why not just add the explicit states in VALID_TRANSITIONS?
This obfuscates what are actually valid transitions by splitting the logic between that literal map and this function.

@jedrazb
Copy link
Member Author

jedrazb commented Jun 19, 2024

Thank you both for reviewing, yeah it makes sense to explicitly state this in the transition table. Let me update the PR :)

@jedrazb
Copy link
Member Author

jedrazb commented Jun 19, 2024

@elasticmachine merge upstream

1 similar comment
@jedrazb
Copy link
Member Author

jedrazb commented Jun 19, 2024

@elasticmachine merge upstream

@jedrazb jedrazb changed the title [Connector API] Allow status transition to the same status [Connector API] Allow Connector status transition to the same status for CONNECTED, CONFIGURED, ERROR Jun 19, 2024
@jedrazb
Copy link
Member Author

jedrazb commented Jun 19, 2024

@seanstory @artem-shelkovnikov I updated the PR. The changes are now to allow transition to same status for following statuses:

  • CONNECTED (e.g. starting a sync if connector status is already connected)
  • CONFIGURED (when sending multiple reqs to update configuration)
  • ERROR (when multiple concurrent running jobs report error, e.g. content sync and access control job)

I'm changing this just for connectors. I don't think SyncJob logic needs any changes

Copy link
Member

@seanstory seanstory left a comment

Choose a reason for hiding this comment

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

LGTM

@jedrazb jedrazb merged commit 7b28814 into elastic:main Jun 24, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :SearchOrg/Extract&Transform Label for the Search E&T team Team:Search - Extract & Transform Team:SearchOrg Meta label for the Search Org (Enterprise Search) v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants