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 +4 -4
- data/README.md +14 -8
- data/lib/plugins/mongo_plugin.rb +26 -12
- data/lib/snap_ebs/plugin.rb +1 -1
- data/lib/snap_ebs/snapshotter.rb +2 -0
- data/lib/snap_ebs.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c11e7ec18adb6774b2dbf835f003b59e05c7e930
|
4
|
+
data.tar.gz: be9abe78f7df0f2c09004d602e99fb179b83e05e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff0182e964321e3d7eb3f8cdb40a6e3a515832f19e53e01f293e3431420588b1447df431c852e18a291140dade9dab0fa18f9df2be7071d4071536c44d153550
|
7
|
+
data.tar.gz: 8644e526e686edc25461295ffec083bc9941b800925de7abbc3d6bab6d04c2e8b27ad2007ca637e0fc6211d31d2e604d9d7f17e079439756d2ffb23234de40d4
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
snap-
|
1
|
+
snap-ebs
|
2
2
|
===
|
3
3
|
|
4
|
-
|
5
|
-
|
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
|
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
|
-
|
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
|
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
|
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
|
|
data/lib/plugins/mongo_plugin.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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 =
|
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 '
|
128
|
-
system
|
141
|
+
logger.info "Starting mongodb via '#{options[:command]}'"
|
142
|
+
system options[:command]
|
129
143
|
end
|
130
144
|
|
131
145
|
def lock_mongo
|
data/lib/snap_ebs/plugin.rb
CHANGED
data/lib/snap_ebs/snapshotter.rb
CHANGED
data/lib/snap_ebs.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog
|