public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Arslan Ahmad <arahmad@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/fence-agents] eln: - fence_gce: fail immediately with import errors
Date: Fri, 04 Sep 2026 13:57:32 GMT	[thread overview]
Message-ID: <178853025290.1.1576505360288461895.rpms-fence-agents-c3f495909693@fedoraproject.org> (raw)

          A new commit has been pushed.

          Repo   : rpms/fence-agents
          Branch : eln
          Commit : c3f495909693ede9785be7da150dc925cbc63ca6
          Author : Arslan Ahmad <arahmad@redhat.com>
          Date   : 2026-09-04T09:52:00-04:00
          Stats  : +69/-1 in 2 file(s)
          URL    : https://src.fedoraproject.org/rpms/fence-agents/c/c3f495909693ede9785be7da150dc925cbc63ca6?branch=eln

          Log:
          - fence_gce: fail immediately with import errors
Resolves: RHEL-219431

---
diff --git a/RHEL-219431-fence_gce-fail-immediately-with-import-error.patch b/RHEL-219431-fence_gce-fail-immediately-with-import-error.patch
new file mode 100644
index 0000000..8fa085f
--- /dev/null
+++ b/RHEL-219431-fence_gce-fail-immediately-with-import-error.patch
@@ -0,0 +1,62 @@
+From 449658afaa6a03387cae61842550ccb4b4c5f9dd Mon Sep 17 00:00:00 2001
+From: Arslan Ahmad <arahmad@redhat.com>
+Date: Mon, 20 Jul 2026 13:42:48 +0530
+Subject: [PATCH] fence_gce: fail immediately on import errors
+
+Previously, if a dependency like `httplib2` failed to load due to
+a package conflict, the script would silently pass and crash further
+down the stack. Now, it explicitly catches the error, prints a clear
+log message identifying the broken module and exits immediately
+making aware of the dependency issue.
+
+AI: Assisted by Claude
+
+Signed-off-by: Arslan Ahmad <arahmad@redhat.com>
+---
+ agents/gce/fence_gce.py |  7 ++++---
+ lib/fencing.py.py       | 13 +++++++++++++
+ 2 files changed, 17 insertions(+), 3 deletions(-)
+
+diff --git a/agents/gce/fence_gce.py b/agents/gce/fence_gce.py
+index c7bd2a5dc..7cc8bbbf6 100644
+--- a/agents/gce/fence_gce.py
++++ b/agents/gce/fence_gce.py
+@@ -36,10 +36,11 @@
+   import socks
+   try:
+     from google.oauth2.credentials import Credentials as GoogleCredentials
+-  except:
++  except ImportError:
+     from oauth2client.client import GoogleCredentials
+-except:
+-  pass
++except Exception as e:
++    from fencing import fail_import_if_not_metadata_or_help_action
++    fail_import_if_not_metadata_or_help_action("Failed to import Google Cloud dependencies", e)
+ 
+ VERSION = '1.0.5'
+ ACTION_IDS = {
+diff --git a/lib/fencing.py.py b/lib/fencing.py.py
+index 123926782..8adacea85 100644
+--- a/lib/fencing.py.py
++++ b/lib/fencing.py.py
+@@ -1280,6 +1280,19 @@ def source_env(env_file):
+     os.environ.clear()
+     os.environ.update(line.partition('=')[::2] for line in output.decode("utf-8").split('\0') if not re.match(r"^\s*$", line))
+ 
++def fail_import_if_not_metadata_or_help_action(message, e):
++    args = sys.argv[1:]
++    opts = list(zip(args, args[1:] + [None]))
++    if any(opt in ("-h", "--help", "--action=metadata", "--action=manpage") or (opt in ("-o", "--action") and arg in ("metadata", "manpage")) for opt, arg in opts):
++        return
++    # When no command-line args, input might be from stdin - defer error to let argument validation happen
++    if len(args) == 0:
++        return
++    # Otherwise fail immediately
++    logging.getLogger().name = os.path.basename(sys.argv[0])
++    logging.error("%s: %s", message, str(e))
++    sys.exit(EC_GENERIC_ERROR)
++
+ # Convert array of format [[key1, value1], [key2, value2], ... [keyN, valueN]] to dict, where key is
+ # in format a.b.c.d...z and returned dict has key only z
+ def array_to_dict(array):

diff --git a/fence-agents.spec b/fence-agents.spec
index d67e1a9..93fff21 100644
--- a/fence-agents.spec
+++ b/fence-agents.spec
@@ -13,7 +13,7 @@
 Name: fence-agents
 Summary: Set of unified programs capable of host isolation ("fencing")
 Version: 4.16.0
-Release: 33%{?alphatag:.%{alphatag}}%{?dist}
+Release: 34%{?alphatag:.%{alphatag}}%{?dist}
 License: GPL-2.0-or-later AND LGPL-2.0-or-later
 URL: https://github.com/ClusterLabs/fence-agents
 Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.gz
@@ -129,6 +129,7 @@ Patch23: RHEL-140160-fence_ibm_vpc-set-proxy-when-token-is-expired-as-well.patch
 Patch24: RHEL-155007-fence_openstack-fix-list-action-to-avoid-timeout-with-large-number-of-VMs.patch
 Patch25: RHEL-191488-1-fence_vmware_rest-add-token-based-authentication.patch
 Patch26: RHEL-191488-2-fence_vmware_rest-remove-static-token-option.patch
+Patch27: RHEL-219431-fence_gce-fail-immediately-with-import-error.patch
 
 %global supportedagents amt_ws apc apc_snmp bladecenter brocade cisco_mds cisco_ucs drac5 eaton_snmp emerson eps hpblade ibmblade ibm_powervs ibm_vpc ifmib ilo ilo_moonshot ilo_mp ilo_ssh intelmodular ipdu ipmilan kdump kubevirt lpar mpath nutanix_ahv redfish rhevm rsa rsb sbd scsi vmware_rest vmware_soap wti
 %ifarch x86_64
@@ -267,6 +268,7 @@ BuildRequires: %{systemd_units}
 %patch -p1 -P 24
 %patch -p1 -P 25
 %patch -p1 -P 26
+%patch -p1 -P 27
 
 # prevent compilation of something that won't get used anyway
 sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
@@ -1246,6 +1248,10 @@ are located on corosync cluster nodes.
 %endif
 
 %changelog
+* Fri Jul 31 2026 Arslan Ahmad <arahmad@redhat.com> - 4.16.0-34
+- fence_gce: fail immediately with import errors
+  Resolves: RHEL-219431
+
 * Fri Jul 31 2026 Arslan Ahmad <arahmad@redhat.com> - 4.16.0-33
 - fence_vmware_rest: add token-based authentication
   Resolves: RHEL-191488

                 reply	other threads:[~2026-09-04 13:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178853025290.1.1576505360288461895.rpms-fence-agents-c3f495909693@fedoraproject.org \
    --to=arahmad@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox