From 999a9c3acf23921c78d6d7830b8e7d2eadc0e3e1 Mon Sep 17 00:00:00 2001 From: Tinashe Date: Thu, 17 Apr 2025 15:34:45 -0400 Subject: [PATCH 1/2] remove-consoleredirect --- .../default/scripts/sample/consoleredirect | 15 ------- .../hpc/scripts/sample/consoleredirect | 39 ------------------- 2 files changed, 54 deletions(-) delete mode 100644 confluent_osdeploy/el9-diskless/profiles/default/scripts/sample/consoleredirect delete mode 100644 confluent_osdeploy/suse15/profiles/hpc/scripts/sample/consoleredirect diff --git a/confluent_osdeploy/el9-diskless/profiles/default/scripts/sample/consoleredirect b/confluent_osdeploy/el9-diskless/profiles/default/scripts/sample/consoleredirect deleted file mode 100644 index 60143ae5..00000000 --- a/confluent_osdeploy/el9-diskless/profiles/default/scripts/sample/consoleredirect +++ /dev/null @@ -1,15 +0,0 @@ -is_rhel=false - -if test -f /boot/efi/EFI/redhat/grub.cfg; then - grubcfg="/etc/default/grub" - is_rhel=true -else - echo "Expected File missing: Check if os redhat" - exit -fi - -# Working on Redhat -if $is_rhel; then - sed -i '/^GRUB_TERMINAL/s/serial //' $grubcfg - grub2-mkconfig -o /boot/grub2/grub.cfg -fi \ No newline at end of file diff --git a/confluent_osdeploy/suse15/profiles/hpc/scripts/sample/consoleredirect b/confluent_osdeploy/suse15/profiles/hpc/scripts/sample/consoleredirect deleted file mode 100644 index 270d24b7..00000000 --- a/confluent_osdeploy/suse15/profiles/hpc/scripts/sample/consoleredirect +++ /dev/null @@ -1,39 +0,0 @@ -is_suse=false - -if test -f /boot/efi/EFI/sle_hpc/grub.cfg; then - grubcfg="/boot/efi/EFI/sle_hpc/grub.cfg" - grub2-mkconfig -o $grubcfg - is_suse=true -else - echo "Expected File missing: Check if os sle_hpc" - exit -fi - -# working on SUSE -if $is_suse; then - start=false - num_line=0 - lines_to_edit=() - while read line; do - ((num_line++)) - if [[ $line == *"grub_platform"* ]]; then - start=true - fi - if $start; then - if [[ $line != "#"* ]];then - lines_to_edit+=($num_line) - fi - fi - if [[ ${#line} -eq 2 && $line == *"fi" ]]; then - if $start; then - start=false - fi - fi - done < grub_cnf.cfg - - for line_num in "${lines_to_edit[@]}"; do - line_num+="s" - sed -i "${line_num},^,#," $grubcfg - done - sed -i 's,^terminal,#terminal,' $grubcfg -fi From 3b46ccb5b10a12a9a612cd2c513b8d40366d6fbc Mon Sep 17 00:00:00 2001 From: Tinashe Date: Fri, 25 Apr 2025 16:55:25 -0400 Subject: [PATCH 2/2] make nodeconsole kill more consistent --- confluent_client/bin/nodeconsole | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/confluent_client/bin/nodeconsole b/confluent_client/bin/nodeconsole index 02c00e81..ee4acf52 100755 --- a/confluent_client/bin/nodeconsole +++ b/confluent_client/bin/nodeconsole @@ -404,6 +404,7 @@ if options.screenshot: cursor_down(numrows) sys.stdout.write('\n') sys.exit(0) + def kill(noderange): sess = client.Command() envstring=os.environ.get('NODECONSOLE_WINDOWED_COMMAND') @@ -411,29 +412,23 @@ def kill(noderange): envstring = 'xterm' nodes = [] - for res in sess.read('/noderange/{0}/nodes/'.format(args[0])): + for res in sess.read('/noderange/{0}/nodes/'.format(noderange)): node = res.get('item', {}).get('href', '/').replace('/', '') if not node: sys.stderr.write(res.get('error', repr(res)) + '\n') sys.exit(1) nodes.append(node) - for node in nodes: - s=socket.socket(socket.AF_UNIX) - winid=None + for node in nodes: + command = "ps auxww | grep {0} | grep console | egrep '\\b{1}\\b' | grep -v grep | awk '{{print $2}}'".format(envstring, node) + process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = process.communicate() try: - win=subprocess.Popen(['xwininfo', '-tree', '-root'], stdout=subprocess.PIPE) - wintr=win.communicate()[0] - for line in wintr.decode('utf-8').split('\n'): - if 'console: {0}'.format(node) in line or 'confetty' in line: - win_obj = [ele for ele in line.split(' ') if ele.strip()] - winid = win_obj[0] - except: - print("Error: cannot retrieve window id of node {}".format(node)) - - if winid: - ps_data=subprocess.Popen(['xkill', '-id', winid ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - + process_id = stdout.decode('utf-8').split()[0] + except IndexError: + sys.stderr.write(node + ": console window not found \n") + continue + subprocess.Popen(["kill", process_id], stdout=subprocess.PIPE, stderr=subprocess.PIPE) sys.exit(0) def handle_geometry(envlist, sizegeometry, side_pad=0, top_pad=0, first=False):