From dd89c48b9aa20ac0666b191020c2531b891b5f38 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 20 Sep 2021 08:01:41 -0400 Subject: [PATCH] Fix problem where syncfiles could fail on certan hosts If the set of oldhosts and newhosts were just so, targlines or sourcelines could be all null and cause index errors. --- .../suse15/profiles/hpc/scripts/syncfileclient | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/confluent_osdeploy/suse15/profiles/hpc/scripts/syncfileclient b/confluent_osdeploy/suse15/profiles/hpc/scripts/syncfileclient index dd22d6b3..08c9cfdf 100644 --- a/confluent_osdeploy/suse15/profiles/hpc/scripts/syncfileclient +++ b/confluent_osdeploy/suse15/profiles/hpc/scripts/syncfileclient @@ -25,7 +25,7 @@ def partitionhostsline(line): names = names.split() return ipaddr, names, comment -class HostMerger: +class HostMerger(object): def __init__(self): self.byip = {} self.byname = {} @@ -75,8 +75,12 @@ class HostMerger: def write_out(self, targetfile): while not self.targlines[-1]: self.targlines = self.targlines[:-1] + if not self.targlines: + break while not self.sourcelines[-1]: self.sourcelines = self.sourcelines[:-1] + if not self.sourcelines: + break with open(targetfile, 'w') as hosts: for line in self.targlines: hosts.write(line + '\n')