Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#6758] Platform: Reuse on-premise instance once the instance got delete. #6970

Merged
merged 12 commits into from
Feb 16, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import com.yugabyte.yw.common.services.YBClientService;
import com.yugabyte.yw.forms.UniverseTaskParams.EncryptionAtRestConfig.OpType;
import com.yugabyte.yw.forms.UniverseDefinitionTaskParams.Cluster;
import com.yugabyte.yw.models.Universe.UniverseUpdater;
import com.yugabyte.yw.models.helpers.NodeDetails;
import com.yugabyte.yw.models.helpers.TableDetails;
Expand Down Expand Up @@ -314,8 +315,19 @@ public SubTaskGroup createDestroyServerTasks(Collection<NodeDetails> nodes,
// Check if the private ip for the node is set. If not, that means we don't have
// a clean state to delete the node. Log it and skip the node.
mahendranbhat marked this conversation as resolved.
Show resolved Hide resolved
if (node.cloudInfo.private_ip == null) {
LOG.warn(String.format("Node %s doesn't have a private IP. Skipping node delete.",
node.nodeName));
LOG.warn(String.format("Node %s doesn't have a private IP. Skipping node delete.", node.nodeName));
mahendranbhat marked this conversation as resolved.
Show resolved Hide resolved
// Free up the node so that the client can use the instance to create another universe.
mahendranbhat marked this conversation as resolved.
Show resolved Hide resolved
Universe universe = Universe.get(taskParams().universeUUID);
mahendranbhat marked this conversation as resolved.
Show resolved Hide resolved
UniverseDefinitionTaskParams universeDetails = universe.getUniverseDetails();
Cluster cluster = universeDetails.getClusterByUuid(node.placementUuid);
if (cluster.userIntent.providerType.equals(com.yugabyte.yw.commissioner.Common.CloudType.onprem)) {
try {
NodeInstance providerNode = NodeInstance.getByName(node.nodeName);
providerNode.clearNodeDetails();
} catch (Exception ex) {
LOG.warn("On-prem node {} in universe {} doesn't have a linked instance. ", node.nodeName, universe.name);
}
}
continue;
}
AnsibleDestroyServer.Params params = new AnsibleDestroyServer.Params();
Expand Down