Homework 2.1 connection fails while running validation script

Hi,
I’m getting a network error when I try to run the validation .sh file. See traceback below:

exception: connect failed
2018-12-06T06:18:33.192+0000 E QUERY [thread1] Error: network error while attempting to run command 
'isMaster' on host '127.0.0.1:31210' : connect@src/mongo/shell/mongo.js:231:14 @(connect):1:21

TA’s, could you guys assist me?

Fellow students, be warned, SPOILERS BELOW!!! Proceed at your own peril.
Here are the info regarding my repl and user config (both commands were executed in 31210):

MongoDB Enterprise ReplSet:PRIMARY> rs.status()
output
{
	"set" : "ReplSet",
"date" : ISODate("2018-12-06T06:17:19.289Z"),
"myState" : 1,
"term" : NumberLong(6),
"heartbeatIntervalMillis" : NumberLong(2000),
"members" : [
	{
		"_id" : 0,
		"name" : "localhost:31210",
		"health" : 1,
		"state" : 1,
		"stateStr" : "PRIMARY",
		"uptime" : 2085,
		"optime" : {
			"ts" : Timestamp(1544077027, 1),
			"t" : NumberLong(6)
		},
		"optimeDate" : ISODate("2018-12-06T06:17:07Z"),
		"electionTime" : Timestamp(1544075382, 1),
		"electionDate" : ISODate("2018-12-06T05:49:42Z"),
		"configVersion" : 2,
		"self" : true
	},
	{
		"_id" : 1,
		"name" : "localhost:31211",
		"health" : 1,
		"state" : 2,
		"stateStr" : "SECONDARY",
		"uptime" : 1658,
		"optime" : {
			"ts" : Timestamp(1544077027, 1),
			"t" : NumberLong(6)
		},
		"optimeDate" : ISODate("2018-12-06T06:17:07Z"),
		"lastHeartbeat" : ISODate("2018-12-06T06:17:19.286Z"),
		"lastHeartbeatRecv" : ISODate("2018-12-06T06:17:17.377Z"),
		"pingMs" : NumberLong(0),
		"syncingTo" : "localhost:31210",
		"configVersion" : 2
	},
	{
		"_id" : 2,
		"name" : "localhost:31212",
		"health" : 1,
		"state" : 2,
		"stateStr" : "SECONDARY",
		"uptime" : 1644,
		"optime" : {
			"ts" : Timestamp(1544077027, 1),
			"t" : NumberLong(6)
		},
		"optimeDate" : ISODate("2018-12-06T06:17:07Z"),
		"lastHeartbeat" : ISODate("2018-12-06T06:17:17.383Z"),
		"lastHeartbeatRecv" : ISODate("2018-12-06T06:17:18.195Z"),
		"pingMs" : NumberLong(0),
		"syncingTo" : "localhost:31211",
		"configVersion" : 2
	}
],
"ok" : 1
}

MongoDB Enterprise ReplSet:PRIMARY> show users
output
{
	"_id" : "test.userAdmin",
	"user" : "userAdmin",
	"db" : "test",
	"roles" : [
		{
			"role" : "userAdminAnyDatabase",
			"db" : "admin"
		}
	]
}
{
	"_id" : "test.sysAdmin",
	"user" : "sysAdmin",
	"db" : "test",
	"roles" : [
		{
			"role" : "clusterManager",
			"db" : "admin"
		}
	]
}
{
	"_id" : "test.dbAdmin",
	"user" : "dbAdmin",
	"db" : "test",
	"roles" : [
		{
			"role" : "dbAdmin",
			"db" : "admin"
		}
	]
}
{
	"_id" : "test.dataLoader",
	"user" : "dataLoader",
	"db" : "test",
	"roles" : [
		{
			"role" : "readWriteAnyDatabase",
			"db" : "admin"
		}
	]
}

Since in the error message it says that it’s unable to run db.isMaster() on 127.0.0.01:31210, I’ve even tried to start the session informing 127… as host instead of localhost, the same with mongo conn string and also tried to edit the host using rs.conf().
Either way I get the same message.

Am I doing something wrong? I can’t seem to find the issue.

Thanks in advance for the help!

Hi lucasczpnk,

All of these user’s roles should be scoped to the admin database.

Hope that helps,

David

Hey David

Haven’t I scoped them to admin?
Wait, ok, I’d created within test db also.

Removed them from test db, and rechecked users @ admin db, and it seems to check out…

Is there anything still wrong with it @dschupp?

Check output:

MongoDB Enterprise ReplSet:PRIMARY> db.getUsers()
[
{
	"_id" : "admin.userAdmin",
	"user" : "userAdmin",
	"db" : "admin",
	"roles" : [
		{
			"role" : "userAdminAnyDatabase",
			"db" : "admin"
		}
	]
},
{
	"_id" : "admin.sysAdmin",
	"user" : "sysAdmin",
	"db" : "admin",
	"roles" : [
		{
			"role" : "clusterManager",
			"db" : "admin"
		}
	]
},
{
	"_id" : "admin.dbAdmin",
	"user" : "dbAdmin",
	"db" : "admin",
	"roles" : [
		{
			"role" : "dbAdmin",
			"db" : "admin"
		}
	]
},
{
	"_id" : "admin.dataLoader",
	"user" : "dataLoader",
	"db" : "admin",
	"roles" : [
		{
			"role" : "readWriteAnyDatabase",
			"db" : "admin"
		}
	]
}
]

Is there still something missing/wrong?

Is it necessary to inform the resource arg like when creating a role?

Hi lucasczpnk,

Hint: I would review the “can” requirements keeping in mind the scope.

hope that helps,

David

1 Like

Thanks for the hint, I’ll recheck the requirements. :slight_smile:

It was correct, and I still failed this question… :expressionless:

@dschupp How can i check what happened? Is there a specific place in the forum for the course website’s issues or something similar?

Because the output from the detailed answer is the same as it was on my second try (the db.getUsers() from my previous reply was from that, and you can check it there even) but it still counted as incorrect.

Hi lucasczpnk,

I’m sorry you got this one wrong. On your final the submission you change to the correct the role for dbAdmin; however, on this final attempt you also changed the role for userAdmin to an incorrect role.

FYI,

There is a form to report an issue as well as this discussion forum. Also the answer will be posted after the deadline.

Best,

David

reportAnIssue

1 Like