more logging
parent
7169a158e3
commit
9785ec85b4
|
@ -420,8 +420,10 @@ func (self *HttpServer) createDatabase(w libhttp.ResponseWriter, r *libhttp.Requ
|
|||
}
|
||||
err = self.coordinator.CreateDatabase(user, createRequest.Name, createRequest.ReplicationFactor)
|
||||
if err != nil {
|
||||
log.Error("Cannot create database %s. Error: %s", createRequest.Name, err)
|
||||
return errorToStatusCode(err), err.Error()
|
||||
}
|
||||
log.Debug("Created database %s with replication factor %d", createRequest.Name, createRequest.ReplicationFactor)
|
||||
return libhttp.StatusCreated, nil
|
||||
})
|
||||
}
|
||||
|
@ -790,11 +792,18 @@ func (self *HttpServer) createDbUser(w libhttp.ResponseWriter, r *libhttp.Reques
|
|||
self.tryAsDbUserAndClusterAdmin(w, r, func(u common.User) (int, interface{}) {
|
||||
username := newUser.Name
|
||||
if err := self.userManager.CreateDbUser(u, db, username); err != nil {
|
||||
log.Error("Cannot create user: %s", err)
|
||||
return errorToStatusCode(err), err.Error()
|
||||
}
|
||||
log.Debug("Created user %s", username)
|
||||
if err := self.userManager.ChangeDbUserPassword(u, db, username, newUser.Password); err != nil {
|
||||
return libhttp.StatusUnauthorized, err.Error()
|
||||
log.Error("Cannot change user password: %s", err)
|
||||
// there is probably something wrong if we could create
|
||||
// the user but not change the password. so return
|
||||
// 500
|
||||
return libhttp.StatusInternalServerError, err.Error()
|
||||
}
|
||||
log.Debug("Successfully changed %s password", username)
|
||||
return libhttp.StatusOK, nil
|
||||
})
|
||||
}
|
||||
|
|
|
@ -601,6 +601,7 @@ func (self *CoordinatorImpl) DropDatabase(user common.User, db string) error {
|
|||
}
|
||||
|
||||
func (self *CoordinatorImpl) AuthenticateDbUser(db, username, password string) (common.User, error) {
|
||||
log.Debug("(raft:%s) Authenticating password for %s;%s", self.raftServer.(*RaftServer).raftServer.Name(), db, username)
|
||||
dbUsers := self.clusterConfiguration.dbUsers[db]
|
||||
if dbUsers == nil || dbUsers[username] == nil {
|
||||
return nil, common.NewAuthorizationError("Invalid username/password")
|
||||
|
@ -722,7 +723,11 @@ func (self *CoordinatorImpl) ChangeDbUserPassword(requester common.User, db, use
|
|||
}
|
||||
|
||||
dbUsers := self.clusterConfiguration.dbUsers[db]
|
||||
if dbUsers == nil || dbUsers[username] == nil {
|
||||
if dbUsers == nil {
|
||||
return fmt.Errorf("Invalid database name %s", db)
|
||||
}
|
||||
|
||||
if dbUsers[username] == nil {
|
||||
return fmt.Errorf("Invalid username %s", username)
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ func (s *RaftServer) startRaft(potentialLeaders []string, retryUntilJoin bool) {
|
|||
for {
|
||||
joined := false
|
||||
for _, leader := range potentialLeaders {
|
||||
log.Info("(raft:%d) Attempting to join leader: %s", s.port, leader)
|
||||
log.Info("(raft:%s) Attempting to join leader: %s", s.raftServer.Name(), leader)
|
||||
|
||||
if err := s.Join(leader); err == nil {
|
||||
joined = true
|
||||
|
@ -413,7 +413,7 @@ func (s *RaftServer) processCommandHandler(w http.ResponseWriter, req *http.Requ
|
|||
command = &AddPotentialServerCommand{}
|
||||
}
|
||||
if result, err := s.marshalAndDoCommandFromBody(command, req); err != nil {
|
||||
log.Error("ERROR processCommandHanlder: %s", err)
|
||||
log.Error("command %T failed: %s", command, err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
} else {
|
||||
if result != nil {
|
||||
|
|
Loading…
Reference in New Issue