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

Subscribers

People subscribed via source and target branches