Skip to content

Conversation

@chillaq
Copy link
Contributor

@chillaq chillaq commented Jul 5, 2022

Python SDK

What did you accomplish?

Updated Synching Splits to detect if there is a segment in rules, and sync the segment if it does not exist in storage

How do we test the changes introduced in this PR?

Updated tests and ran them locally successfully.

Extra Notes

Related JIRA: https://splitio.atlassian.net/browse/SDKS-2374

mmelograno and others added 3 commits April 6, 2022 19:04
Python 9.1.2 py-yaml vulnerability fix
… sync the segment if it does not exist in storage
… sync the segment if it does not exist in storage
self._backoff = Backoff(
_ON_DEMAND_FETCH_BACKOFF_BASE,
_ON_DEMAND_FETCH_BACKOFF_MAX_WAIT)
self.segment_list = []
Copy link
Contributor

Choose a reason for hiding this comment

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

let's create this variable inside the _fetch_until method instead

for split in split_changes.get('splits', []):
if split['status'] == splits.Status.ACTIVE.value:
# _LOGGER.debug('split details: '+str(split))
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be removed

_LOGGER.debug('Starting splits synchronization')
self._split_synchronizers.split_sync.segment_list = []
try:
self._split_synchronizers.split_sync.synchronize_splits(till)
Copy link
Contributor

Choose a reason for hiding this comment

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

you can set the segment_list here segment_list = self._split_synchronizers.split_sync.synchronize_splits(till)

"""
if self._segment_storage.get(segment_name) != None:
return True
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

the else is not required, only the return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

else: return False is needed to avoid synching segments if the don't exist in sync/split.py _fetch_until() function

_ON_DEMAND_FETCH_BACKOFF_MAX_WAIT)

def _fetch_until(self, fetch_options, till=None):
def _fetch_until(self, fetch_options, till=None, segment_sync=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

segment sync should not be optional since it's used without checks.
still, i'd suggest not passing around the segment sync so deep and just returning a list of all the segments referenced in the splits. later on, when the segments are indeed being fetched, filter out the ones that are already present

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic used to be in sync/synchronizer.py, Matti asked to move it to sync/split.py, that is why segment_sync object is needed. I will put a check before using it to avoid errors.

2- Created test to verify segment_sync is called once from split_sync
3- disable waiting for segment sync workerpool job when synching segments from splits.
4- Other general cleanup.
@mmelograno mmelograno changed the base branch from master to development July 18, 2022 17:20
@chillaq chillaq merged commit 3fff64c into development Jul 19, 2022
@chillaq chillaq deleted the Synching-Segments-In-Splits branch July 19, 2022 19:18
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.

3 participants