File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
systemvm/debian/opt/cloud/bin/cs Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,11 @@ def process(self):
5151 file1 .commit ()
5252 file2 = CsFile (HAPROXY_CONF_P )
5353 if not file2 .compareOrder (file1 ):
54+ # Verify new haproxy config before haproxy restart/reload
55+ haproxy_err = self ._verify_haproxy_config (HAPROXY_CONF_T )
56+ if haproxy_err :
57+ raise Exception ("haproxy config is invalid with error \n %s" % haproxy_err );
58+
5459 CsHelper .copy (HAPROXY_CONF_T , HAPROXY_CONF_P )
5560
5661 proc = CsProcess (['/run/haproxy.pid' ])
@@ -131,3 +136,11 @@ def _create_pem_for_sslcert(self, ssl_certs):
131136 for f in listdir (SSL_CERTS_DIR ):
132137 if f not in cert_names :
133138 CsHelper .execute ("rm -rf %s/%s" % (SSL_CERTS_DIR , f ))
139+
140+ def _verify_haproxy_config (self , config ):
141+ ret = CsHelper .execute2 ("haproxy -c -f %s" % config )
142+ if ret .returncode :
143+ stdout , stderr = ret .communicate ()
144+ logging .error ("haproxy config is invalid with error: %s" % stderr )
145+ return stderr
146+ return ""
You can’t perform that action at this time.
0 commit comments