Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Address bug in config validation for invalid labels (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
drewkerrigan authored Apr 25, 2018
1 parent 49afb4d commit 4d88b1f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions marathon_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,10 @@ def writeConfigAndValidate(
moveTempFile(haproxyTempConfigFile, config_file, "hap_cfg")
return True
else:
moveTempFile(haproxyTempConfigFile, 'haproxy_tmp_conf_fail',
'haproxy_temp_config_fail')
removeTempFileIfExist(domain_temp_map_file)
removeTempFileIfExist(app_temp_map_file)
return False


Expand Down Expand Up @@ -1305,6 +1309,12 @@ def truncateMapFileIfExists(map_file):
os.close(fd)


def removeTempFileIfExist(temp_file):
if os.path.isfile(temp_file):
logger.debug("delete tempfile %s", temp_file)
os.remove(temp_file)


def generateAndValidateTempConfig(config, config_file, domain_map_array,
app_map_array, haproxy_map):
temp_config_file = "%s.tmp" % config_file
Expand Down Expand Up @@ -1720,13 +1730,12 @@ def make_config_valid_and_regenerate(marathon,
generated_config = config(apps, groups, bind_http_https,
ssl_certs, templater, haproxy_map,
domain_map_array, app_map_array,
config_file)
config_file, group_https_by_vhost)
config_valid = generateAndValidateTempConfig(generated_config,
config_file,
domain_map_array,
app_map_array,
haproxy_map,
group_https_by_vhost)
haproxy_map)
if not config_valid:
logger.warn(
"invalid configuration caused by app %s; "
Expand All @@ -1745,7 +1754,7 @@ def make_config_valid_and_regenerate(marathon,
valid_config = config(apps, groups, bind_http_https,
ssl_certs, templater, haproxy_map,
domain_map_array, app_map_array,
config_file)
config_file, group_https_by_vhost)
compareWriteAndReloadConfig(valid_config,
config_file,
domain_map_array,
Expand Down

0 comments on commit 4d88b1f

Please sign in to comment.