snap-ebs 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d2d9b7df8d19e53288b89d957cc9c56d7942d23
4
- data.tar.gz: 07e9374eae9478236ef061a582a050d349015a49
3
+ metadata.gz: c11e7ec18adb6774b2dbf835f003b59e05c7e930
4
+ data.tar.gz: be9abe78f7df0f2c09004d602e99fb179b83e05e
5
5
  SHA512:
6
- metadata.gz: 5f8986b7b2a0be56714219a524d8ef65fa6746b2a78b93fae5350c0e8893fe721a93c24550a10e40b4f9c13a482c02add2bdbd79fab5b0cf4ef4f667a2faefa7
7
- data.tar.gz: c46faf076355911857de4ca88dedf6649ac5ebaf7e54a1df8c961ba8bc341d7ac3c64fc244ac3b7c56ee0150e6cbe20ee5832e7f64b7747318c95319b4dac8f4
6
+ metadata.gz: ff0182e964321e3d7eb3f8cdb40a6e3a515832f19e53e01f293e3431420588b1447df431c852e18a291140dade9dab0fa18f9df2be7071d4071536c44d153550
7
+ data.tar.gz: 8644e526e686edc25461295ffec083bc9941b800925de7abbc3d6bab6d04c2e8b27ad2007ca637e0fc6211d31d2e604d9d7f17e079439756d2ffb23234de40d4
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
- snap-ebsc2-ebs-automatic-consistent-snapshot
1
+ snap-ebs
2
2
  ===
3
3
 
4
- Easier to use than it is to say, this project aims to provide easy, automatic,
5
- and consistent snapshots for AWS EBS volumes on EC2 instances.
4
+ This project aims to provide easy, automatic, and consistent snapshots for AWS
5
+ EBS volumes on EC2 instances.
6
6
 
7
7
  Some specific goals and how they are achieved:
8
8
 
9
9
  - *Safety*: refuses to operate unless everything seems ok, and tries desperately to leave your system no worse than it started
10
- - *Reliability*: comprehensive test sweet makes sure that SnapEbs behaves as expected, even in unexpected conditions.
10
+ - *Reliability*: comprehensive test sweet makes sure that `snap-ebs` behaves as expected, even in unexpected conditions.
11
11
  - *Visibility*: verbose logging options to inspect the decision-making process for any action
12
12
  - *Ease of Installation*: just install the gem and add one line to your crontab
13
13
  - *Ease of Use*: automatically detects volumes mounted to the machine
@@ -30,11 +30,17 @@ sudo yum install gcc \
30
30
  patch \
31
31
  ruby-devel \
32
32
  zlib-devel
33
+
34
+ gem install snap-ebs
35
+ crontab -e
33
36
  ```
34
37
 
38
+ Usage
39
+ ===
40
+
41
+ Put something like this in your root crontab:
35
42
  ```
