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 APIs] Update existing endpoints #2675

Merged
merged 7 commits into from
Jul 26, 2024

Conversation

jedrazb
Copy link
Member

@jedrazb jedrazb commented Jul 4, 2024

Hey 👋

As discussed, I reviewed the existing Connector API endpoints and added patches to update them to the 8.15 state.

Changes

  • index_name and error (including last_sync_error and last_access_control_sync_error) are the only properties that use semantic null. index_name can be set to null to detach the connector, error can be reset to null to indicate healthy state again. We are using optional for everything else.
  • Add sync_cursor field in the Connector definition (we missed it before) and add this as an arg to _last_sync endpoint (new payload field added in 8.15)
  • Updated the ConnectorFeatures representation as it included long-deprecated feature names (filtering_advanced_config and filtering_rules), add missing native_connector_api_keys

Note

We have this open issue with _last_sync endpoint (confusion between semantic null and optional when updating last_sync_*_error ). We are looking into fixing this.

Also, this PR should address existing endpoints, there are couple of endpoints that are still missing. Let's work on this patch first. :)

This comment was marked as outdated.

@l-trotta l-trotta self-assigned this Jul 4, 2024
@jedrazb jedrazb marked this pull request as ready for review July 4, 2024 16:58
@jedrazb
Copy link
Member Author

jedrazb commented Jul 4, 2024

Hey @l-trotta 👋 I see you assigned yourself to the issue. I tried addressing the concerns we discussed in the last call. Happy to answer any questions and address any other concerns!

EDIT: I see there are some failing tests, let me address it first

This comment has been minimized.

@pquentin
Copy link
Member

pquentin commented Jul 5, 2024

Hey @jedrazb, this is good timing because we just managed to add Connectors YAML tests to the flight recorder, so I reran validation and you can see the results in the above comment.

I can report that compared to the current state, this pull requests:

  • fixes last_sync, post and update_name requests
  • fixes sync_job_get responses

The rest is unchanged. I can open an issue listing the failures to not block this pull request which definitely improves things.

@jedrazb
Copy link
Member Author

jedrazb commented Jul 5, 2024

Hey @pquentin ! The changes that fix remaining issues should be minimal, I'm having issues running make validate locally due to vault permission issues. I will ask more in Slack!

This comment was marked as outdated.

@jedrazb
Copy link
Member Author

jedrazb commented Jul 5, 2024

Now it looks better! Two issues:

  • The issues around connector.get/list endpoint responses - we are adressing this for 8.16 in [Connector API] Don't index literal nulls to connector doc elasticsearch#110543:
    • Upon connector creation some fields get preset to null (to match the status quo from before). When handling the response, response definition is unhappy about null fields which are actually optional. If this doesn't break client we can probably ignore this until we change this in ES (?). null properties have been written to connector index with direct index access since 8.8 so there are tons of connectors with fields set to null
  • The issue with connector.update_configuration
    • In ES implementation we have a yaml test case where a crawler-specifc setting is updated via this endpoint. We should not be doing this - since we are not planning to manage crawler via this API.
    • Another test failure is with literal null tooltip being passed in the body (we could make it just optional in server implementation)

I think we can address those issues as a followup.

@l-trotta
Copy link
Contributor

I'm starting to consider mapping the connector request and response in two different classes, as you can see from the validator:
connector.get | 🔴 | 59/59 | 1/59 |
this is because in the response many types are not optional, for example
api_key_id?: string in the request
is actually
api_key_id: string | null in the response

This comment was marked as outdated.

@jedrazb
Copy link
Member Author

jedrazb commented Jul 23, 2024

Hey @l-trotta 👋 As we discussed in the call, I'm updating the spec to address main issues:

I'm starting to consider mapping the connector request and response in two different classes
++ Actually Connector type was only used to describe responses, so I updated the type accordingly.

I had to put tooltip property as string | null for the automated tests to pass. We always return tooltip field from the ES (even if it's null).

I marked last_sync_error and last_access_control_sync_error as just optional, until we address elastic/elasticsearch#110543 in ES.

There are just 2 failing test cases related to crawler state (in connector doc!). Due to historical reasons, some parts of the crawler state were, and still are, stored in the connector index. However, it was agreed that the connector API should not interact with the crawler, so those tests should be removed from ES. I don’t think these failures should block us in this PR, as this is a quirky edge case. Can explain more if needed :)

@jedrazb jedrazb requested a review from l-trotta July 23, 2024 13:43
@l-trotta
Copy link
Contributor

l-trotta commented Jul 24, 2024

Hey @jedrazb, got it we'll wait for the yaml tests to be fixed!
One thing I found: in the connector POST request there should be the connector id path parameter, to allow defining the connector custom name.

Also: sync_cursor?: Dictionary<string, UserDefinedValue> -> the server value for this is Object, and the return value for this when there's no data is null instead of what the server usually sends as an empty dictionary which is {}. This is problematic for some static clients that have no way of dealing with null dictionaries, so I'd suggest changing this to sync_cursor?: UserDefinedValue, which simplifies it.

