Hello,
we need to maintain some automation in the form of an AWS Lambda function calling the Meraki dashboard API and updating our VPC routing tables accordingly
The problem we ran into was that every now and then we would get a 60 second timeout and the function would fail.
To solve this problem, we moved from the default API endpoint to our segment's FQDN (as suggested here)
Unfortunately, this did not solve the problem and the next step was to introduce timeouts and retries to call the Meraki API. The code looks like the following
initialising the Dashboard
meraki_base_url = MERAKI_BASE_URL
logging.info (f'Meraki base URL: {meraki_base_url}')
meraki_dashboard = meraki.DashboardAPI(base_url=meraki_base_url, api_key=meraki_api_key, suppress_logging=True, single_request_timeout=5, maximum_retries=3)
calling it
def get_meraki_tagged_networks(dashboard, org_id, vmx_tag):
"""
Returns Meraki network IDs for the given organisation.
"""
logging.info('Executing API call to obtain all Meraki networks in the organization')
try:
organization_networks_response = dashboard.organizations.getOrganizationNetworks(
org_id, total_pages='all'
)
vmx_network = [x for x in organization_networks_response if str(vmx_tag) in str(x['tags'])[1:-1]]
except Exception as e:
logging.error(f'Unknown error happened while retriving Meraki network IDs: {e}')
sys.exit(1)
if len(vmx_network) == 0:
return None
else:
return vmx_network[0]['id']
Unfortunately, the problem is still there and error we receive now is as follows
[INFO] 2024-03-05T23:01:18.698Z 0565e7a3-f0a3-4df6-8db3-25e4e3952a68 Executing API call to obtain all Meraki networks in the organization
[ERROR] 2024-03-05T23:01:23.306Z 0565e7a3-f0a3-4df6-8db3-25e4e3952a68 Unknown error happened while retriving Meraki network IDs: organizations, getOrganizationNetworks - 502 Bad Gateway, <html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></cente
So it seems that the retries number is not respected, otherwise time between log records would have been 15 second(3 multiple by 5)
Any hint of what might be wrong?