ec2-rotate-volume-snapshots 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -64,7 +64,7 @@ end
64
64
  volume_ids = ARGV
65
65
 
66
66
  ec2 = RightAws::Ec2.new(opts[:aws_access_key], opts[:aws_secret_access_key], :region => opts[:aws_region])
67
- all_snapshots = ec2.describe_snapshots
67
+ all_snapshots = ec2.describe_snapshots(:filters => { 'volume-id' => volume_ids })
68
68
 
69
69
  volume_ids.each do |volume_id|
70
70
  if volume_id !~ /^vol-/
@@ -73,6 +73,9 @@ volume_ids.each do |volume_id|
73
73
  exit 1
74
74
  end
75
75
 
76
+ # keep track of how many deletes we've done per throttle
77
+ deletes = 0
78
+
76
79
  # poor man's way to get a deep copy of our time_periods definition hash
77
80
  periods = Marshal.load(Marshal.dump(time_periods))
78
81
 
@@ -114,6 +117,18 @@ volume_ids.each do |volume_id|
114
117
  else
115
118
  puts " #{time.strftime '%Y-%m-%d %H:%M:%S'} #{snapshot_id} Deleting"
116
119
  ec2.delete_snapshot(snapshot_id) unless opts[:dry_run]
120
+
121
+ # Hardcore rigorous testing has shown that sleeping 5 seconds after 50 deletes
122
+ # keeps the RequestLimitExceeded error away in 2 out of 2 trials, while sleeping
123
+ # 1 second was insufficient.
124
+ # There doesn't seem to be any published numbers for what the limit actually is,
125
+ # and there does seem to be plenty of implications that it depends on your account,
126
+ # the AWS service, and possibly phases of the moon and AWS's internal activities.
127
+ deletes = deletes + 1
128
+ if deletes > 50
129
+ deletes = 0
130
+ sleep 5
131
+ end
117
132
  end
118
133
  end
119
134
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ec2-rotate-volume-snapshots}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Zach Wily"]
12
- s.date = %q{2011-08-23}
12
+ s.date = %q{2012-06-26}
13
13
  s.default_executable = %q{ec2-rotate-volume-snapshots}
14
14
  s.description = %q{Provides a simple way to rotate EC2 snapshots with configurable retention periods.}
15
15
  s.email = %q{zach@zwily.com}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2-rotate-volume-snapshots
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Zach Wily
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-23 00:00:00 -06:00
18
+ date: 2012-06-26 00:00:00 -07:00
19
19
  default_executable: ec2-rotate-volume-snapshots
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency