|
|
faf1e5 |
From 6f8623c570247903e3cba925676677e44a99c69c Mon Sep 17 00:00:00 2001
|
|
|
faf1e5 |
From: Eduardo Otubo <otubo@redhat.com>
|
|
|
faf1e5 |
Date: Tue, 28 Apr 2020 08:22:05 +0200
|
|
|
faf1e5 |
Subject: [PATCH 2/3] swap file "size" being used before checked if str (#315)
|
|
|
faf1e5 |
|
|
|
faf1e5 |
RH-Author: Eduardo Otubo <otubo@redhat.com>
|
|
|
faf1e5 |
Message-id: <20200422130428.7663-3-otubo@redhat.com>
|
|
|
faf1e5 |
Patchwork-id: 96033
|
|
|
faf1e5 |
O-Subject: [RHEL-7.7.z/RHEL-7.8.z cloud-init PATCH 2/3] swap file "size" being used before checked if str (#315)
|
|
|
faf1e5 |
Bugzilla: 1801094
|
|
|
faf1e5 |
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
faf1e5 |
RH-Acked-by: Cathy Avery <cavery@redhat.com>
|
|
|
faf1e5 |
|
|
|
faf1e5 |
commit 46cf23c28812d3e3ba0c570defd9a05628af5556
|
|
|
faf1e5 |
Author: Eduardo Otubo <otubo@redhat.com>
|
|
|
faf1e5 |
Date: Tue Apr 14 18:16:25 2020 +0200
|
|
|
faf1e5 |
|
|
|
faf1e5 |
swap file "size" being used before checked if str (#315)
|
|
|
faf1e5 |
|
|
|
faf1e5 |
Swap file size variable was being used before checked if it's set to str
|
|
|
faf1e5 |
"auto". If set to "auto", it will break with:
|
|
|
faf1e5 |
|
|
|
faf1e5 |
failed to setup swap: unsupported operand type(s) for /: 'str' and 'int'
|
|
|
faf1e5 |
|
|
|
faf1e5 |
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
|
|
|
faf1e5 |
RHBZ: 1772505
|
|
|
faf1e5 |
|
|
|
faf1e5 |
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
|
|
|
faf1e5 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
faf1e5 |
---
|
|
|
faf1e5 |
cloudinit/config/cc_mounts.py | 2 +-
|
|
|
faf1e5 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
faf1e5 |
|
|
|
faf1e5 |
diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py
|
|
|
faf1e5 |
index 6884ddf..811781f 100644
|
|
|
faf1e5 |
--- a/cloudinit/config/cc_mounts.py
|
|
|
faf1e5 |
+++ b/cloudinit/config/cc_mounts.py
|
|
|
faf1e5 |
@@ -274,7 +274,6 @@ def setup_swapfile(fname, size=None, maxsize=None):
|
|
|
faf1e5 |
maxsize: the maximum size
|
|
|
faf1e5 |
"""
|
|
|
faf1e5 |
swap_dir = os.path.dirname(fname)
|
|
|
faf1e5 |
- mibsize = str(int(size / (2 ** 20)))
|
|
|
faf1e5 |
if str(size).lower() == "auto":
|
|
|
faf1e5 |
try:
|
|
|
faf1e5 |
memsize = util.read_meminfo()['total']
|
|
|
faf1e5 |
@@ -286,6 +285,7 @@ def setup_swapfile(fname, size=None, maxsize=None):
|
|
|
faf1e5 |
size = suggested_swapsize(fsys=swap_dir, maxsize=maxsize,
|
|
|
faf1e5 |
memsize=memsize)
|
|
|
faf1e5 |
|
|
|
faf1e5 |
+ mibsize = str(int(size / (2 ** 20)))
|
|
|
faf1e5 |
if not size:
|
|
|
faf1e5 |
LOG.debug("Not creating swap: suggested size was 0")
|
|
|
faf1e5 |
return
|
|
|
faf1e5 |
--
|
|
|
faf1e5 |
1.8.3.1
|
|
|
faf1e5 |
|