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

[Integration][Gitlab] - Introduce Pagination and Run Code in Async #1047

Merged
merged 9 commits into from
Sep 25, 2024

Conversation

PeyGis
Copy link
Contributor

@PeyGis PeyGis commented Sep 24, 2024

Description

What - Added logs, pagination and async implementation to the GitLab integration

Why -

How -

Type of change

Please leave one option from the following and delete the rest:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • New Integration (non-breaking change which adds a new integration)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Non-breaking change (fix of existing functionality that will not change current behavior)
  • Documentation (added/updated documentation)

All tests should be run against the port production environment(using a testing org).

Core testing checklist

  • Integration able to create all default resources from scratch
  • Resync finishes successfully
  • Resync able to create entities
  • Resync able to update entities
  • Resync able to detect and delete entities
  • Scheduled resync able to abort existing resync and start a new one
  • Tested with at least 2 integrations from scratch
  • Tested with Kafka and Polling event listeners
  • Tested deletion of entities that don't pass the selector

Integration testing checklist

  • Integration able to create all default resources from scratch
  • Resync able to create entities
  • Resync able to update entities
  • Resync able to detect and delete entities
  • Resync finishes successfully
  • If new resource kind is added or updated in the integration, add example raw data, mapping and expected result to the examples folder in the integration directory.
  • If resource kind is updated, run the integration with the example data and check if the expected result is achieved
  • If new resource kind is added or updated, validate that live-events for that resource are working as expected
  • Docs PR link here

Preflight checklist

  • Handled rate limiting
  • Handled pagination
  • Implemented the code in async
  • Support Multi account

Screenshots

Include screenshots from your environment showing how the resources of the integration will look.

API Documentation

Provide links to the API documentation used for this integration.

@PeyGis PeyGis requested a review from a team as a code owner September 24, 2024 16:19
Copy link
Contributor

@Tankilevitch Tankilevitch left a comment

Choose a reason for hiding this comment

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

Lets setup listeners either way if webhook creation is successful or not

This should be run either way if possible with whatever webhooks it got.

        for client, webhook_ids in client_to_webhooks:
            for webhook_id in webhook_ids:
                setup_listeners(client, webhook_id)

Comment on lines 68 to 70
async for hook_batch in AsyncFetcher.fetch_batch(
group.hooks.list
):
Copy link
Contributor

Choose a reason for hiding this comment

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

lets create a method in the client for it

@@ -90,11 +93,12 @@ def _create_group_webhook(
f"Creating webhook for {group.get_id()} with events: {[event for event in webhook_events if webhook_events[event]]}"
)
try:
resp = group.hooks.create(
resp = await AsyncFetcher.fetch_single(
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like maybe fetch_single isn't the appropriate name for it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I felt the same but I was also worried about duplication since the implementation will look the same, only the name of the method will change

f"Failed to setup webhook: {e}. {NO_WEBHOOK_WARNING}",
stack_info=True,
)
logger.exception(f"Failed to setup webhook: {e}. {NO_WEBHOOK_WARNING}")
Copy link
Contributor

Choose a reason for hiding this comment

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

need to make sure that it actually prints the stacktrace, I think exception does it but just lets make sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried a division by zero with or without the stack_info=True and the log is the same, so it doesn't have any impact

Screenshot 2024-09-24 at 8 07 21 PM

Comment on lines 102 to 103
await event_handler.start_event_processor()
await system_event_handler.start_event_processor()
Copy link
Contributor

Choose a reason for hiding this comment

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

lets run them either way if app_host is configured

@github-actions github-actions bot added size/L and removed size/M labels Sep 24, 2024
Copy link
Contributor Author

@PeyGis PeyGis left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@Tankilevitch Tankilevitch left a comment

Choose a reason for hiding this comment

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

LGTM

@Tankilevitch Tankilevitch merged commit c3e2f02 into main Sep 25, 2024
15 checks passed
@Tankilevitch Tankilevitch deleted the gitlab-paginate-webhook branch September 25, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants