From a6359253e676c54e8fdc5127b1d60e9e52610610 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Jan 19 2022 21:16:42 +0000 Subject: import fence-agents-4.2.1-84.el8 --- diff --git a/SOURCES/bz1977588-5-fence_kubevirt-get-namespace-from-context.patch b/SOURCES/bz1977588-5-fence_kubevirt-get-namespace-from-context.patch new file mode 100644 index 0000000..aa394e0 --- /dev/null +++ b/SOURCES/bz1977588-5-fence_kubevirt-get-namespace-from-context.patch @@ -0,0 +1,88 @@ +From 647841dea9d93922779a4aa7d0b5f52f5bc2b4e9 Mon Sep 17 00:00:00 2001 +From: Dan Kenigsberg +Date: Thu, 13 Jan 2022 14:57:26 +0200 +Subject: [PATCH] fence_kubevirt: take default namespace from context + +If --namespace is not provided to kubectl, a default one is taken from +kubeconfig context. Let fence_kubevirt behave similarly. + +Signed-off-by: Dan Kenigsberg +--- + agents/kubevirt/fence_kubevirt.py | 24 +++++++++++++----------- + 2 files changed, 14 insertions(+), 12 deletions(-) + +diff --git a/agents/kubevirt/fence_kubevirt.py b/agents/kubevirt/fence_kubevirt.py +index 8392b75a0..8c27a0334 100755 +--- a/agents/kubevirt/fence_kubevirt.py ++++ b/agents/kubevirt/fence_kubevirt.py +@@ -12,12 +12,21 @@ + except ImportError: + logging.error("Couldn\'t import kubernetes.client.exceptions.ApiException - not found or not accessible") + ++def _get_namespace(options): ++ from kubernetes import config ++ ++ ns = options.get("--namespace") ++ if ns is None: ++ ns = config.kube_config.list_kube_config_contexts()[1]['context']['namespace'] ++ ++ return ns ++ + def get_nodes_list(conn, options): + logging.debug("Starting list/monitor operation") + result = {} + try: + apiversion = options.get("--apiversion") +- namespace = options.get("--namespace") ++ namespace = _get_namespace(options) + include_uninitialized = True + vm_api = conn.resources.get(api_version=apiversion, kind='VirtualMachine') + vm_list = vm_api.get(namespace=namespace) +@@ -31,7 +40,7 @@ def get_power_status(conn, options): + logging.debug("Starting get status operation") + try: + apiversion = options.get("--apiversion") +- namespace = options.get("--namespace") ++ namespace = _get_namespace(options) + name = options.get("--plug") + vmi_api = conn.resources.get(api_version=apiversion, + kind='VirtualMachineInstance') +@@ -61,7 +70,7 @@ def set_power_status(conn, options): + logging.debug("Starting set status operation") + try: + apiversion= options.get("--apiversion") +- namespace = options.get("--namespace") ++ namespace = _get_namespace(options) + name = options.get("--plug") + action = 'start' if options["--action"] == "on" else 'stop' + virtctl_vm_action(conn, action, namespace, name, apiversion) +@@ -75,7 +84,7 @@ def define_new_opts(): + "longopt" : "namespace", + "help" : "--namespace=[namespace] Namespace of the KubeVirt machine", + "shortdesc" : "Namespace of the KubeVirt machine.", +- "required" : "1", ++ "required" : "0", + "order" : 2 + } + all_opt["kubeconfig"] = { +@@ -101,11 +110,6 @@ def virtctl_vm_action(conn, action, namespace, name, apiversion): + path = path.format(api_version=apiversion, namespace=namespace, name=name, action=action) + return conn.request('put', path, header_params={'accept': '*/*'}) + +-def validate_options(required_options_list, options): +- for required_option in required_options_list: +- if required_option not in options: +- fail_usage("Failed: %s option must be provided" % required_option) +- + # Main agent method + def main(): + conn = None +@@ -127,8 +131,6 @@ def main(): + + run_delay(options) + +- validate_options(['--namespace'], options) +- + # Disable insecure-certificate-warning message + if "--ssl-insecure" in options: + import urllib3 diff --git a/SPECS/fence-agents.spec b/SPECS/fence-agents.spec index 7eff500..552523c 100644 --- a/SPECS/fence-agents.spec +++ b/SPECS/fence-agents.spec @@ -79,7 +79,7 @@ Name: fence-agents Summary: Set of unified programs capable of host isolation ("fencing") Version: 4.2.1 -Release: 83%{?alphatag:.%{alphatag}}%{?dist} +Release: 84%{?alphatag:.%{alphatag}}%{?dist} License: GPLv2+ and LGPLv2+ Group: System Environment/Base URL: https://github.com/ClusterLabs/fence-agents @@ -235,6 +235,7 @@ Patch103: bz1977588-2-fence_kubevirt.patch Patch104: bz1977588-3-fence_kubevirt-fix-status.patch Patch105: bz1977588-4-fence_kubevirt-power-timeout-40s.patch Patch106: bz1963163-fence_zvmip-add-ssl-tls-support.patch +Patch107: bz1977588-5-fence_kubevirt-get-namespace-from-context.patch %if 0%{?fedora} || 0%{?rhel} > 7 %global supportedagents amt_ws apc apc_snmp bladecenter brocade cisco_mds cisco_ucs compute drac5 eaton_snmp emerson eps evacuate hds_cb hpblade ibmblade ibm_powervs ibm_vpc ifmib ilo ilo_moonshot ilo_mp ilo_ssh intelmodular ipdu ipmilan kdump kubevirt lpar mpath redfish rhevm rsa rsb sbd scsi vmware_rest vmware_soap wti @@ -425,6 +426,7 @@ BuildRequires: python3-pip %patch104 -p1 -F1 %patch105 -p1 %patch106 -p1 +%patch107 -p1 # prevent compilation of something that won't get used anyway sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac @@ -1370,14 +1372,14 @@ Fence agent for IBM z/VM over IP. %endif %changelog +* Mon Jan 17 2022 Oyvind Albrigtsen - 4.2.1-84 +- fence_kubevirt: new fence agent + Resolves: rhbz#1977588 + * Thu Nov 11 2021 Oyvind Albrigtsen - 4.2.1-83 - fence_zvmip: add SSL/TLS support Resolves: rhbz#1963163 -* Thu Nov 4 2021 Oyvind Albrigtsen - 4.2.1-82 -- fence_kubevirt: new fence agent - Resolves: rhbz#1977588 - * Tue Nov 2 2021 Oyvind Albrigtsen - 4.2.1-80 - fence_sbd: dont spam logs when disable_timeout is enabled Resolves: rhbz#1971683