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

[Core] Add opt-in integration resource provision service #1297

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

erikzaadi
Copy link
Member

Description

What - Add a flow that verifies the USE_PROVISIONED_DEFAULTS and uses the provisioning resources accordingly

Logic:

Integration marked use_provisioned_defaults as true but org feature toggle USE_PROVISIONED_DEFAULTS isn't available

=> Regular flow

Org feature toggle USE_PROVISIONED_DEFAULTS enabled but integration wasn't marked with use_provisioned_defaults

=> Regular flow

Integration marked use_provisioned_defaults as true and org feature toggle USE_PROVISIONED_DEFAULTS is set

=> Create integration with the `provisionEnabled` property set to true
=> Skip creating resources
=> Wait until config is populated before continuing flow

Type of change

  • New feature (non-breaking change which adds functionality)

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
  • Integration able to NOT 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

@erikzaadi erikzaadi requested a review from a team as a code owner January 5, 2025 16:35
@github-actions github-actions bot added the size/M label Jan 5, 2025
@erikzaadi erikzaadi force-pushed the PORT-12242-onboarding-provision-feature-flag branch 9 times, most recently from a5c6b85 to 0886913 Compare January 6, 2025 11:48
@github-actions github-actions bot added size/L and removed size/M labels Jan 6, 2025
@erikzaadi erikzaadi force-pushed the PORT-12242-onboarding-provision-feature-flag branch from 802d38d to b00e679 Compare January 6, 2025 16:23
@erikzaadi erikzaadi changed the title Add opt-in integration resource provision service [CORE] Add opt-in integration resource provision service Jan 6, 2025
@erikzaadi erikzaadi changed the title [CORE] Add opt-in integration resource provision service [Core] Add opt-in integration resource provision service Jan 6, 2025
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.

Nice work
left a few comments, overall seems like you've added some core functionality to the integration initialization which I think is really worth adding testing for to make sure everything is behaving as expected

.github/workflows/integrations-test.yml Outdated Show resolved Hide resolved
port_ocean/clients/port/mixins/organization.py Outdated Show resolved Hide resolved
port_ocean/clients/port/mixins/organization.py Outdated Show resolved Hide resolved
port_ocean/core/defaults/initialize.py Outdated Show resolved Hide resolved
Comment on lines 54 to 56
async def _poll_integration_until_default_provisioning_is_complete(
self,
interval=15,
Copy link
Contributor

Choose a reason for hiding this comment

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

15 what?

Copy link
Contributor

Choose a reason for hiding this comment

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

lets not use magic numbers

Copy link
Contributor

Choose a reason for hiding this comment

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

can we do some kind of backoff or eventually mechanism? 15 seconds is huge time to wait for integration to finish set up

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 idea, will add

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed!

port_ocean/clients/port/mixins/integrations.py Outdated Show resolved Hide resolved
@@ -68,6 +68,7 @@ class IntegrationConfiguration(BaseOceanSettings, extra=Extra.allow):
initialize_port_resources: bool = True
scheduled_resync_interval: int | None = None
client_timeout: int = 60
use_provisioned_defaults: bool = False
Copy link
Contributor

Choose a reason for hiding this comment

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

are we sure we want to use only two options False and True ? maybe worth changing the variable to provisioning_mode

  • port
  • local
    which will allow us more flexability in the future?

Copy link
Member Author

Choose a reason for hiding this comment

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

WDYM? Why would that be different?

port_ocean/core/defaults/initialize.py Outdated Show resolved Hide resolved
port_ocean/clients/port/mixins/integrations.py Outdated Show resolved Hide resolved
port_ocean/clients/port/mixins/integrations.py Outdated Show resolved Hide resolved
@erikzaadi erikzaadi force-pushed the PORT-12242-onboarding-provision-feature-flag branch 2 times, most recently from e3b9410 to 78cf234 Compare January 7, 2025 07:13
f"Fetching created integration and validating config, attempt {attempts+1}/{INTEGRATION_POLLING_RETRY_LIMIT}"
)
response = await self._get_current_integration()
response_json = response.json()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
response_json = response.json()
integration_response = response.json()

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 73 to 74
if config != {}:
return response_json

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if config != {}:
return response_json
if config:
return response_json

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 104 to 107
if use_provisioned_defaults:
json["provisionEnabled"] = use_provisioned_defaults

Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't be something on top of the integration, but rather as a query param
see the image below for reference
Screenshot 2025-01-07 at 13 27 02

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines +24 to +25
super().__init__(
f"Failed to retrieve integration config after {retries} attempts"
Copy link
Contributor

Choose a reason for hiding this comment

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

does it mean that the integration won't continue to run after this issue happens

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, and it'll be in the logs

@erikzaadi erikzaadi force-pushed the PORT-12242-onboarding-provision-feature-flag branch from f3d696d to 1a40313 Compare January 8, 2025 08:41
@github-actions github-actions bot added size/M and removed size/L labels Jan 8, 2025
@erikzaadi erikzaadi force-pushed the PORT-12242-onboarding-provision-feature-flag branch 3 times, most recently from 79e3d2a to 152f355 Compare January 11, 2025 14:36
@erikzaadi erikzaadi force-pushed the PORT-12242-onboarding-provision-feature-flag branch from 11f99ed to bf41328 Compare January 12, 2025 11:38
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