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

adds repeats to try fix len(dns). Issue79 #252

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
17 changes: 14 additions & 3 deletions ssm/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,23 @@ 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:
Copy link
Contributor

Choose a reason for hiding this comment

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

fails is never being incremented, so will never reach 3

for line in lines:
Copy link
Contributor

@rowan04 rowan04 Aug 3, 2023

Choose a reason for hiding this comment

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

is lines still being defined here?

if line.isspace() or line.strip().startswith('#'):
Copy link
Contributor

Choose a reason for hiding this comment

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

The lines inside the for loop should be indented 4 spaces.

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:
Fixed Show fixed Hide fixed
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
Loading