]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephfs-top: fix exception on small sized windows
authorJos Collin <jcollin@redhat.com>
Thu, 5 Sep 2024 08:37:21 +0000 (14:07 +0530)
committerJos Collin <jcollin@redhat.com>
Fri, 6 Sep 2024 11:36:52 +0000 (17:06 +0530)
Fixes "exception: addwstr() returned ERR"
when the window width is smaller than expected.

Fixes: https://tracker.ceph.com/issues/67859
Signed-off-by: Jos Collin <jcollin@redhat.com>
src/tools/cephfs/top/cephfs-top

index ae252ee71cec159daf7f0e5f722dfed58a279fb7..9ecc47fc2d5f35f2731b58aacd520e842bee87c9 100755 (executable)
@@ -941,6 +941,15 @@ class FSTop(FSTopBase):
         self.header.addstr(5, 0, help, curses.A_DIM)
         return True
 
+    def handle_header(self, stats_json, help, screen_title, color_id=0):
+        try:
+            return self.create_header(stats_json, help, screen_title, color_id)
+        except curses.error:
+            curses.endwin()
+            sys.stderr.write("Error creating header. Please increase the window width to use "
+                             "cephfs-top.\n")
+            exit()
+
     def run_display(self):
         # clear the pads to have a smooth refresh
         self.header.erase()
@@ -990,7 +999,7 @@ class FSTop(FSTopBase):
                     current_states["limit"] = None
                 self.header.erase()  # erase previous text
                 self.fsstats.erase()
-                self.create_header(stats_json, help, screen_title, 3)
+                self.handle_header(stats_json, help, screen_title, 3)
             else:
                 self.tablehead_y = 0
                 help = "COMMANDS: " + help_commands
@@ -1003,7 +1012,7 @@ class FSTop(FSTopBase):
                 else:
                     num_client = len(client_metadata)
                 vscrollEnd += num_client
-                if self.create_header(stats_json, help, screen_title, 3):
+                if self.handle_header(stats_json, help, screen_title, 3):
                     self.create_table_header()
                     self.create_clients(stats_json, fs)
 
@@ -1122,7 +1131,7 @@ class FSTop(FSTopBase):
                 current_states["limit"] = None
                 self.header.erase()  # erase previous text
                 self.fsstats.erase()
-                self.create_header(stats_json, help, screen_title, 2)
+                self.handle_header(stats_json, help, screen_title, 2)
             else:
                 self.tablehead_y = 0
                 num_client = 0
@@ -1138,7 +1147,7 @@ class FSTop(FSTopBase):
                     else:
                         num_client = len(client_metadata)
                     vscrollEnd += num_client
-                    if self.create_header(stats_json, help, screen_title, 2):
+                    if self.handle_header(stats_json, help, screen_title, 2):
                         if not index:  # do it only for the first fs
                             self.create_table_header()
                         self.create_clients(stats_json, fs)