summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorEduardo Otubo <otubo@redhat.com>2020-04-14 18:16:25 +0200
committerGitHub <noreply@github.com>2020-04-14 10:16:25 -0600
commit46cf23c28812d3e3ba0c570defd9a05628af5556 (patch)
treee57beead38fd72c46198595f56c7b18f0ee8bfe8 /cloudinit/config
parent48b15bf3fbfb74e1112c86c63f55dea2c76adfa3 (diff)
downloadvyos-cloud-init-46cf23c28812d3e3ba0c570defd9a05628af5556.tar.gz
vyos-cloud-init-46cf23c28812d3e3ba0c570defd9a05628af5556.zip
swap file "size" being used before checked if str (#315)
Swap file size variable was being used before checked if it's set to str "auto". If set to "auto", it will break with: failed to setup swap: unsupported operand type(s) for /: 'str' and 'int' Signed-off-by: Eduardo Otubo <otubo@redhat.com> RHBZ: 1772505
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_mounts.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py
index 73537e71..1f077bf5 100644
--- a/cloudinit/config/cc_mounts.py
+++ b/cloudinit/config/cc_mounts.py
@@ -287,7 +287,6 @@ def setup_swapfile(fname, size=None, maxsize=None):
maxsize: the maximum size
"""
swap_dir = os.path.dirname(fname)
- mibsize = str(int(size / (2 ** 20)))
if str(size).lower() == "auto":
try:
memsize = util.read_meminfo()['total']
@@ -299,6 +298,7 @@ def setup_swapfile(fname, size=None, maxsize=None):
size = suggested_swapsize(fsys=swap_dir, maxsize=maxsize,
memsize=memsize)
+ mibsize = str(int(size / (2 ** 20)))
if not size:
LOG.debug("Not creating swap: suggested size was 0")
return