Fixes #28076: Pending nodes in LDAP doesn't show up in webapp#6829
Conversation
|
|
||
| object nodeFacts extends RequestVar[MapView[NodeId, CoreNodeFact]](initNodeInfos()(CurrentUser.queryContext)) | ||
| } | ||
|
|
There was a problem hiding this comment.
that doesn't seems usefull anymore. I think it was done because once upon a time, I took a lot of time to query these info. Plus, we wanted to have the same data for the whole page.
But now, it can be done with just a nodeFactRepo.getAll() and pass the result around as a parameter.
| } | ||
|
|
||
| def pendingNodes(html: NodeSeq): NodeSeq = { | ||
| displayCount(() => countPendingNodes(), "pending nodes") |
There was a problem hiding this comment.
we don't need that to be lazily evaluated, because nothing is async nor be evaluated in a ZIO context
| private def countPendingNodes(): Box[Int] = { | ||
| ldap.flatMap(con => con.searchOne(pendingNodesDit.NODES.dn, ALL, "1.1")).map(x => x.size) | ||
| private def countPendingNodes(implicit qc: QueryContext): Box[Int] = { | ||
| nodeFactRepo.getAll()(qc, SelectNodeStatus.Pending).map(_.size) |
There was a problem hiding this comment.
so this is the actual bug correction.
There was a problem hiding this comment.
this would be painful for upmerge, since Scala 3 requires getAll()(using qc, SelectNodeStatus.Pending) (or even getAll(using status = SelectNodeStatus.Pending)) 😅
I don't know if I would prefer defining a new implicit val select: SelectNodeStatus = SelectNodeStatus.pending to avoid that upmerge... (I prefer Scala 3 myself 😸)
clarktsiory
left a comment
There was a problem hiding this comment.
LGTM ! The may be some upmerge with Scala 3 using...
|
This PR is not mergeable to upper versions. |
|
OK, merging this PR |
https://issues.rudder.io/issues/28076
So, the root problem was that we were counting entries in LDAP branch
ou=PendingNodes,..., but that is not correct since we switched toCoreNodeFactRepository: now, a pending node needs to have an entry in bothou=PendingNodes,...andou=Nodes, ...like an accepted node.So we were in the case where these nodes only had half the needed content. I haven't the least idea HOW we get there, but in any case, when we only have something in
ou=Pending Nodes,we should ignore it - which is correctly done byNodeFactRepo.More over, that way of doing things was ignoring tenants, which is not good.
So, the correction is just to replace the compliacte LDAP request by
factRepo.giveMePendingNodes.count(more or less, actual syntaxt is not that).I also cleaned up other bit that were extremely complicated for no apparent reason - some code dating back from 2014, so perhaps it was relevant in that anticated times, but not now with the node fact repos.