diff options
| author | Kotresh HR <khiremat@redhat.com> | 2018-05-09 01:10:29 -0400 | 
|---|---|---|
| committer | Kotresh HR <khiremat@redhat.com> | 2018-08-16 00:20:20 -0400 | 
| commit | 396277b9a24b5f7793b3b0f91e7aa7992e8a145e (patch) | |
| tree | 966982750fad66019df93474452b90aac8588294 /extras | |
| parent | f33a61086da43af5a5de2ba99b4045a63cf5bd79 (diff) | |
geo-rep/scheduler: Fix crash
Fix crash where session_name is referenced
before assignment. Well, this is a corner
case where the geo-rep session exists and
the status output doesn't show any rows.
This might happen when glusterd is down
or when the system is in inconsistent state
w.r.t glusterd.
Backpor of:
 > BUG: 1576179
 > Change-Id: Iec1557e01b35068041b4b3c1aacee2bfa0e05873
 > Signed-off-by: Kotresh HR <khiremat@redhat.com>
fixes: bz#1611108
Change-Id: Iec1557e01b35068041b4b3c1aacee2bfa0e05873
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'extras')
| -rw-r--r-- | extras/geo-rep/schedule_georep.py.in | 70 | 
1 files changed, 35 insertions, 35 deletions
diff --git a/extras/geo-rep/schedule_georep.py.in b/extras/geo-rep/schedule_georep.py.in index 01a46978ef4..38d8f500ad6 100644 --- a/extras/geo-rep/schedule_georep.py.in +++ b/extras/geo-rep/schedule_georep.py.in @@ -300,6 +300,7 @@ def get_summary(mastervol, slave_url):      status_data = get(mastervol, slave_url)      for session in status_data: +        session_name = ""          summary = {              "active": 0,              "passive": 0, @@ -342,7 +343,8 @@ def get_summary(mastervol, slave_url):          if summary["faulty"] == 0 and summary["offline"] == 0:              summary["ok"] = True -        out.append([session_name, summary, faulty_rows, down_rows]) +        if session_name != "": +                out.append([session_name, summary, faulty_rows, down_rows])      return out @@ -400,41 +402,39 @@ def main(args):              # or any other error. Gluster cmd still produces XML output              # with different message              output_warning("Unable to get Geo-replication Status") -            time.sleep(1) -            continue - -        session_name, summary, faulty_rows, down_rows = session_summary[0] -        chkpt_status = "COMPLETE" if summary["checkpoints_ok"] else \ -                       "NOT COMPLETE" -        ok_status = "OK" if summary["ok"] else "NOT OK" - -        if summary["ok"]: -            output_ok("All Checkpoints {1}, " -                      "All status {2} (Turns {0:>3})".format( -                          turns, chkpt_status, ok_status))          else: -            output_warning("All Checkpoints {1}, " -                           "All status {2} (Turns {0:>3})".format( -                               turns, chkpt_status, ok_status)) - -            output_warning("Geo-rep workers Faulty/Offline, " -                           "Faulty: {0} Offline: {1}".format( -                               repr(faulty_rows), -                               repr(down_rows))) - -        if summary["checkpoints_ok"]: -            output_ok("Stopping Geo-replication session now") -            cmd = ["@SBIN_DIR@/gluster", "volume", "geo-replication", -                   args.mastervol, -                   "%s::%s" % (args.slave, args.slavevol), "stop"] -            execute(cmd) -            break -        else: -            # If Checkpoint is not complete after a iteration means brick -            # was down and came online now. SETATTR on mount is not -            # recorded, So again issue touch on mount root So that -            # Stime will increase and Checkpoint will complete. -            touch_mount_root(args.mastervol) +            session_name, summary, faulty_rows, down_rows = session_summary[0] +            chkpt_status = "COMPLETE" if summary["checkpoints_ok"] else \ +                           "NOT COMPLETE" +            ok_status = "OK" if summary["ok"] else "NOT OK" + +            if summary["ok"]: +                output_ok("All Checkpoints {1}, " +                          "All status {2} (Turns {0:>3})".format( +                              turns, chkpt_status, ok_status)) +            else: +                output_warning("All Checkpoints {1}, " +                               "All status {2} (Turns {0:>3})".format( +                                   turns, chkpt_status, ok_status)) + +                output_warning("Geo-rep workers Faulty/Offline, " +                               "Faulty: {0} Offline: {1}".format( +                                   repr(faulty_rows), +                                   repr(down_rows))) + +            if summary["checkpoints_ok"]: +                output_ok("Stopping Geo-replication session now") +                cmd = ["@SBIN_DIR@/gluster", "volume", "geo-replication", +                       args.mastervol, +                       "%s::%s" % (args.slave, args.slavevol), "stop"] +                execute(cmd) +                break +            else: +                # If Checkpoint is not complete after a iteration means brick +                # was down and came online now. SETATTR on mount is not +                # recorded, So again issue touch on mount root So that +                # Stime will increase and Checkpoint will complete. +                touch_mount_root(args.mastervol)          # Increment the turns and Sleep for 10 sec          turns += 1  | 
