- fence_gce: fail immediately with import errors
Resolves: RHEL-187353
This commit is contained in:
parent
71e94b083a
commit
998e6b6306
@ -0,0 +1,39 @@
|
||||
--- a/agents/gce/fence_gce.py 2026-07-31 18:20:02.677000000 +0530
|
||||
+++ b/agents/gce/fence_gce.py 2026-07-31 18:31:30.223000000 +0530
|
||||
@@ -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)
|
||||
|
||||
METADATA_SERVER = 'http://metadata.google.internal/computeMetadata/v1/'
|
||||
METADATA_HEADERS = {'Metadata-Flavor': 'Google'}
|
||||
--- a/lib/fencing.py.py 2026-07-31 18:20:02.666000000 +0530
|
||||
+++ b/lib/fencing.py.py 2026-07-31 18:33:40.236000000 +0530
|
||||
@@ -1281,6 +1281,19 @@
|
||||
os.environ.clear()
|
||||
os.environ.update(line.partition('=')[::2] for line in output.decode("utf-8").split('\0') if not re.match("^\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):
|
||||
@ -47,7 +47,7 @@
|
||||
Name: fence-agents
|
||||
Summary: Set of unified programs capable of host isolation ("fencing")
|
||||
Version: 4.10.0
|
||||
Release: 120%{?alphatag:.%{alphatag}}%{?dist}
|
||||
Release: 121%{?alphatag:.%{alphatag}}%{?dist}
|
||||
License: GPLv2+ and LGPLv2+
|
||||
URL: https://github.com/ClusterLabs/fence-agents
|
||||
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.gz
|
||||
@ -224,6 +224,7 @@ Patch78: RHEL-183892-fence_ibm_vpc-set-proxy-when-token-is-expired-as-well.patch
|
||||
Patch79: RHEL-154985-fence_openstack-fix-list-action-to-avoid-timeout-with-large-number-of-VMs.patch
|
||||
Patch80: RHEL-193739-1-fence_vmware_rest-add-token-based-authentication.patch
|
||||
Patch81: RHEL-193739-2-fence_vmware_rest-remove-static-token-option.patch
|
||||
Patch82: RHEL-187353-fence_gce-fail-immediately-with-import-error.patch
|
||||
|
||||
### HA support libs/utils ###
|
||||
# all archs
|
||||
@ -431,6 +432,7 @@ BuildRequires: %{systemd_units}
|
||||
%patch -p1 -P 79
|
||||
%patch -p1 -P 80
|
||||
%patch -p1 -P 81
|
||||
%patch -p1 -P 82
|
||||
|
||||
# prevent compilation of something that won't get used anyway
|
||||
sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
|
||||
@ -1536,6 +1538,10 @@ are located on corosync cluster nodes.
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Jul 31 2026 Arslan Ahmad <arahmad@redhat.com> - 4.10.0-121
|
||||
- fence_gce: fail immediately with import errors
|
||||
Resolves: RHEL-187353
|
||||
|
||||
* Thu Jul 30 2026 Arslan Ahmad <arahmad@redhat.com> - 4.10.0-120
|
||||
- fence_vmware_rest: add token-based authentication
|
||||
Resolves: RHEL-193739
|
||||
|
||||
Loading…
Reference in New Issue
Block a user