36
- gem install snap-ebsc2-ebs-automatic-consistent-snapshot
37
- crontab -e
43
+ snap-ebs -a AWSACCESSKEY -s AWSSECRETKEY --directory /data,/log,/journal --mongo --mongo-shutdown yes --logfile /var/log/snap-ebs.log
38
44
  ```
39
45
 
40
46
  Testing
@@ -50,7 +56,7 @@ Like any good Ruby software, this tool has a unit test suite that seeks mostly t
50
56
  Vagrant Integration Testing
51
57
  ---
52
58
 
53
- The integration layer contains an Ansible + Vagrant setup to configure clusters of services for live-fire testing (the AWS bits are mocked out via SnapEbs's `--mock` flag). Simply running `vagrant up` will build a cluster of servers running MySQL, MongoDB, etc, configured in a master/slave architecture as approprite for the given system.
59
+ The integration layer contains an Ansible + Vagrant setup to configure clusters of services for live-fire testing (the AWS bits are mocked out via `snap-ebs`'s `--mock` flag). Simply running `vagrant up` will build a cluster of servers running MySQL, MongoDB, etc, configured in a master/slave architecture as approprite for the given system.
54
60
 
55
- There is also a set of Ansible tasks that verify the operation of each plugin under **both ideal and pathological** conditions. This means that SnapEbs runs reliably, even when the services it operates on do not. Things like timeouts and service restart failures are modeled via `socat`, and assertions are made on the correct error output for each condition. For more info on how this is done, check `roles/integration-test/tasks/*.yml`
61
+ There is also a set of Ansible tasks that verify the operation of each plugin under **both ideal and pathological** conditions. This means that `snap-ebs` runs reliably, even when the services it operates on do not. Things like timeouts and service restart failures are modeled via `socat`, and assertions are made on the correct error output for each condition. For more info on how this is done, check `roles/integration-test/tasks/*.yml`
56
62
 
@@ -4,8 +4,10 @@ class SnapEbs::Plugin::MongoPlugin < SnapEbs::Plugin
4
4
  attr_accessor :client
5
5
  def defined_options
6
6
  {
7
- service: 'Service to start after shutting down server',
8
7
  shutdown: 'Shutdown mongodb server (this is required if your data and journal are on different volumes',
8
+ command: 'Command to start mongodb if the server must be shut down (i.e. multi-volume Wired Tiger)',
9
+ 'retry': 'How many times to retry starting or unlocking mongodb (default: 720)',
10
+ interval: 'Interval (in seconds) to wait when retrying (default: 5)',
9
11
  user: 'Mongo user',
10
12
  password: 'Mongo password',
11
13
  port: 'Mongo port',
@@ -19,9 +21,11 @@ class SnapEbs::Plugin::MongoPlugin < SnapEbs::Plugin
19
21
 
20
22
  def default_options
21
23
  {
22
- service: 'mongodb',
23
- port: '27017',
24
24
  shutdown: false,
25
+ command: "service mongod start",
26
+ 'retry': 720,
27
+ interval: 5,
28
+ port: '27017',
25
29
  host: 'localhost',
26
30
  server_selection_timeout: 30,
27
31
  wait_queue_timeout: 1,
@@ -61,11 +65,7 @@ class SnapEbs::Plugin::MongoPlugin < SnapEbs::Plugin
61
65
  end
62
66
 
63
67
  def after
64
- if wired_tiger?
65
- carefully('start mongo') { start_mongo } if options.shutdown
66
- else
67
- carefully('unlock mongo') { unlock_mongo }
68
- end
68
+ unlock_or_start_mongo
69
69
 
70
70
  if carefully('check that mongo is still accessible') { client.command(serverStatus: 1).first }
71
71
  logger.info "Received status from mongo, everything appears to be ok"
@@ -76,7 +76,19 @@ class SnapEbs::Plugin::MongoPlugin < SnapEbs::Plugin
76
76
  "Mongo"
77
77
  end
78
78
 
79
- private
79
+ def unlock_or_start_mongo
80
+ (options.retry.to_i + 1).times do
81
+ if wired_tiger?
82
+ return if carefully('start mongo') { start_mongo } if options.shutdown
83
+ else
84
+ return if carefully('unlock mongo') { unlock_mongo }
85
+ end
86
+
87
+ # otherwise we failed
88
+ logger.warn "Failed to start MongoDB, retrying in #{options.interval} seconds"
89
+ sleep options.interval.to_i
90
+ end
91
+ end
80
92
 
81
93
  def safe_to_operate?
82
94
  # we check for strict equality with booleans here, because nil means an
@@ -88,7 +100,9 @@ class SnapEbs::Plugin::MongoPlugin < SnapEbs::Plugin
88
100
 
89
101
  def wired_tiger?
90
102
  if @wired_tiger.nil?
91
- @wired_tiger = client.command(serverStatus: 1).first.has_key? WIRED_TIGER_KEY
103
+ @wired_tiger = carefully 'detect mongodb\'s storage engine' do
104
+ client.command(serverStatus: 1).first.has_key? WIRED_TIGER_KEY
105
+ end
92
106
  end
93
107
  @wired_tiger
94
108
  end
@@ -124,8 +138,8 @@ class SnapEbs::Plugin::MongoPlugin < SnapEbs::Plugin
124
138
  end
125
139
 
126
140
  def start_mongo
127
- logger.info "Starting mongodb via 'service #{options[:service]} start'"
128
- system "service #{options[:service]} start"
141
+ logger.info "Starting mongodb via '#{options[:command]}'"
142
+ system options[:command]
129
143
  end
130
144
 
131
145
  def lock_mongo
@@ -38,7 +38,7 @@ class SnapEbs::Plugin
38
38
 
39
39
  def carefully msg
40
40
  yield
41
- rescue Exception => e
41
+ rescue => e
42
42
  logger.error "Error while trying to #{msg}"
43
43
  logger.error e
44
44
  nil
@@ -3,6 +3,8 @@ require 'httparty'
3
3
  module SnapEbs::Snapshotter
4
4
  AWS_INSTANCE_ID_URL = 'http://169.254.169.254/latest/dynamic/instance-identity/document'
5
5
 
6
+ attr_writer :compute
7
+
6
8
  def take_snapshots
7
9
  attached_volumes.collect do |vol|
8
10
  next unless should_snap vol
data/lib/snap_ebs.rb CHANGED
@@ -22,6 +22,10 @@ class SnapEbs
22
22
  @@logger
23
23
  end
24
24
 
25
+ def self.logger= logger_
26
+ @@logger = logger_
27
+ end
28
+
25
29
  def plugins
26
30
  @plugins ||= registered_plugins.collect { |klass| klass.new }
27
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snap-ebs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Conrad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-26 00:00:00.000000000 Z
11
+ date: 2015-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog