Skip to content

Commit 639bada

Browse files
author
Johan De Wit
committed
cleanup unused code and debug lines
1 parent d70d9f8 commit 639bada

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

lib/puppet/provider/mongodb_replset/mongo.rb

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def master_host(members)
130130
end
131131

132132
def self.replset_properties
133-
Puppet.debug('XXXXXXXXX in replset_properties')
134133
conn_string = conn_string # rubocop:disable Lint/SelfAssignment
135134
begin
136135
output = mongo_command('rs.conf()', conn_string)
@@ -147,7 +146,6 @@ def self.replset_properties
147146
rescue Puppet::ExecutionFailure => e
148147
#if e.message =~ %r{command replSetGetConfig requires authentication} || e.message =~ %r{not authorized on admin to execute command} || e.message =~ %r{no replset config has been received}
149148
if e.message =~ %r{command replSetGetConfig requires authentication} || e.message =~ %r{not authorized on admin to execute command}
150-
Puppet.debug('XXXXXXXXX in replset_properties rescue part')
151149
output = mongo_command('rs.status()', conn_string)
152150
if output['members']
153151
memb = []
@@ -173,21 +171,8 @@ def get_hosts_status(members)
173171
Puppet.debug "Checking replicaset member #{host} ..."
174172
begin
175173
status = rs_status(host)
176-
Puppet.debug('XXXXXXXXXXXXXX should not get here since I dont have a replicaset')
177174
raise Puppet::Error, "Can't configure replicaset #{name}, host #{host} is not supposed to be part of a replicaset." if status.key?('errmsg') && status['errmsg'] == 'not running with --replSet'
178175

179-
# if auth_enabled && status.key?('errmsg')
180-
# Puppet.debug "In auth_enabled && status.key?('errmsg')"
181-
# if status['errmsg'].include?('requires authentication') || status['errmsg'].include?('not authorized on admin') || status['errmsg'].include?('Authentication failed')
182-
# Puppet.debug "In auth_enabled && status.key?('errmsg') need authentication"
183-
# Puppet.warning "Host #{host} is available, but you are unauthorized because of authentication is enabled: #{auth_enabled}"
184-
# alive.push(member)
185-
# elsif status['errmsg'].include?('no replset config has been received')
186-
# Puppet.debug 'Mongo rs.status() RS not initialized output'
187-
# alive.push(member)
188-
# end
189-
# end
190-
191176
if status.key?('set')
192177
raise Puppet::Error, "Can't configure replicaset #{name}, host #{host} is already part of another replicaset." if status['set'] != name
193178

@@ -199,7 +184,6 @@ def get_hosts_status(members)
199184
alive.push(member)
200185
end
201186
rescue Puppet::ExecutionFailure => e
202-
Puppet.debug('XXXXXXXXXXXX in rescue checking connection mebers')
203187
if auth_enabled
204188
case e.message
205189
when %r{no replset config has been received}
@@ -425,17 +409,10 @@ def mongo_command(command, host, retries = 4)
425409
end
426410

427411
def self.mongo_command(command, host = nil, retries = 4)
428-
#begin
429-
output = mongo_eval("EJSON.stringify(#{command})", 'admin', retries, host)
430-
#rescue Puppet::ExecutionFailure => e
431-
#if e.message =~ %r{no replset config has been received} || e.message =~ %r{Authentication failed}
432-
if output =~ %r{no replset config has been received} || output =~ %r{Authentication failed}
433-
output = '{}'
434-
# else
435-
# Puppet.debug "Got an exception: #{e}"
436-
# raise
437-
end
438-
#end
412+
output = mongo_eval("EJSON.stringify(#{command})", 'admin', retries, host)
413+
if output =~ %r{no replset config has been received} || output =~ %r{Authentication failed}
414+
output = '{}'
415+
end
439416

440417
# Hack to avoid non-json empty sets
441418
output = '{}' if output == "null\n"

lib/puppet/provider/mongodb_user/mongodb.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ def self.instances
1919

2020
users = JSON.parse out
2121

22-
Puppet.debug("XXXXXXXX In self.instances, retrieved users: #{users}")
23-
2422
users.map do |user|
2523
db = if user['db'] == '$external'
2624
# For external users, we need to retreive the original DB name from here.
@@ -44,7 +42,6 @@ def self.instances
4442

4543
# Assign prefetched users based on username and database, not on id and name
4644
def self.prefetch(resources)
47-
Puppet.debug("XXXXXXXXXXX in prefetch: got following instances: #{instances}")
4845
users = instances
4946
resources.each do |name, resource|
5047
provider = users.find { |user| user.username == resource[:username] && user.database == resource[:database] }
@@ -84,10 +81,8 @@ def create
8481
end
8582

8683
if @resource[:auth_mechanism] == :x509
87-
Puppet.debug("XXXXXXXXXX about to create X509 user with command: #{command}")
8884
mongo_eval("db.getSiblingDB(\"$external\").runCommand(#{command.to_json})", @resource[:database])
8985
else
90-
Puppet.debug("XXXXXXXXXX about to create regular user with command: #{command}")
9186
mongo_eval("db.runCommand(#{command.to_json})", @resource[:database])
9287
end
9388
else

0 commit comments

Comments
 (0)