Skip to content

Commit

Permalink
adds retries to fix len(dns). issue 79
Browse files Browse the repository at this point in the history
resolve apel#79 . i was unsure which part to loop so i just repeated the whole chunk within the try statement.
  • Loading branch information
DanielPerkins7 committed Aug 2, 2023
1 parent 7849c57 commit 96020a3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ssm/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,24 @@ def get_dns(dn_file, log):
dns.append(line.strip())
else:
log.warning('DN in incorrect format: %s', line)

# If no valid DNs, SSM cannot receive any messages.
if len(dns) == 0:
fails = 0
while fails < 3 and len(dns) == 0:
for line in lines:
if line.isspace() or line.strip().startswith('#'):
continue
elif line.strip().startswith('/'):
dns.append(line.strip())
else:
log.warning('DN in incorrect format: %s', line)
if len(dns) == 0:
raise Ssm2Exception('No valid DNs found in %s. SSM will not start' % dn_file)

finally:
if f is not None:
f.close()
# If no valid DNs, SSM cannot receive any messages.
if len(dns) == 0:
raise Ssm2Exception('No valid DNs found in %s. SSM will not start' % dn_file)

log.debug('%s DNs found.', len(dns))
return dns

0 comments on commit 96020a3

Please sign in to comment.