Skip to content

Commit 4fac32b

Browse files
committed
[ws-manager-bridge] Fix login/metrics errors
1 parent ce4b8cf commit 4fac32b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

components/ws-manager-bridge/src/bridge-controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class BridgeController {
6161
protected async reconcile() {
6262
return this.reconcileQueue.enqueue(async () => {
6363
const allClusters = await this.getAllWorkspaceClusters();
64-
log.info("reconciling clusters...", { allClusters });
64+
log.info("reconciling clusters...", { allClusters: Array.from(allClusters.values()) });
6565
const toDelete: string[] = [];
6666
try {
6767
for (const [name, bridge] of this.bridges) {
@@ -81,13 +81,13 @@ export class BridgeController {
8181
}
8282
}
8383

84-
this.metrics.updateClusterMetrics(Array.from(allClusters).map(c => c[1]));
84+
this.metrics.updateClusterMetrics(Array.from(allClusters).map(([_, c]) => c));
8585
for (const [name, newCluster] of allClusters) {
8686
log.debug("reconcile: create bridge for new cluster", { name });
8787
const bridge = await this.createAndStartBridge(newCluster);
8888
this.bridges.set(newCluster.name, bridge);
8989
}
90-
log.info("done reconciling.", { allClusters });
90+
log.info("done reconciling.", { allClusters: Array.from(allClusters.values()) });
9191
});
9292
}
9393

components/ws-manager-bridge/src/prometheus-metrics-exporter.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class PrometheusMetricsExporter {
1717
protected readonly clusterCordoned: prom.Gauge<string>;
1818
protected readonly statusUpdatesTotal: prom.Counter<string>;
1919

20-
protected activeClusterNames: string[] = [];
20+
protected activeClusterNames = new Set<string>();
2121

2222
constructor() {
2323
this.workspaceStartupTimeHistogram = new prom.Histogram({
@@ -69,18 +69,18 @@ export class PrometheusMetricsExporter {
6969
}
7070

7171
updateClusterMetrics(clusters: WorkspaceClusterWoTLS[]): void {
72-
let newActiveClusterNames: string[] = [];
72+
let newActiveClusterNames = new Set<string>();
7373
clusters.forEach(cluster => {
7474
this.clusterCordoned.labels(cluster.name).set(cluster.state === 'cordoned' ? 1 : 0);
7575
this.clusterScore.labels(cluster.name).set(cluster.score);
76-
newActiveClusterNames.push(cluster.name);
76+
newActiveClusterNames.add(cluster.name);
7777
});
7878

79-
const noLongerActiveCluster = this.activeClusterNames.filter(c => !newActiveClusterNames.includes(c));
80-
if (noLongerActiveCluster.length > 0) {
81-
this.clusterScore.remove(...noLongerActiveCluster);
82-
this.clusterCordoned.remove(...noLongerActiveCluster);
83-
}
79+
const noLongerActiveCluster = Array.from(this.activeClusterNames).filter(c => !newActiveClusterNames.has(c));
80+
noLongerActiveCluster.forEach(clusterName => {
81+
this.clusterCordoned.remove(clusterName);
82+
this.clusterScore.remove(clusterName);
83+
});
8484
this.activeClusterNames = newActiveClusterNames;
8585
}
8686

0 commit comments

Comments
 (0)