Skip to content

Commit

Permalink
Merge pull request #967 from hpcc-systems/yadhap/cluster-connection-i…
Browse files Browse the repository at this point in the history
…ssues

Used new cluster route to fetch cluster information when application …
  • Loading branch information
FancMa01 authored Dec 9, 2024
2 parents 7d134a5 + 6113100 commit 7d306b9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Tombolo/client-reactjs/src/redux/actions/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function updateApplicationAddButtonTourShown(shown) {

function getClusters() {
return (dispatch) => {
fetch('/api/hpcc/read/getClusters', { headers: authHeader() })
fetch('/api/cluster', { headers: authHeader() })
.then((response) => (response.ok ? response.json() : handleError(response)))
.then((clusters) => {
//if there are no clusters, set this to null for later checks
Expand Down
26 changes: 24 additions & 2 deletions Tombolo/server/controllers/clusterController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { clusters } = require("../cluster-whitelist.js");
const { Sequelize } = require("sequelize");
const {
AccountService,
TopologyService,
Expand Down Expand Up @@ -304,10 +305,31 @@ const getClusters = async (req, res) => {
try {
// Get clusters ASC by name
const clusters = await Cluster.findAll({
attributes: { exclude: ["hash"] },
attributes: {
exclude: ["hash", "metaData"],
include: [
[
Sequelize.literal(`
CASE
WHEN metaData IS NOT NULL AND JSON_EXTRACT(metaData, '$.reachabilityInfo') IS NOT NULL
THEN JSON_EXTRACT(metaData, '$.reachabilityInfo')
ELSE '{}'
END
`),
"reachabilityInfo",
],
],
},
order: [["name", "ASC"]],
});
res.status(200).json({ success: true, data: clusters });
// Parse the JSON string into a JavaScript object
const parsedClusters = clusters.map((cluster) => {
const clusterData = cluster.get({ plain: true });
clusterData.reachabilityInfo = JSON.parse(clusterData.reachabilityInfo);
return clusterData;
});

res.status(200).json({ success: true, data: parsedClusters });
} catch (err) {
logger.error(`Get clusters: ${err.message}`);
res
Expand Down

0 comments on commit 7d306b9

Please sign in to comment.