Skip to content

feat: adding weighted random host selection strategy #907

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
merged 1 commit into from
Jul 3, 2025

Conversation

JuanLeee
Copy link
Collaborator

@JuanLeee JuanLeee commented Jun 17, 2025

Description

Adding weighed random selection for host selection in order to prepare for future features.
User is able to add weights to different hosts to modify the likeliness of the particular host to be selected.

Manually tested for verification.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@JuanLeee JuanLeee force-pushed the feat/randomWeight branch 2 times, most recently from 52a2d2f to 78be473 Compare June 18, 2025 00:29
@JuanLeee JuanLeee force-pushed the feat/randomWeight branch from 78be473 to 41fda0a Compare June 19, 2025 22:32
@JuanLeee JuanLeee force-pushed the feat/randomWeight branch 6 times, most recently from 2b20e9a to bcbc617 Compare June 23, 2025 17:28
@JuanLeee JuanLeee force-pushed the feat/randomWeight branch 2 times, most recently from 5284e12 to 68180ea Compare July 3, 2025 10:30
@JuanLeee JuanLeee force-pushed the feat/randomWeight branch from 68180ea to 7e4f6d4 Compare July 3, 2025 10:51
Comment on lines +211 to +213
message = "HostSelector.NoHostsMatchingRole"
logger.error(message, role)
raise AwsWrapperError(Messages.get_formatted("HostSelector.NoHostsMatchingRole", role))
Copy link
Contributor

@karenc-bq karenc-bq Jul 3, 2025

Choose a reason for hiding this comment

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

Suggested change
message = "HostSelector.NoHostsMatchingRole"
logger.error(message, role)
raise AwsWrapperError(Messages.get_formatted("HostSelector.NoHostsMatchingRole", role))
message = Messages.get_formatted("HostSelector.NoHostsMatchingRole", role)
logger.error(message, role)
raise AwsWrapperError(message)

Copy link
Collaborator Author

@JuanLeee JuanLeee Jul 3, 2025

Choose a reason for hiding this comment

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

logger.error already gets the message formatted:

def error(self, msg, *args, **kwargs):
    if not self.logger.isEnabledFor(logging.ERROR):
        return

    if args is not None and len(args) > 0:
        self.logger.error(Messages.get_formatted(msg, *args), **kwargs)
    else:
        try:
            self.logger.error(Messages.get(msg), **kwargs)
        except NotInResourceBundleError:
            self.logger.error(msg, **kwargs)

Comment on lines +246 to +247
logger.error(message, pair)
raise AwsWrapperError(Messages.get_formatted(message, pair))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above

@karenc-bq karenc-bq merged commit c8bfb0d into aws:main Jul 3, 2025
6 checks passed
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