@l-trotta
Copy link
Contributor

l-trotta commented Jul 24, 2024

Another thing: there are some properties in ConnectorConfigProperties that should be nullable. (for example default_value, depends_on...)

@jedrazb
Copy link
Member Author

jedrazb commented Jul 25, 2024

got it we'll wait for the yaml tests to be fixed!

Okok I see, let me get rid of those tests from the server first.

This comment was marked as outdated.

Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
connector.check_in 🟢 3/3 3/3
connector.delete 🟢 9/9 9/9
connector.get 🔴 60/60 59/60
connector.last_sync 🟢 7/7 7/7
connector.list 🟢 19/19 19/19
connector.post 🟢 7/7 7/7
connector.put 🟢 13/13 13/13
connector.secret_delete 🟠 Missing type Missing type
connector.secret_get 🟠 Missing type Missing type
connector.secret_post 🟠 Missing type Missing type
connector.secret_put 🟠 Missing type Missing type
connector.sync_job_cancel 🟢 3/3 3/3
connector.sync_job_check_in 🟠 Missing type Missing type
connector.sync_job_claim 🟠 Missing type Missing type
connector.sync_job_delete 🟢 4/4 4/4
connector.sync_job_error 🟠 Missing type Missing type
connector.sync_job_get 🟢 22/22 22/22
connector.sync_job_list 🟢 12/12 12/12
connector.sync_job_post 🟢 50/50 50/50
connector.sync_job_update_stats 🟠 Missing type Missing type
connector.update_active_filtering 🟢 1/1 1/1
connector.update_api_key_id 🟢 4/4 4/4
connector.update_configuration 🔴 8/9 9/9
connector.update_error 🟢 4/4 4/4
connector.update_features 🟠 Missing type Missing type
connector.update_filtering_validation 🟢 3/3 3/3
connector.update_filtering 🟢 12/12 12/12
connector.update_index_name 🟢 4/4 4/4
connector.update_name 🟢 4/4 4/4
connector.update_native 🟢 3/3 3/3
connector.update_pipeline 🟢 3/3 3/3
connector.update_scheduling 🟢 3/3 3/3
connector.update_service_type 🟢 2/2 2/2
connector.update_status 🟢 3/3 3/3

You can validate these APIs yourself by using the make validate target.

@jedrazb
Copy link
Member Author

jedrazb commented Jul 26, 2024

@l-trotta addressed your feedback around sync_cursor type :)

Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
connector.check_in 🟢 3/3 3/3
connector.delete 🟢 9/9 9/9
connector.get 🔴 60/60 59/60
connector.last_sync 🟢 7/7 7/7
connector.list 🟢 19/19 19/19
connector.post 🟢 7/7 7/7
connector.put 🟢 13/13 13/13
connector.secret_delete 🟠 Missing type Missing type
connector.secret_get 🟠 Missing type Missing type
connector.secret_post 🟠 Missing type Missing type
connector.secret_put 🟠 Missing type Missing type
connector.sync_job_cancel 🟢 3/3 3/3
connector.sync_job_check_in 🟠 Missing type Missing type
connector.sync_job_claim 🟠 Missing type Missing type
connector.sync_job_delete 🟢 4/4 4/4
connector.sync_job_error 🟠 Missing type Missing type
connector.sync_job_get 🟢 22/22 22/22
connector.sync_job_list 🟢 12/12 12/12
connector.sync_job_post 🟢 50/50 50/50
connector.sync_job_update_stats 🟠 Missing type Missing type
connector.update_active_filtering 🟢 1/1 1/1
connector.update_api_key_id 🟢 4/4 4/4
connector.update_configuration 🔴 8/9 9/9
connector.update_error 🟢 4/4 4/4
connector.update_features 🟠 Missing type Missing type
connector.update_filtering_validation 🟢 3/3 3/3
connector.update_filtering 🟢 12/12 12/12
connector.update_index_name 🟢 4/4 4/4
connector.update_name 🟢 4/4 4/4
connector.update_native 🟢 3/3 3/3
connector.update_pipeline 🟢 3/3 3/3
connector.update_scheduling 🟢 3/3 3/3
connector.update_service_type 🟢 2/2 2/2
connector.update_status 🟢 3/3 3/3

You can validate these APIs yourself by using the make validate target.

@jedrazb jedrazb merged commit 4b67d9a into main Jul 26, 2024
7 checks passed
@jedrazb jedrazb deleted the connector-api-patch-nullable-usage branch July 26, 2024 12:04
Copy link
Contributor

The backport to 8.15 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-8.15 8.15
# Navigate to the new working tree
cd .worktrees/backport-8.15
# Create a new branch
git switch --create backport-2675-to-8.15
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 4b67d9a824878e54a250d4c9c333474a9a06a141
# Push it to GitHub
git push --set-upstream origin backport-2675-to-8.15
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-8.15

Then, create a pull request where the base branch is 8.15 and the compare/head branch is backport-2675-to-8.15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants