sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init a year ago
Clone
d1c5ca
From 4f177d3363a0efb2ee67b8a46efaca7707c2437f Mon Sep 17 00:00:00 2001
d1c5ca
From: Eduardo Otubo <otubo@redhat.com>
d1c5ca
Date: Mon, 24 Aug 2020 15:25:36 +0200
d1c5ca
Subject: [PATCH 2/3] swap file "size" being used before checked if str (#315)
d1c5ca
d1c5ca
RH-Author: Eduardo Otubo <otubo@redhat.com>
d1c5ca
Message-id: <20200820092042.5418-3-otubo@redhat.com>
d1c5ca
Patchwork-id: 98192
d1c5ca
O-Subject: [RHEL-8.3.0 cloud-init PATCH 2/3] swap file "size" being used before checked if str (#315)
d1c5ca
Bugzilla: 1794664
d1c5ca
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
d1c5ca
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
d1c5ca
d1c5ca
commit 46cf23c28812d3e3ba0c570defd9a05628af5556
d1c5ca
Author: Eduardo Otubo <otubo@redhat.com>
d1c5ca
Date:   Tue Apr 14 17:45:14 2020 +0200
d1c5ca
d1c5ca
    swap file "size" being used before checked if str
d1c5ca
d1c5ca
    Swap file size variable was being used before checked if it's set to str
d1c5ca
    "auto". If set to "auto", it will break with:
d1c5ca
d1c5ca
      failed to setup swap: unsupported operand type(s) for /: 'str' and 'int'
d1c5ca
d1c5ca
    Signed-off-by: Eduardo Otubo <otubo@redhat.com>
d1c5ca
d1c5ca
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
d1c5ca
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
d1c5ca
---
d1c5ca
 cloudinit/config/cc_mounts.py | 2 +-
d1c5ca
 1 file changed, 1 insertion(+), 1 deletion(-)
d1c5ca
d1c5ca
diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py
d1c5ca
index 4293844..0573026 100644
d1c5ca
--- a/cloudinit/config/cc_mounts.py
d1c5ca
+++ b/cloudinit/config/cc_mounts.py
d1c5ca
@@ -274,7 +274,6 @@ def setup_swapfile(fname, size=None, maxsize=None):
d1c5ca
     maxsize: the maximum size
d1c5ca
     """
d1c5ca
     swap_dir = os.path.dirname(fname)
d1c5ca
-    mibsize = str(int(size / (2 ** 20)))
d1c5ca
     if str(size).lower() == "auto":
d1c5ca
         try:
d1c5ca
             memsize = util.read_meminfo()['total']
d1c5ca
@@ -286,6 +285,7 @@ def setup_swapfile(fname, size=None, maxsize=None):
d1c5ca
         size = suggested_swapsize(fsys=swap_dir, maxsize=maxsize,
d1c5ca
                                   memsize=memsize)
d1c5ca
 
d1c5ca
+    mibsize = str(int(size / (2 ** 20)))
d1c5ca
     if not size:
d1c5ca
         LOG.debug("Not creating swap: suggested size was 0")
d1c5ca
         return
d1c5ca
-- 
d1c5ca
1.8.3.1
d1c5ca