mongolly 0.2.7 → 0.2.8

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: d73eae25653648079e0557d07b6ba9952b45d302
4
- data.tar.gz: f0f56ea2f3a5f3fa4f7ea7654658453e085c0d05
3
+ metadata.gz: ac849aa6e734e18e7d3c76cedd59595b36dda1ba
4
+ data.tar.gz: 884b04ec2321d46e84aac06efdccdcf3da776917
5
5
  SHA512:
6
- metadata.gz: 2f9c420e393587cb3ca3894175112437834625af3bd308ab96bf50e79ed116a6931a87cb601a17b9915a60666cb505aae80c4e63c24fb3e825f1d910c29f83dc
7
- data.tar.gz: 7d382fce218c64c7917c52257a58f66e88828956d95b63cb6e3cafbe1fa3a980a9209dae44ff83de925692c8529c8be13a468ec1bf6f95b1a7add2c18bb80c55
6
+ metadata.gz: ebae305017011d239b7c3fd333c453a3bed1026a472ae07f9ed4c005e449995ceb3ebe2210fcf8b79df0a91d64600c15e0136cd418b2ca0eea12773fb25049d5
7
+ data.tar.gz: 4392b563a59dbcacafc9de3669cb90314392029e4e26810f94a6694dbbbeb2667c0d56a9f1b5fd35328de4e09a8dd954b795f720e053a90a307610680726efa7
@@ -9,7 +9,6 @@ class Mongo::MongoClient
9
9
  REPLICA_SNAPSHOT_PREFER_HIDDEN = true
10
10
 
11
11
  def snapshot_ebs(options={})
12
-
13
12
  @mongolly_dry_run = options[:dry_run] || false
14
13
  @mongolly_logger = options[:logger] || Logger.new(STDOUT)
15
14
  options[:volume_tag] ||= 'mongolly'
@@ -20,17 +19,14 @@ class Mongo::MongoClient
20
19
  if mongos?
21
20
  @mongolly_logger.info("Detected sharded cluster")
22
21
  with_disabled_balancing do
23
- # Stop Config Server
24
- ssh_command(options[:config_server_ssh_user], config_server, options[:mongo_stop_command], options[:config_server_ssh_keypath])
25
-
26
- backup_instance(config_server, options, false)
22
+ with_config_server_stopped(options) do
23
+ backup_instance(config_server, options, false)
27
24
 
28
- shards.each do |name,hosts|
29
- @mongolly_logger.debug("Found Shard #{name} with hosts #{hosts}.")
30
- replica_set_connection(hosts, options).snapshot_ebs(options)
25
+ shards.each do |name,hosts|
26
+ @mongolly_logger.debug("Found Shard #{name} with hosts #{hosts}.")
27
+ replica_set_connection(hosts, options).snapshot_ebs(options)
28
+ end
31
29
  end
32
- # Start Config Server
33
- ssh_command(options[:config_server_ssh_user], config_server, options[:mongo_start_command], options[:config_server_ssh_keypath])
34
30
  end
35
31
  else
36
32
  backup_instance(snapshot_ebs_target(REPLICA_SNAPSHOT_THRESHOLD, REPLICA_SNAPSHOT_PREFER_HIDDEN), options, false )
@@ -102,6 +98,19 @@ protected
102
98
  return @config_server
103
99
  end
104
100
 
101
+ def with_config_server_stopped(options={})
102
+ begin
103
+ # Stop Config Server
104
+ ssh_command(options[:config_server_ssh_user], config_server, options[:mongo_stop_command], options[:config_server_ssh_keypath])
105
+ yield
106
+ rescue => ex
107
+ @mongolly_logger.error "Error with config server stopped: #{ex.to_s}"
108
+ ensure
109
+ # Start Config Server
110
+ ssh_command(options[:config_server_ssh_user], config_server, options[:mongo_start_command], options[:config_server_ssh_keypath])
111
+ end
112
+ end
113
+
105
114
  def with_disabled_balancing
106
115
  begin
107
116
  disable_balancing
@@ -115,6 +124,8 @@ protected
115
124
  end
116
125
  @mongolly_logger.debug "With shard balancing disabled..."
117
126
  yield
127
+ rescue => ex
128
+ @mongolly_logger.error "Error with disabled balancer: #{ex.to_s}"
118
129
  ensure
119
130
  enable_balancing
120
131
  end
@@ -127,6 +138,8 @@ protected
127
138
  lock! unless @mongolly_dry_run || locked?
128
139
  @mongolly_logger.debug "With database locked..."
129
140
  yield
141
+ rescue => ex
142
+ @mongolly_logger.error "Error with database locked: #{ex.to_s}"
130
143
  ensure
131
144
  @mongolly_logger.debug "Unlocking database..."
132
145
  unlock! if !@mongolly_dry_run && locked?
@@ -182,7 +195,7 @@ protected
182
195
 
183
196
  def replica_set_connection(hosts, options)
184
197
  db = Mongo::MongoReplicaSetClient.new(hosts)
185
- db['admin'].authenticate(options[:db_username], options[:db_password], true)
198
+ db['admin'].authenticate(options[:db_username], options[:db_password])
186
199
  return db
187
200
  end
188
201
 
@@ -54,7 +54,7 @@ module Mongolly
54
54
  @logger.debug "connecting to a single instance #{@database}"
55
55
  Mongo::MongoClient.new(*@database.split(':'))
56
56
  end
57
- db['admin'].authenticate(@db_username, @db_password, true)
57
+ db['admin'].authenticate(@db_username, @db_password)
58
58
  return db
59
59
  end
60
60
  end
@@ -1,3 +1,3 @@
1
1
  module Mongolly
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongolly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Saffitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-15 00:00:00.000000000 Z
11
+ date: 2015-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor