Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #876 from josefkarasek/bz-1524644
Automatic merge from submit-queue.

bug 1524644. Curator configuration produces wrong regular expressions

For example `^.operations.` instead of `^\.operations\..*$`
Both regexes match, but the first one only accidentaly. Example index name:
`.operations.1827ac8a-ef8f-11e7-92de-0ebdd5807cb2.2018.01.02`

Curator code: https://github.com/elastic/curator/blob/3.5/curator/api/filter.py#L90-L138

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1524644
  • Loading branch information
openshift-merge-robot committed Jan 2, 2018
2 parents 7e58f32 + 9476cab commit 5ae3d1f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions curator/run_cron.py
Expand Up @@ -100,7 +100,11 @@
default_value = default_value * 7

base_default_cmd = '/usr/bin/curator --loglevel ' + curlvl + ' ' + connection_info + ' delete indices --timestring %Y.%m.%d'
default_command = base_default_cmd + ' --older-than ' + str(default_value) + ' --time-unit ' + default_time_unit + ' --exclude .searchguard* --exclude .kibana*'
default_command = base_default_cmd \
+ ' --older-than ' + str(default_value) \
+ ' --time-unit ' + default_time_unit \
+ ' --exclude ' + shellquote('^' + re.escape('.searchguard.') + '.*$') \
+ ' --exclude ' + shellquote('^' + re.escape('.kibana.') + '.*$')

proj_prefix = 'project.'

Expand All @@ -113,8 +117,6 @@
value = int(decoded[project][operation][unit])

if unit in allowed_units:
default_command = default_command + " --exclude " + shellquote(re.escape(project + '.') + '*')

if unit.lower() == "weeks":
unit = "days"
value = value * 7
Expand All @@ -123,6 +125,8 @@
this_project = project
else:
this_project = proj_prefix + project
default_command = default_command \
+ " --exclude " + shellquote('^' + re.escape(this_project + '.') + '.*$')
curator_settings[operation].setdefault(unit, {}).setdefault(value, []).append(this_project)
logger.debug('Using [%s] [%d] for [%s]' % (unit, value, this_project))
else:
Expand All @@ -148,7 +152,7 @@
' --older-than ' + str(value) + ' --time-unit ' + unit + \
' --regex ' + \
shellquote('(' + '|'.join(map(
lambda project:'^' + re.escape(project + '.'),
lambda project:'^' + re.escape(project + '.') + '.*$',
curator_settings[operation][unit][value])) + ')')
job = my_cron.new(command=tab_cmd, comment='Generated job based on settings')
job.every().day()
Expand Down

0 comments on commit 5ae3d1f

Please sign in to comment.