Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #22197: We can accept a node with an existing hostname even if node_accept_duplicated_hostname is false #5284

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -885,15 +885,6 @@ class AcceptHostnameAndIp(
* Only return existing hostname (and so again, we want that to be empty)
*/
private[this] def queryForDuplicateHostname(hostnames: Seq[String]): Box[Unit] = {
def failure(duplicates: Seq[String], name: String) = {
Failure(
"There is already a node with %s %s in database. You can not add it again.".format(
name,
duplicates.mkString("'", "' or '", "'")
)
)
}

val hostnameCriterion = hostnames.toList.map { h =>
CriterionLine(
objectType = objectType,
Expand All @@ -909,13 +900,11 @@ class AcceptHostnameAndIp(
// if not, we don't group them that the duplicate appears in the list
noDuplicatesH <- if (duplicatesH.isEmpty) Full({})
else {
// get the hostname from nodeInfoService
for {
nodesInfo <- nodeInfoService.getNodeInfosSeq(duplicatesH).toBox
hostnames = nodesInfo.map(ni => ni.hostname)
} yield {
failure(hostnames, "Hostname")
}
val startMessage =
if (duplicatesH.size >= 2) "There are already ${duplicatesH.size} nodes" else "There is already a node"
Failure(
s"${startMessage} with hostname '${name}' in Rudder. You can not add it again."
)
}
} yield {}
}
Expand Down
Expand Up @@ -2915,11 +2915,11 @@ object RudderConfigInit {
lazy val newNodeManagerImpl = {
// the sequence of unit process to accept a new inventory
val unitAcceptors = {
acceptHostnameAndIp ::
historizeNodeStateOnChoice ::
updateFactRepoOnChoice ::
acceptNodeAndMachineInNodeOu ::
acceptInventory ::
acceptHostnameAndIp ::
Nil
}

Expand Down