From 2ebeb61bbb6573874a24df7568d2f4c70c6e376a Mon Sep 17 00:00:00 2001 From: Frank Liang Date: Tue, 18 Mar 2025 09:37:33 +0800 Subject: [PATCH 1/4] fix swapoff breaks hibernate process Refs: https://github.com/aws/amazon-ec2-hibinit-agent/pull/50 Signed-off-by: Frank Liang --- ...fix-swapoff-breaks-hibernate-process.patch | 59 +++++++++++++++++++ ec2-hibinit-agent.spec | 6 +- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 0002-rhel-fix-swapoff-breaks-hibernate-process.patch diff --git a/0002-rhel-fix-swapoff-breaks-hibernate-process.patch b/0002-rhel-fix-swapoff-breaks-hibernate-process.patch new file mode 100644 index 0000000..06c042e --- /dev/null +++ b/0002-rhel-fix-swapoff-breaks-hibernate-process.patch @@ -0,0 +1,59 @@ +From 0197c7173a5ad1470060862a0be96b9a976bdf49 Mon Sep 17 00:00:00 2001 +From: Frank Liang +Date: Thu, 2 Jan 2025 22:28:12 +0800 +Subject: [PATCH] rhel: fix swapoff breaks hibernate process + +hibernate() always calling swapoff breaks hibernation process. +The hibernation wont continue if call swapoff too fast in rhel or amazon +linux. + +"swapon --priority=32767 /swap && systemctl hibernate ;echo $?; swapoff /swap" + +Signed-off-by: Frank Liang +--- + packaging/rhel/acpid.sleep.sh | 17 ++++++----------- + 1 file changed, 6 insertions(+), 11 deletions(-) + +diff --git a/packaging/rhel/acpid.sleep.sh b/packaging/rhel/acpid.sleep.sh +index 9b381f9..1e55b51 100755 +--- a/packaging/rhel/acpid.sleep.sh ++++ b/packaging/rhel/acpid.sleep.sh +@@ -11,29 +11,24 @@ swap_priority=32767 + hibernate() + { + swapon --priority=$swap_priority /swap && systemctl hibernate +- if [ $? -ne 0 ] +- then ++ if [ $? -ne 0 ]; then + logger "Hibernation failed, Sleeping 2 mins before retry" + failed='true' ++ swapoff /swap ++ sleep 2m + else + failed='false' + fi +- swapoff /swap + } + + case "$2" in + SBTN) + # The iteration had been placed here to add retry logic to hibernation + # in case of failures and to avoid force stop of instances after 20min +- for i in 1 2 3 +- do ++ for i in 1 2 3; do + hibernate +- if [ $failed == 'true' ]; +- then +- swapoff /swap +- sleep 2m +- else +- break ++ if [ $failed == 'false' ]; then ++ break + fi + done + ;; +-- +2.48.1 + diff --git a/ec2-hibinit-agent.spec b/ec2-hibinit-agent.spec index 876af8e..c2e4e9a 100644 --- a/ec2-hibinit-agent.spec +++ b/ec2-hibinit-agent.spec @@ -12,7 +12,7 @@ Name: ec2-hibinit-agent Version: 1.0.9 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Hibernation setup utility for Amazon EC2 License: Apache-2.0 @@ -22,6 +22,7 @@ Source0: https://github.com/aws/%{project}/archive/v%{version}/%{name}-%{ # Ensure swapon with maximum priority before hibernation # Upstream Patch: https://github.com/aws/amazon-ec2-hibinit-agent/pull/49) Patch1: 0001-swapon-with-maximum-priority-before-hibernation.patch +Patch2: 0002-rhel-fix-swapoff-breaks-hibernate-process.patch BuildArch: noarch @@ -148,6 +149,9 @@ fi %selinux_relabel_post -s %{selinuxtype} %changelog +* Tue Mar 18 2025 Frank Liang - 1.0.9-5 +- Include upstream Patch to fix swapoff breaks hibernate process + * Fri Nov 08 2024 Dominik Wombacher - 1.0.9-4 - Include upstream Patch to ensure swapon with maximum priority before hibernation - Resolves rhbz#2322884 From 42c39a883c4b81c2bfde26013cb6b4971035c823 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Thu, 20 Mar 2025 10:13:58 +0000 Subject: [PATCH 2/4] fix: align changelog and release with rawhide branch to avoid merge conflicts --- ec2-hibinit-agent.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ec2-hibinit-agent.spec b/ec2-hibinit-agent.spec index c2e4e9a..1d38962 100644 --- a/ec2-hibinit-agent.spec +++ b/ec2-hibinit-agent.spec @@ -12,7 +12,7 @@ Name: ec2-hibinit-agent Version: 1.0.9 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Hibernation setup utility for Amazon EC2 License: Apache-2.0 @@ -149,9 +149,12 @@ fi %selinux_relabel_post -s %{selinuxtype} %changelog -* Tue Mar 18 2025 Frank Liang - 1.0.9-5 +* Tue Mar 18 2025 Frank Liang - 1.0.9-6 - Include upstream Patch to fix swapoff breaks hibernate process +* Thu Jan 16 2025 Fedora Release Engineering - 1.0.9-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + * Fri Nov 08 2024 Dominik Wombacher - 1.0.9-4 - Include upstream Patch to ensure swapon with maximum priority before hibernation - Resolves rhbz#2322884 From b01e3c9b651437ade275ad10e81506c5f4c6e195 Mon Sep 17 00:00:00 2001 From: Python Maint Date: Tue, 3 Jun 2025 12:20:16 +0200 Subject: [PATCH 3/4] Rebuilt for Python 3.14 --- ec2-hibinit-agent.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ec2-hibinit-agent.spec b/ec2-hibinit-agent.spec index 1d38962..c26867c 100644 --- a/ec2-hibinit-agent.spec +++ b/ec2-hibinit-agent.spec @@ -12,7 +12,7 @@ Name: ec2-hibinit-agent Version: 1.0.9 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Hibernation setup utility for Amazon EC2 License: Apache-2.0 @@ -149,6 +149,9 @@ fi %selinux_relabel_post -s %{selinuxtype} %changelog +* Tue Jun 03 2025 Python Maint - 1.0.9-7 +- Rebuilt for Python 3.14 + * Tue Mar 18 2025 Frank Liang - 1.0.9-6 - Include upstream Patch to fix swapoff breaks hibernate process From 907cf67e48e5e8841e253f02bd71556fd8680e75 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 23 Jul 2025 19:41:21 +0000 Subject: [PATCH 4/4] Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild --- ec2-hibinit-agent.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ec2-hibinit-agent.spec b/ec2-hibinit-agent.spec index c26867c..9defa5e 100644 --- a/ec2-hibinit-agent.spec +++ b/ec2-hibinit-agent.spec @@ -12,7 +12,7 @@ Name: ec2-hibinit-agent Version: 1.0.9 -Release: 7%{?dist} +Release: 8%{?dist} Summary: Hibernation setup utility for Amazon EC2 License: Apache-2.0 @@ -149,6 +149,9 @@ fi %selinux_relabel_post -s %{selinuxtype} %changelog +* Wed Jul 23 2025 Fedora Release Engineering - 1.0.9-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + * Tue Jun 03 2025 Python Maint - 1.0.9-7 - Rebuilt for Python 3.14