Skip to content

feat: CompositeDataSource blacklists DataSources that report unrecoverable error #826

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

Merged

Conversation

tanderson-ld
Copy link
Contributor

@tanderson-ld tanderson-ld commented Apr 17, 2025

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions
    To be done on target branch.

@tanderson-ld tanderson-ld marked this pull request as ready for review April 18, 2025 14:16
@tanderson-ld tanderson-ld requested a review from a team as a code owner April 18, 2025 14:16
});

// it('it reports DataSourceState Off when all synchronizers report Off', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reviewers: Still tweaking this test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CompositeDataSource is now stitching together status of underlying datasources into a cohesive series, so most of the changes in here are to enhance the existing tests to check the status sequences.

expect(statusCallback).toHaveBeenNthCalledWith(1, DataSourceState.Initializing, undefined);
expect(statusCallback).toHaveBeenNthCalledWith(2, DataSourceState.Valid, undefined);
expect(statusCallback).toHaveBeenNthCalledWith(3, DataSourceState.Interrupted, undefined);
expect(statusCallback).toHaveBeenNthCalledWith(4, DataSourceState.Valid, undefined);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reviewers: Here it is now checking the top level status updates are a proper merging of the underlying data source statuses.

@@ -28,16 +30,4 @@ export interface DataSource {
stop(): void;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reviewers: The initializer and synchronizer factory distinction was making writing the logic related to culling a blacklist datasource cumbersome. So removed that distinction to make the logic the same for both types.

Closed,
// This datasource encountered an unrecoverable error and it is not expected to be resolved through trying again in the future
Off,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reviewers: Added Off and reordered so Valid would be 0 (positive result).

Copy link
Member

Choose a reason for hiding this comment

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

Is that considered a breaking change then?


const DEFAULT_FALLBACK_TIME_MS = 2 * 60 * 1000;
const DEFAULT_RECOVERY_TIME_MS = 5 * 60 * 1000;

/**
* Represents a transition between data sources.
*/
export type Transition = 'none' | 'switchToSync' | 'fallback' | 'recover' | 'stop';
export type Transition = 'switchToSync' | 'fallback' | 'recover' | 'stop';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Undefined transition takes the place of none now.

} else {
isPrimary = this._syncFactories.pos() === 0;
factory = this._syncFactories.next();
}
break;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reviewers: All the position tracking logic is now in the dataSourceList class to encapsulate iteration.

@@ -273,7 +305,7 @@ export class CompositeDataSource implements DataSource {
const condition = this._transitionConditions[state];

// exclude recovery can happen for certain initializers/synchronizers (ex: the primary synchronizer shouldn't recover to itself)
if (!condition || (excludeRecover && condition.transition === 'recover')) {
if (excludeRecover && condition?.transition === 'recover') {
return undefined;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reviewers: No logical change intended here.

@@ -34,7 +34,7 @@ export default class OneShotInitializerFDv2 implements subsystemCommon.DataSyste
const message = httpErrorMessage(err, 'initializer', 'initializer does not retry');
this._logger?.error(message);
statusCallback(
subsystemCommon.DataSourceState.Closed,
subsystemCommon.DataSourceState.Off,
new LDPollingError(DataSourceErrorKind.ErrorResponse, message, status),
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reviewers: This is what leads to blacklisting after unrecoverable error.

@tanderson-ld tanderson-ld requested a review from keelerm84 April 18, 2025 14:32
Copy link
Member

@keelerm84 keelerm84 left a comment

Choose a reason for hiding this comment

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

Looks good overall. Not approving since there is a pending test commented out, but otherwise 👍🏼

Closed,
// This datasource encountered an unrecoverable error and it is not expected to be resolved through trying again in the future
Off,
Copy link
Member

Choose a reason for hiding this comment

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

Is that considered a breaking change then?

@tanderson-ld tanderson-ld changed the title feat: CompositeDataSource blacklists DataSources that report Off feat: CompositeDataSource blacklists DataSources that report unrecoverable error Apr 22, 2025
@tanderson-ld
Copy link
Contributor Author

Looks good overall. Not approving since there is a pending test commented out, but otherwise 👍🏼

Addressed!

@tanderson-ld tanderson-ld requested a review from keelerm84 April 22, 2025 17:04
@tanderson-ld tanderson-ld merged commit aee6479 into ta/fdv2-temporary-holding Apr 22, 2025
2 checks passed
@tanderson-ld tanderson-ld deleted the ta/sdk-1137/blacklisting-datasources branch April 22, 2025 17:10
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.

2 participants