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

Lambda cold/warm start issue when DNS changes region #68

Open
geralexgr opened this issue Oct 18, 2023 · 0 comments
Open

Lambda cold/warm start issue when DNS changes region #68

geralexgr opened this issue Oct 18, 2023 · 0 comments

Comments

@geralexgr
Copy link

There is an issue in the code when the DNS is switching from one region to another.

We have noticed that when there is a failover from one region to another from the loadbalancer, although the health_active_region is changing, due to the fact that codeblock is not wrapped into a function or in the function handler, the code is not in warm state and wrong results are returned. Currently the initialisation of the config is done on the cold state. As a result when one runs the lambda every x minutes when a failover occurs it will return an error.

In the function logs we notice an error message like:

Client is configured with the deprecated endpoint: us-east-2

health_dns = socket.gethostbyname_ex('global.health.amazonaws.com')
(current_endpoint, global_endpoint, ip_endpoint) = health_dns
health_active_list = current_endpoint.split('.')
health_active_region = health_active_list[1]
print("current health region: ", health_active_region)
# create a boto3 health client w/ backoff/retry
config = Config(
region_name=health_active_region,
retries=dict(
max_attempts=10 # org view apis have a lower tps than the single
# account apis so we need to use larger
# backoff/retry values than than the boto defaults
)
)

A solution for this issue could be to wrap the initialisations inside a function.

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

No branches or pull requests

1 participant