Hi!  Sorry you've had a snag with this. This is a good catch!  Thanks for 
finding this.

The problem is in filter_by_timestamp:

    dateregex = get_date_regex(timestring)
    if object_type == 'index':
        regex = "^" + prefix + "(" + dateregex + ")" + suffix + "$"
    elif object_type == 'snapshot':
        regex = "(" + "^" + snapshot_prefix + '.*' + ")"

It should look like:

    if object_type == 'index':
        dateregex = get_date_regex(timestring)
        regex = "^" + prefix + "(" + dateregex + ")" + suffix + "$"
    elif object_type == 'snapshot':
        regex = "(" + "^" + snapshot_prefix + '.*' + ")"

Would you issue a pull request for this change?

--Aaron

On Friday, November 21, 2014 9:40:33 AM UTC-7, Matt Hughes wrote:
>
> Sorry, the subject was a little misleading.
>
> Really the problem is just with this call:
>
> curator.snapshot(client, all_indices=True, repository=repo_name, 
> delete_older_than=10, time_unit="days")
>
> Traceback (most recent call last):
>   File "./test.py", line 12, in <module>
>     curator.snapshot(client, all_indices=True, repository=repo_name, 
> delete_older_than=10, time_unit="days")
>   File "/usr/lib/python2.6/site-packages/curator/curator.py", line 1092, 
> in snapshot
>     matching_snapshots = list(filter_by_timestamp(object_list=
> snapshot_list, object_type='snapshot', **kwargs))
>   File "/usr/lib/python2.6/site-packages/curator/curator.py", line 354, in 
> filter_by_timestamp
>     dateregex = get_date_regex(timestring)
>   File "/usr/lib/python2.6/site-packages/curator/curator.py", line 32, in 
> get_date_regex
>     for s in range(0, len(timestring)):
> TypeError: object of type 'NoneType' has no len()
>
>
> However, using the exact same parameters with curator command line work 
> fine:
>
> bash-4.1# curator snapshot --delete-older-than 10 --repository test
> 2014-11-21 16:38:32,949 INFO      Job starting...
> 2014-11-21 16:38:32,953 INFO      Deleting specified snapshots...
> 2014-11-21 16:38:32,958 INFO      curator-20141121155804 is within the 
> threshold period (10 days).
> 2014-11-21 16:38:32,958 INFO      curator-20141121155806 is within the 
> threshold period (10 days).
> 2014-11-21 16:38:32,958 INFO      curator-20141121160217 is within the 
> threshold period (10 days).
> 2014-11-21 16:38:32,958 INFO      curator-20141121160242 is within the 
> threshold period (10 days).
> 2014-11-21 16:38:32,958 INFO      curator-20141121160426 is within the 
> threshold period (10 days).
> 2014-11-21 16:38:32,958 INFO      curator-20141121160724 is within the 
> threshold period (10 days).
> 2014-11-21 16:38:32,959 INFO      curator-20141121160846 is within the 
> threshold period (10 days).
> 2014-11-21 16:38:32,959 INFO      Specified snapshots deleted.
> 2014-11-21 16:38:32,959 INFO      Done in 0:00:00.016456.
>
>
>
> On Friday, November 21, 2014 11:09:46 AM UTC-5, Matt Hughes wrote:
>>
>> Trying to use the curator API.  I want to do a backup of all my indices 
>> and only if the snapshot backup is successful, trim any snapshots older 
>> than 5 days.
>>
>> First part is simple enough, but I don't see any return for 
>> create_snapshot:
>>
>> bash-4.1# cat test.py
>> #!/usr/bin/env python
>>
>> import elasticsearch
>> import curator
>>
>> repo_name = 'test'
>> client = elasticsearch.Elasticsearch(host="localhost", port=9200, timeout
>> =21600)
>> backup_status = curator.create_snapshot(client, repository=repo_name)
>> print(backup_status)
>> if backup_status == None:
>>     print("Trimming snapshots older than 10 days.")
>>     curator.snapshot(client, all_indices=True, repository=repo_name, 
>> delete_older_than=10, time_unit="days")
>> else:
>>     print("Backup failed: Not trimming snapshots.")
>>
>>
>> bash-4.1# ./test.py
>> None
>> Trimming snapshots older than 10 days.
>> Traceback (most recent call last):
>>   File "./test.py", line 12, in <module>
>>     curator.snapshot(client, all_indices=True, repository=repo_name, 
>> delete_older_than=10, time_unit="days")
>>   File "/usr/lib/python2.6/site-packages/curator/curator.py", line 1092, 
>> in snapshot
>>     matching_snapshots = list(filter_by_timestamp(object_list=
>> snapshot_list, object_type='snapshot', **kwargs))
>>   File "/usr/lib/python2.6/site-packages/curator/curator.py", line 354, 
>> in filter_by_timestamp
>>     dateregex = get_date_regex(timestring)
>>   File "/usr/lib/python2.6/site-packages/curator/curator.py", line 32, in 
>> get_date_regex
>>     for s in range(0, len(timestring)):
>> TypeError: object of type 'NoneType' has no len()
>>
>> This is using version 2.0.2.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/a778cc34-45fb-4528-82d9-80363bc0c2b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to