Merge ~mitchdz/ubuntu/+source/ec2-hibinit-agent:mitch/recreate_swap-focal into ubuntu/+source/ec2-hibinit-agent:ubuntu/focal-devel

Proposed by Mitchell Dzurick
Status: Merged
Merged at revision: 451ede930789c7d4583c1868f22c84657e92da55
Proposed branch: ~mitchdz/ubuntu/+source/ec2-hibinit-agent:mitch/recreate_swap-focal
Merge into: ubuntu/+source/ec2-hibinit-agent:ubuntu/focal-devel
Diff against target: 60 lines (+38/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/lp2031345-recreate-swap-file.patch (+30/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Graham Inggs (community) Approve
Canonical Server Reporter Pending
Review via email: mp+450797@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Graham Inggs (ginggs) wrote :

Looks good to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index ff32d5b..a8c5080 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
1ec2-hibinit-agent (1.0.0-0ubuntu9.5) focal; urgency=medium
2
3 * d/p/lp2031345-recreate-swap-file.patch: Reduce SWAP size if current SWAP
4 is larger than needed (LP: #2031345)
5
6 -- Mitchell Dzurick <mitchell.dzurick@canonical.com> Mon, 28 Aug 2023 07:23:22 -0700
7
1ec2-hibinit-agent (1.0.0-0ubuntu9.4) focal; urgency=medium8ec2-hibinit-agent (1.0.0-0ubuntu9.4) focal; urgency=medium
29
3 * d/p/lp2023924-remove-quotes-from-state-dir.patch: fixes an issue where a10 * d/p/lp2023924-remove-quotes-from-state-dir.patch: fixes an issue where a
diff --git a/debian/patches/lp2031345-recreate-swap-file.patch b/debian/patches/lp2031345-recreate-swap-file.patch
4new file mode 10064411new file mode 100644
index 0000000..04590c7
--- /dev/null
+++ b/debian/patches/lp2031345-recreate-swap-file.patch
@@ -0,0 +1,30 @@
1Description: Recreating the swap file if the current size is sufficiently larger.
2Author: deborshi1988 <deborshi.only@gmail.com>
3Origin: backport, https://github.com/aws/amazon-ec2-hibinit-agent/commit/d2ce783d10d3a4437ebac468ed669666d8b6671b
4Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/ec2-hibinit-agent/+bug/2031345
5Last-Update: 2023-08-28
6---
7This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
8--- a/agent/hibinit-agent
9+++ b/agent/hibinit-agent
10@@ -43,6 +43,7 @@
11 IMDS_BASEURL = 'http://169.254.169.254'
12 IMDS_API_TOKEN_PATH = 'latest/api/token'
13 IMDS_SPOT_ACTION_PATH = 'latest/meta-data/hibernation/configured'
14+MAX_SWAP_SIZE_OFFSET_ALLOWED = 100 * 1024
15
16 def log(message):
17 if log_to_syslog:
18@@ -440,7 +441,11 @@
19 cur_swap = os.path.getsize(SWAP_FILE)
20
21 bi = None
22- if cur_swap >= target_swap_size - SWAP_RESERVED_SIZE:
23+ if cur_swap > target_swap_size - SWAP_RESERVED_SIZE + MAX_SWAP_SIZE_OFFSET_ALLOWED:
24+ log("Swap already exists! (have %d, need %d), deleting existing swap file %s since current swap is sufficiently large and wasting memory" %
25+ (cur_swap, target_swap_size, SWAP_FILE))
26+ os.remove(SWAP_FILE)
27+ elif cur_swap >= target_swap_size - SWAP_RESERVED_SIZE:
28 log("There's sufficient swap available (have %d, need %d)" %
29 (cur_swap, target_swap_size))
30 update_kernel_swap_offset(config.swapon, config.swapoff, SWAP_FILE, config.grub_update)
diff --git a/debian/patches/series b/debian/patches/series
index 0656b89..f66ab04 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -11,3 +11,4 @@ lp1968805-Swapon-with-maximum-priority-before-hibernation.patch
11lp1941785-Add-support-for-IMDSv2.patch11lp1941785-Add-support-for-IMDSv2.patch
12lp2023924-remove-quotes-from-state-dir.patch12lp2023924-remove-quotes-from-state-dir.patch
13lp2024505-fix-locale-issue.patch13lp2024505-fix-locale-issue.patch
14lp2031345-recreate-swap-file.patch

Subscribers

People subscribed via source and target branches