sailesh1993 / rpms / cloud-init

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