ec2-hibinit-agent: Add support for IMDSv2
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-images |
New
|
Undecided
|
Unassigned | ||
ec2-hibinit-agent (Ubuntu) |
Fix Released
|
Undecided
|
Mitchell Dzurick | ||
Xenial |
Fix Released
|
Undecided
|
Mitchell Dzurick | ||
Bionic |
Fix Released
|
Undecided
|
Mitchell Dzurick | ||
Focal |
Fix Released
|
Undecided
|
Mitchell Dzurick | ||
Impish |
Won't Fix
|
Undecided
|
Unassigned | ||
Jammy |
Fix Released
|
Undecided
|
Mitchell Dzurick | ||
Kinetic |
Fix Released
|
Undecided
|
Mitchell Dzurick | ||
Lunar |
Fix Released
|
Undecided
|
Mitchell Dzurick | ||
Mantic |
Fix Released
|
Undecided
|
Mitchell Dzurick |
Bug Description
[Impact]
If an Amazon Instance is set to require IMDSv2 and enable hibernation, the instance will get stuck in a "stopping" state when hibernation is triggered, and no VM state is preserved. Changes to support IMDSv2 in ec2-hibinit-agent are needed to prevent this behavior when only using IMDSv2.
[Fix]
Backport a portion of https:/
[Test Case]
# To test the failure
# This test case is written for Mantic but will apply to all distributions
1. Create an amazon EC2 instance with the following properties
- AMI - ami-0c2d04617e3
- t3.micro
- encrypted 8GB EBS volume with default key
- Stop - Hibernate behavior: Enable
- Metadata accessible : Enable
- Metadata version Info : V2 only (token required)
2. Wait for instance to say "Running"
3. Initiate Hibernation
# At this point the machine will stay stuck in the "Stopping" State and you will have to force stop the machine.
# To test the fix
1. Create an amazon EC2 instance with the following properties
- AMI - ami-0c2d04617e3
- t3.micro
- encrypted 8GB EBS volume with default key
- Stop - Hibernate behavior: Enable
- Metadata accessible : Enable
- Metadata version Info : V2 only (token required)
2. Wait for instance to say "Running"
3. ssh into your instance
4. (Before Change is Merged) add PPA for updated package; apt update && apt upgrade
5. Create a test program
```
/bin/cat <<EOM >~/allocate_mem.py
#!/usr/bin/python3
import time
# Allocate 200MB chunk of memory
size = 200 * 1024 * 1024 # 200MB
memory_chunk = bytearray(size)
print("Allocated 200MB of memory.")
# Enter indefinite loop
while True:
time.sleep(1) # Wait for 1 second
# The script will never reach this point
EOM
```
6. Run a background process
```
python3 ~/allocate_mem.py &
```
7. Hibernate the instance
8. Wait for Instance to be in "Stopped" State
9. Start the intsance
10. ssh into instance
11. Check that the process is running
$ ps aux | grep allocate_mem
ubuntu 2532 1.1 23.0 221948 213248 pts/0 S 13:43 0:00 python3 /home/ubuntu/
[Where problems could occur]
Hibernation may not properly occur which would result in a loss of VM state and the end user needing to force stop the instance.
Related branches
- git-ubuntu import: Pending requested
-
Diff: 220 lines (+192/-0)4 files modifieddebian/changelog (+10/-0)
debian/patches/lp1941785-Add-support-for-IMDSv2.patch (+161/-0)
debian/patches/lp2023924-remove-quotes-from-state-dir.patch (+19/-0)
debian/patches/series (+2/-0)
- git-ubuntu import: Pending requested
-
Diff: 375 lines (+312/-2)8 files modifieddebian/changelog (+16/-0)
debian/ec2-hibinit-agent.install (+1/-0)
debian/hibinit-agent.system-sleep (+1/-2)
debian/hibinit-resume (+48/-0)
debian/patches/lp1941785-Add-support-for-IMDSv2.patch (+161/-0)
debian/patches/lp1968805-Swapon-with-maximum-priority-before-hibernation.patch (+63/-0)
debian/patches/lp2023924-remove-quotes-from-state-dir.patch (+19/-0)
debian/patches/series (+3/-0)
- Athos Ribeiro (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 191 lines (+169/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/lp1941785-Add-support-for-IMDSv2.patch (+161/-0)
debian/patches/series (+1/-0)
- Athos Ribeiro (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 191 lines (+169/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/lp1941785-Add-support-for-IMDSv2.patch (+161/-0)
debian/patches/series (+1/-0)
- Athos Ribeiro (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 190 lines (+168/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/lp1941785-Add-support-for-IMDSv2.patch (+160/-0)
debian/patches/series (+1/-0)
- Athos Ribeiro (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 191 lines (+169/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/lp1941785-Add-support-for-IMDSv2.patch (+161/-0)
debian/patches/series (+1/-0)
- Athos Ribeiro (community): Approve
- Ubuntu Sponsors: Pending requested
- git-ubuntu import: Pending requested
-
Diff: 191 lines (+169/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/lp1941785-Add-support-for-IMDSv2.patch (+161/-0)
debian/patches/series (+1/-0)
affects: | linux (Ubuntu) → ec2-hibinit-agent (Ubuntu) |
description: | updated |
description: | updated |
tags: | added: server-todo |
Changed in ec2-hibinit-agent (Ubuntu): | |
status: | New → In Progress |
Changed in ec2-hibinit-agent (Ubuntu Focal): | |
assignee: | nobody → Mitchell Dzurick (mitchdz) |
Changed in ec2-hibinit-agent (Ubuntu Jammy): | |
assignee: | nobody → Mitchell Dzurick (mitchdz) |
Changed in ec2-hibinit-agent (Ubuntu Kinetic): | |
assignee: | nobody → Mitchell Dzurick (mitchdz) |
Changed in ec2-hibinit-agent (Ubuntu Lunar): | |
assignee: | nobody → Mitchell Dzurick (mitchdz) |
Changed in ec2-hibinit-agent (Ubuntu Mantic): | |
assignee: | nobody → Mitchell Dzurick (mitchdz) |
Changed in ec2-hibinit-agent (Ubuntu Focal): | |
status: | New → In Progress |
Changed in ec2-hibinit-agent (Ubuntu Jammy): | |
status: | New → In Progress |
Changed in ec2-hibinit-agent (Ubuntu Lunar): | |
status: | New → In Progress |
Changed in ec2-hibinit-agent (Ubuntu Kinetic): | |
status: | New → In Progress |
description: | updated |
description: | updated |
tags: |
added: verification-done-focal verification-done-jammy verification-done-kinetic verification-done-lunar removed: verification-needed-focal verification-needed-jammy verification-needed-kinetic verification-needed-lunar |
tags: | removed: server-todo |
Changed in ec2-hibinit-agent (Ubuntu Xenial): | |
assignee: | nobody → Mitchell Dzurick (mitchdz) |
Changed in ec2-hibinit-agent (Ubuntu Bionic): | |
assignee: | nobody → Mitchell Dzurick (mitchdz) |
Ubuntu 21.10 (Impish Indri) has reached end of life, so this bug will not be fixed for that specific release.