mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8952 - Do not restart conntrackd unless it's needed
- With the keepalived fixed they should not be needed anymore. So first reducing them drasticaly - I am now making a backup of the template file, write to the template file and compare it with the existing configuration - The template file is recovered afer the process - I also check if the process is running - I fixed a bug in the compare method - I am now updating the configuration variable once the file content is flushed to disk
This commit is contained in:
parent
5a216056b5
commit
b4920aa028
@ -64,6 +64,9 @@ class CsFile:
|
||||
handle.write(line)
|
||||
handle.close()
|
||||
logging.info("Wrote edited file %s" % self.filename)
|
||||
self.config = list(self.new_config)
|
||||
logging.info("Updated file in-cache configuration")
|
||||
|
||||
|
||||
def dump(self):
|
||||
for line in self.new_config:
|
||||
@ -160,4 +163,6 @@ class CsFile:
|
||||
|
||||
|
||||
def compare(self, o):
|
||||
return (isinstance(o, self.__class__) and set(self.config) == set(o.new_config))
|
||||
result = (isinstance(o, self.__class__) and set(self.config) == set(o.config))
|
||||
logging.debug("Comparison of CsFiles content is ==> %s" % result)
|
||||
return result
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
import logging
|
||||
import os.path
|
||||
import re
|
||||
import shutil
|
||||
from cs.CsDatabag import CsDataBag
|
||||
from CsProcess import CsProcess
|
||||
from CsFile import CsFile
|
||||
@ -37,13 +36,14 @@ class CsLoadBalancer(CsDataBag):
|
||||
return
|
||||
config = self.dbag['config'][0]['configuration']
|
||||
file1 = CsFile(HAPROXY_CONF_T)
|
||||
file2 = CsFile(HAPROXY_CONF_P)
|
||||
file1.empty()
|
||||
for x in config:
|
||||
[file1.append(w, -1) for w in x.split('\n')]
|
||||
if not file2.compare(file1):
|
||||
|
||||
file1.commit()
|
||||
shutil.copy2(HAPROXY_CONF_T, HAPROXY_CONF_P)
|
||||
file2 = CsFile(HAPROXY_CONF_P)
|
||||
if not file2.compare(file1):
|
||||
CsHelper.copy(HAPROXY_CONF_T, HAPROXY_CONF_P)
|
||||
|
||||
proc = CsProcess(['/var/run/haproxy.pid'])
|
||||
if not proc.find():
|
||||
|
||||
@ -131,9 +131,9 @@ class CsRedundant(object):
|
||||
|
||||
CsHelper.copy(conntrackd_template_conf, conntrackd_temp_bkp)
|
||||
|
||||
connt = CsFile(conntrackd_template_conf)
|
||||
conntrackd_tmpl = CsFile(conntrackd_template_conf)
|
||||
if guest is not None:
|
||||
connt.section("Multicast {", "}", [
|
||||
conntrackd_tmpl.section("Multicast {", "}", [
|
||||
"IPv4_address 225.0.0.50\n",
|
||||
"Group 3780\n",
|
||||
"IPv4_interface %s\n" % guest.get_ip(),
|
||||
@ -141,14 +141,15 @@ class CsRedundant(object):
|
||||
"SndSocketBuffer 1249280\n",
|
||||
"RcvSocketBuffer 1249280\n",
|
||||
"Checksum on\n"])
|
||||
connt.section("Address Ignore {", "}", self._collect_ignore_ips())
|
||||
connt.commit()
|
||||
conntrackd_tmpl.section("Address Ignore {", "}", self._collect_ignore_ips())
|
||||
conntrackd_tmpl.commit()
|
||||
|
||||
conntrackd_conf = CsFile(self.CONNTRACKD_CONF)
|
||||
|
||||
if not connt.compare(conntrackd_conf):
|
||||
CsHelper.copy(conntrackd_template_conf, self.CONNTRACKD_CONF)
|
||||
is_equals = conntrackd_tmpl.compare(conntrackd_conf)
|
||||
proc = CsProcess(['/etc/conntrackd/conntrackd.conf'])
|
||||
if not proc.find() or not is_equals:
|
||||
CsHelper.copy(conntrackd_template_conf, self.CONNTRACKD_CONF)
|
||||
CsHelper.service("conntrackd", "restart")
|
||||
|
||||
# Restore the template file and remove the backup.
|
||||
|
||||
@ -458,26 +458,22 @@ class TestVPCRedundancy(cloudstackTestCase):
|
||||
self.query_routers()
|
||||
self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
|
||||
self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
|
||||
time.sleep(30)
|
||||
self.check_master_status(2)
|
||||
self.add_nat_rules()
|
||||
self.do_vpc_test(False)
|
||||
time.sleep(30)
|
||||
|
||||
self.stop_router_by_type("MASTER")
|
||||
# wait for the backup router to transit to master state
|
||||
time.sleep(30)
|
||||
time.sleep(10)
|
||||
self.check_master_status(1)
|
||||
self.do_vpc_test(False)
|
||||
|
||||
self.delete_nat_rules()
|
||||
time.sleep(45)
|
||||
self.check_master_status(1)
|
||||
self.do_vpc_test(True)
|
||||
|
||||
self.start_routers()
|
||||
self.add_nat_rules()
|
||||
time.sleep(30)
|
||||
self.check_master_status(2)
|
||||
self.do_vpc_test(False)
|
||||
|
||||
@ -488,7 +484,6 @@ class TestVPCRedundancy(cloudstackTestCase):
|
||||
self.query_routers()
|
||||
self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
|
||||
self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
|
||||
time.sleep(30)
|
||||
self.check_master_status(2)
|
||||
self.add_nat_rules()
|
||||
self.do_default_routes_test()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user