Skip to content

Commit

Permalink
disable configuration cleanup on failed validation (d2iq-archive#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
squaredsquid authored and jkoelker committed Mar 21, 2019
1 parent 0b5eaa6 commit ebcbfcb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Longhelp.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ usage: marathon_lb.py [-h] [--longhelp] [--marathon MARATHON [MARATHON ...]]
[--lru-cache-capacity LRU_CACHE_CAPACITY]
[--haproxy-map] [--dont-bind-http-https]
[--group-https-by-vhost] [--ssl-certs SSL_CERTS]
[--skip-validation] [--dry]
[--skip-validation] [--skip-config-cleanup] [--dry]
[--min-serv-port-ip-per-task MIN_SERV_PORT_IP_PER_TASK]
[--max-serv-port-ip-per-task MAX_SERV_PORT_IP_PER_TASK]
[--syslog-socket SYSLOG_SOCKET]
Expand Down Expand Up @@ -88,6 +88,9 @@ optional arguments:
/etc/ssl/site1.co.pem,/etc/ssl/site2.co.pem (default:
/etc/ssl/cert.pem)
--skip-validation Skip haproxy config file validation (default: False)
--skip-config-cleanup
If one app fails, don't try to make configuration
valid by removing apps one by one (default: False)
--dry, -d Only print configuration to console (default: False)
--min-serv-port-ip-per-task MIN_SERV_PORT_IP_PER_TASK
Minimum port number to use when auto-assigning service
Expand Down
9 changes: 8 additions & 1 deletion marathon_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ def get_apps(marathon, apps=[]):
# to a deployment group.
processed_apps = []
deployment_groups = {}

for app in apps:
deployment_group = None
if 'HAPROXY_DEPLOYMENT_GROUP' in app['labels']:
Expand Down Expand Up @@ -1785,7 +1786,8 @@ def regenerate_config(marathon, config_file, groups, bind_http_https,
(changed, config_valid) = compareWriteAndReloadConfig(
generated_config, config_file, domain_map_array, app_map_array,
haproxy_map)
if changed and not config_valid:

if changed and not config_valid and not args.skip_config_cleanup:
apps = make_config_valid_and_regenerate(marathon,
raw_apps,
groups,
Expand All @@ -1797,6 +1799,7 @@ def regenerate_config(marathon, config_file, groups, bind_http_https,
app_map_array,
config_file,
group_https_by_vhost)

return apps


Expand Down Expand Up @@ -2082,6 +2085,10 @@ def get_arg_parser():
parser.add_argument("--skip-validation",
help="Skip haproxy config file validation",
action="store_true")
parser.add_argument("--skip-config-cleanup",
help="If one app fails, don't try to make "
"configuration valid by removing apps one by one",
action="store_true")
parser.add_argument("--dry", "-d",
help="Only print configuration to console",
action="store_true")
Expand Down

0 comments on commit ebcbfcb

Please sign in to comment.