You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Needed changes:
- Use stderr for errors instead of stdout. The `mongo` command from
the older client package put its errors on stout and exited with
zero as exit code. Mongosh, by contrast, puts errors on stderr
instead of stdout and exits with a non-zero exit code.
This means we need to pass the underlying exception to the caller so
it can deal with it appropriately.
- Replace old functions:
- `printjson` has become `EJSON.stringify`.
- `rs.secondaryOk()` and `rs.slaveOk()` have become
`db.getMongo().setReadPref("primaryPreferred")`.
- `db` is now an object instead of the database name, we need to call
`getName()` on it to get the database name.
- Don't throw an exception from the `if (authRequired()) {` block, as
that causes the `mongosh` command to stop processing further
commands and exit with a non-zero exit code.
Puppet.debug"Checking replicaset member #{host} ..."
156
-
status=rs_status(host)
157
-
raisePuppet::Error,"Can't configure replicaset #{name}, host #{host} is not supposed to be part of a replicaset."ifstatus.key?('errmsg') && status['errmsg'] == 'not running with --replSet'
Puppet.warning"Host #{host} is available, but you are unauthorized because of authentication is enabled: #{auth_enabled}"
161
-
alive.push(member)
162
-
end
163
-
164
-
ifstatus.key?('errmsg') && status['errmsg'].include?('no replset config has been received')
165
-
Puppet.debug'Mongo v4 rs.status() RS not initialized output'
166
-
alive.push(member)
167
-
end
168
-
169
-
ifstatus.key?('set')
170
-
raisePuppet::Error,"Can't configure replicaset #{name}, host #{host} is already part of another replicaset."ifstatus['set'] != name
171
-
172
-
# This node is alive and supposed to be a member of our set
173
-
Puppet.debug"Host #{host} is available for replset #{status['set']}"
174
-
alive.push(member)
175
-
elsifstatus.key?('info')
176
-
Puppet.debug"Host #{host} is alive but unconfigured: #{status['info']}"
177
-
alive.push(member)
156
+
begin
157
+
status=rs_status(host)
158
+
159
+
ifstatus.key?('set')
160
+
raisePuppet::Error,"Can't configure replicaset #{name}, host #{host} is already part of another replicaset."ifstatus['set'] != name
161
+
162
+
# This node is alive and supposed to be a member of our set
163
+
Puppet.debug"Host #{host} is available for replset #{status['set']}"
164
+
alive.push(member)
165
+
elsifstatus.key?('info')
166
+
Puppet.debug"Host #{host} is alive but unconfigured: #{status['info']}"
167
+
alive.push(member)
168
+
end
169
+
rescuePuppet::ExecutionFailure=>e
170
+
raisePuppet::Error,"Can't configure replicaset #{name}, host #{host} is not supposed to be part of a replicaset."ife.message =~ %r{not running with --replSet}
0 commit comments