Skip to content

Commit

Permalink
Fix getCluster message application property
Browse files Browse the repository at this point in the history
-Use the application id as application property, not the cluster name

Change-Id: I41aec030aaaaa93a473e7290d258ec0025a7d94e
  • Loading branch information
rudi committed Apr 29, 2024
1 parent 847cdad commit 1ae236f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,13 @@ public boolean defineCluster(String appID, String clusterName, ObjectNode cluste
/**
* Get the definition of a cluster created by {@link #defineCluster}.
*
* @param appID The application ID.
* @param clusterName The cluster name, as given in {@link defineCluster}.
* @return The cluster definition, or null in case of error.
*/
public JsonNode getCluster(String clusterName) {
public JsonNode getCluster(String appID, String clusterName) {
Map<String, Object> msg = Map.of("metaData", Map.of("user", "admin", "clusterName", clusterName));
Map<String, Object> response = getCluster.sendSync(msg, clusterName, null, false);
Map<String, Object> response = getCluster.sendSync(msg, appID, null, false);
JsonNode payload = extractPayloadFromExnResponse(response, "getCluster");
return payload.isMissingNode() ? null : payload;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ public static String createNodeName(String clusterName, String componentName, in
* </ul>
*
* @param conn The exn connector.
* @param appID The application id.
* @param clusterName The name of the cluster to poll.
*/
private static boolean waitForClusterDeploymentFinished(ExnConnector conn, String clusterName) {
private static boolean waitForClusterDeploymentFinished(ExnConnector conn, String appID, String clusterName) {
final int pollInterval = 10000; // Check status every 10s
int callsSincePrinting = 0; // number of intervals since we last logged what we're doing
int failedCalls = 0;
Expand All @@ -160,7 +161,7 @@ private static boolean waitForClusterDeploymentFinished(ExnConnector conn, Strin
} catch (InterruptedException e1) {
// ignore
}
JsonNode clusterState = conn.getCluster(clusterName);
JsonNode clusterState = conn.getCluster(appID, clusterName);
final String status;
if (clusterState != null) {
JsonNode jsonState = clusterState.at("/status");
Expand Down Expand Up @@ -427,7 +428,7 @@ public static void deployApplication(NebulousApp app, JsonNode kubevela) {
return;
}

if (!waitForClusterDeploymentFinished(conn, clusterName)) {
if (!waitForClusterDeploymentFinished(conn, appUUID, clusterName)) {
log.error("Error while waiting for deployCluster to finish, trying to delete cluster {} and aborting deployment",
cluster);
app.setStateFailed();
Expand Down Expand Up @@ -638,7 +639,7 @@ public static void redeployApplication(NebulousApp app, ObjectNode updatedKubeve
log.info("Starting scaleout: {}", nodesToAdd);
Main.logFile("redeploy-scaleout-" + appUUID + ".json", nodesToAdd.toPrettyString());
conn.scaleOut(appUUID, clusterName, nodesToAdd);
waitForClusterDeploymentFinished(conn, clusterName);
waitForClusterDeploymentFinished(conn, appUUID, clusterName);
} else {
log.info("No nodes added, skipping scaleout");
}
Expand Down

0 comments on commit 1ae236f

Please sign in to comment.