Performing verification for Bionic.

Bionic seems to hibernate okay on both Xen and KVM based instances, so I tested 
both t2.medium and c5.large instance types. Each had 20gb of storage, with 
advanced > enable encryption > yes.
I also made sure to enable Advanced settings > Stop State (Hibernation) Support 
> Enabled.

I started two sets of instances, one with 1.0.0-0ubuntu4~18.04.5 from
-updates, and the other with 1.0.0-0ubuntu4~18.04.6 from -proposed.

After leaving each instance for a few minutes to finish setting up
hibinit-agent.service, I pressed Instance State > Hibernate.

Both instances hibernated successfully, and within 30 seconds of
pressing the hibernate button.

I then started both instances, and ssh'd in. My screen sessions were
both active, so hibernation was successful.

The base case of no additional swapfile configured results in correct
hibernation for both -updates and -proposed packages.

I then followed the below steps, and added an additional swapfile to
each instance.

$ sudo fallocate -l 4G /swapfile
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=4194304
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ echo "/swapfile swap swap defaults 0 0" | sudo tee -a /etc/fstab
$ swapon --show
NAME TYPE SIZE USED PRIO
/swapfile file 4G 0B -2

I went back to the console and pressed Instance State > Hibernate.

This time, both instances hibernated successfully, and completed within
30 seconds of pressing the hibernate button. Bionic has a different
behaviour to that of Focal and onward, where the -updates package would
stay running, and be force stopped 20 minutes later. On Bionic, both
hibernate successfully.

I then started both instances. Both instances came up correctly, and I
could ssh in. But my screen sessions were missing, and journalctl showed
this was a fresh boot for both instances. It seems Bionic has issues
resuming from hibernation when there is an additional swapfile set, but
most users do not notice it, because the instance comes up and starts
correctly, as if hibernation had been successful.

Journalctl in both suggests that it wasn't aware that it was hibernated
in the first place as no attempt to resume was made, so perhaps we are
setting the resume= variable on the kernel command line wrong. I
checked, and Bionic sets it as:

resume_offset=401408 resume=PARTUUID=80f6dacd-01

I checked the offsets manually with

$ findmnt -no PARTUUID -T /swap-hibinit
80f6dacd-01

$ sudo filefrag -v /swap-hibinit
Filesystem type is: ef53
File size of /swap-hibinit is 4194304000 (1024000 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       0:     401408..    401408:      1:     
   
everything matched. Very strange. It should have resumed...

Regardless of the outcome, I checked journalctl of the previous boot,
and for the instance with -updates enabled, we see:

Jun 03 05:04:02 ip-172-31-26-1 systemd-logind[1108]: Suspend key pressed.
Jun 03 05:04:02 ip-172-31-26-1 systemd-logind[1108]: Requested operation not 
supported, ignoring.
Jun 03 05:04:02 ip-172-31-26-1 kernel: Adding 4095996k swap on /swap-hibinit.  
Priority:-3 extents:5 across:43827
Jun 03 05:04:02 ip-172-31-26-1 systemd[1]: Reached target Sleep.
Jun 03 05:04:02 ip-172-31-26-1 systemd[1]: Starting Hibernate...
Jun 03 05:04:02 ip-172-31-26-1 kernel: PM: Image not found (code -16)
Jun 03 05:04:02 ip-172-31-26-1 systemd-sleep[3321]: Suspending system...
Jun 03 05:04:02 ip-172-31-26-1 kernel: PM: hibernation entry

/swap-hibinit is still enabled at priority -3, so this specific
launchpad bug still exists on Bionic, and the /swap file will be
selected for hibernation instead, due to it having a priority of -2.

On the instance with -proposed enabled:

Jun 03 05:04:02 ip-172-31-25-176 systemd-logind[3432]: Suspend key pressed.
Jun 03 05:04:02 ip-172-31-25-176 systemd-logind[3432]: Requested operation not 
supported, ignoring.
Jun 03 05:04:02 ip-172-31-25-176 kernel: Adding 4095996k swap on /swap-hibinit. 
 Priority:32767 extents:5 across:
Jun 03 05:04:02 ip-172-31-25-176 systemd[1]: Reached target Sleep.
Jun 03 05:04:02 ip-172-31-25-176 systemd[1]: Starting Hibernate...
Jun 03 05:04:02 ip-172-31-25-176 kernel: PM: Image not found (code -16)
Jun 03 05:04:02 ip-172-31-25-176 systemd-sleep[4314]: Suspending system...
Jun 03 05:04:02 ip-172-31-25-176 kernel: PM: hibernation entry

/swap-hibinit is added with priority 32767, and will be selected over
/swapfile, since it beats -2.

The changes in this SRU are still beneficial and needed, and worth the
regression risk even though there is no behavioural change to the user
with the package in -proposed versus the package in -updates. It also
keeps the code in ec2-hibinit-agent in sync with focal and onward
regards to changes.

I think we should look into the hibernation issue with Bionic in a
separate bug, and track it there, and keep this bug about making sure
/swap-hibinit is enabled with priority higher than any other swapfile.

So, I will be marking this bug as verification done for Bionic, but I
will keep looking into this on the Bionic side.

** Tags removed: verification-needed verification-needed-bionic
** Tags added: verification-done-bionic

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1968805

Title:
  Hibernation fails when an additional swapfile is added due to priority
  mismatch

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ec2-hibinit-agent/+bug/1968805/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to