Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,9 @@ export class StorageNodeSelector implements StorageNodeSelectorService {
this.selectedNode = selectedNode
this.logger.info('Selected content node', this.selectedNode)
} else {
// No healthy nodes found. Fall back to a random node
this.selectedNode = this.getRandomNode()
this.logger.warn(
'No healthy nodes found. Falling back to random node:',
this.selectedNode
)
// No healthy nodes found
this.selectedNode = null
this.logger.warn('No healthy nodes found')
this.selectionState = 'failed_all'
}

Expand Down Expand Up @@ -130,17 +127,6 @@ export class StorageNodeSelector implements StorageNodeSelectorService {
return selectedNode
}

private getRandomNode(): string | null {
if (!this.orderedNodes?.length) {
this.orderedNodes = this.orderNodes(new Date().toString())
}
if (this.orderedNodes.length === 0) {
return null
}
const randomIndex = Math.floor(Math.random() * this.orderedNodes.length)
return this.orderedNodes[randomIndex] ?? null
}

private orderNodes(key: string) {
const endpoints = this.nodes.map((node) => node.endpoint.toLowerCase())
const hash = new RendezvousHash(...endpoints)
Expand Down