← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1897099] Re: create_swap do not fallback to dd when fallocate fails

 

This bug is believed to be fixed in cloud-init in version 20.4. If this
is still a problem for you, please make a comment and set the state back
to New

Thank you.

** Changed in: cloud-init
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1897099

Title:
  create_swap do not fallback to dd when fallocate fails

Status in cloud-init:
  Fix Released

Bug description:
  Name            : cloud-init
  Version         : 20.2-1

  Code in questioning:  cloudinit/config/cc_mounts.py

          try:
              create_swap(fname, size, "fallocate")
          except util.ProcessExecutionError as e:
              LOG.warning(errmsg, fname, size, "dd", e)
              LOG.warning("Will attempt with dd.")
              create_swap(fname, size, "dd")


  as there is a kernel bug in latest's linux versions, fallocate creates swap images with holes.
  The workaround is to move fallocate (make create_swap function to fail) so that cloud-init will fallback to dd.

  
  Used bootcmd (or cloud-boothook) to rename (move) fallocate binary from my system but according the the logs, it didnt fallback to dd as it should. Probably the error was not ProcessExecutionError 

  
  Logs:

  /var/log/cloud-init-output.log:2020-09-24 09:13:16,470 - cc_mounts.py[WARNING]: Failed to create swapfile '/swapfile' of size 2048MB via fallocate: Unexpected
   error while running command.
  /var/log/cloud-init-output.log:Command: ['fallocate', '-l', '2048M', '/swapfile']
  /var/log/cloud-init-output.log:Reason: [Errno 2] No such file or directory: b'fallocate'
  /var/log/cloud-init-output.log:2020-09-24 09:13:16,479 - cc_mounts.py[WARNING]: failed to setup swap: [Errno 2] No such file or directory: '/swapfile'
  /var/log/cloud-init-output.log:chmod: cannot access '/usr/bin/fallocate': No such file or directory
  /var/log/cloud-init.log:2020-09-24 09:13:16,460 - cc_mounts.py[DEBUG]: Attempting to determine the real name of swap
  /var/log/cloud-init.log:2020-09-24 09:13:16,460 - cc_mounts.py[DEBUG]: changed default device swap => None
  /var/log/cloud-init.log:2020-09-24 09:13:16,460 - cc_mounts.py[DEBUG]: Ignoring nonexistent default named mount swap
  /var/log/cloud-init.log:2020-09-24 09:13:16,461 - cc_mounts.py[DEBUG]: suggest 2048.0 MB swap for 1983.953125 MB memory with '9030.296875 MB' disk given max=2048.0 MB [max=2048.0 MB]'
  /var/log/cloud-init.log:2020-09-24 09:13:16,461 - cc_mounts.py[DEBUG]: Creating swapfile in '/swapfile' on fstype 'ext4' using 'fallocate'
  /var/log/cloud-init.log:2020-09-24 09:13:16,461 - util.py[DEBUG]: Running command ['fallocate', '-l', '2048M', '/swapfile'] with allowed return codes [0] (she
  ll=False, capture=True)
  /var/log/cloud-init.log:2020-09-24 09:13:16,470 - cc_mounts.py[WARNING]: Failed to create swapfile '/swapfile' of size 2048MB via fallocate: Unexpected error while running command.
  /var/log/cloud-init.log:Command: ['fallocate', '-l', '2048M', '/swapfile']
  /var/log/cloud-init.log:Reason: [Errno 2] No such file or directory: b'fallocate'
  /var/log/cloud-init.log:2020-09-24 09:13:16,479 - util.py[DEBUG]: Attempting to remove /swapfile
  /var/log/cloud-init.log:2020-09-24 09:13:16,479 - util.py[DEBUG]: Setting up swap file took 0.019 seconds
  /var/log/cloud-init.log:2020-09-24 09:13:16,479 - cc_mounts.py[WARNING]: failed to setup swap: [Errno 2] No such file or directory: '/swapfile'

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1897099/+subscriptions


References