Log cluster name together with application id
Change-Id: Ice2fd1ca5886fb9ff4eccf66df660714c3873aef
This commit is contained in:
parent
1a56a2b130
commit
74461a22c2
@ -124,7 +124,7 @@ public class NebulousAppDeployer {
|
|||||||
String clusterName = app.getClusterName();
|
String clusterName = app.getClusterName();
|
||||||
ExnConnector conn = app.getExnConnector();
|
ExnConnector conn = app.getExnConnector();
|
||||||
Map<String, NodeCandidate> edgeCandidates = app.getNodeEdgeCandidates();
|
Map<String, NodeCandidate> edgeCandidates = app.getNodeEdgeCandidates();
|
||||||
log.info("Starting initial deployment for application", keyValue("appId", appUUID));
|
log.info("Starting initial deployment for application", keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
|
|
||||||
int deployGeneration = app.getDeployGeneration() + 1;
|
int deployGeneration = app.getDeployGeneration() + 1;
|
||||||
app.setDeployGeneration(deployGeneration);
|
app.setDeployGeneration(deployGeneration);
|
||||||
@ -157,10 +157,11 @@ public class NebulousAppDeployer {
|
|||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// 2. Find node candidates
|
// 2. Find node candidates
|
||||||
|
|
||||||
|
// TODO: filter by app resources (check enabled: true in resources array)
|
||||||
List<NodeCandidate> controllerCandidates = conn.findNodeCandidates(controllerRequirements, appUUID);
|
List<NodeCandidate> controllerCandidates = conn.findNodeCandidates(controllerRequirements, appUUID);
|
||||||
if (controllerCandidates.isEmpty()) {
|
if (controllerCandidates.isEmpty()) {
|
||||||
log.error("Could not find node candidates for requirements: {}",
|
log.error("Could not find node candidates for requirements: {}",
|
||||||
controllerRequirements, keyValue("appId", appUUID));
|
controllerRequirements, keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
// Continue here while we don't really deploy
|
// Continue here while we don't really deploy
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
@ -168,10 +169,11 @@ public class NebulousAppDeployer {
|
|||||||
for (Map.Entry<String, List<Requirement>> e : workerRequirements.entrySet()) {
|
for (Map.Entry<String, List<Requirement>> e : workerRequirements.entrySet()) {
|
||||||
String nodeName = e.getKey();
|
String nodeName = e.getKey();
|
||||||
List<Requirement> requirements = e.getValue();
|
List<Requirement> requirements = e.getValue();
|
||||||
|
// TODO: filter by app resources (check enabled: true in resources array)
|
||||||
List<NodeCandidate> candidates = conn.findNodeCandidates(requirements, appUUID);
|
List<NodeCandidate> candidates = conn.findNodeCandidates(requirements, appUUID);
|
||||||
if (candidates.isEmpty()) {
|
if (candidates.isEmpty()) {
|
||||||
log.error("Could not find node candidates for requirements: {}", requirements,
|
log.error("Could not find node candidates for for node {}, requirements: {}", nodeName, requirements,
|
||||||
keyValue("appId", appUUID));
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
// Continue here while we don't really deploy
|
// Continue here while we don't really deploy
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
@ -182,7 +184,7 @@ public class NebulousAppDeployer {
|
|||||||
// 3. Select node candidates
|
// 3. Select node candidates
|
||||||
|
|
||||||
// Controller node
|
// Controller node
|
||||||
log.info("Deciding on controller node candidate", keyValue("appId", appUUID));
|
log.info("Deciding on controller node candidate", keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
String masterNodeName = clusterName + "-masternode"; // safe because all component node names end with a number
|
String masterNodeName = clusterName + "-masternode"; // safe because all component node names end with a number
|
||||||
NodeCandidate masterNodeCandidate = null;
|
NodeCandidate masterNodeCandidate = null;
|
||||||
if (controllerCandidates.size() > 0) {
|
if (controllerCandidates.size() > 0) {
|
||||||
@ -194,11 +196,12 @@ public class NebulousAppDeployer {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error("Empty node candidate list for controller, continuing without creating node",
|
log.error("Empty node candidate list for controller, continuing without creating node",
|
||||||
keyValue("appId", appUUID));
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component nodes
|
// Component nodes
|
||||||
log.info("Collecting worker nodes for {}", appUUID, keyValue("appId", appUUID));
|
log.info("Collecting worker nodes for {}", appUUID,
|
||||||
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
ArrayNode nodeLabels = mapper.createArrayNode();
|
ArrayNode nodeLabels = mapper.createArrayNode();
|
||||||
Map<String, NodeCandidate> clusterNodes = new HashMap<>();;
|
Map<String, NodeCandidate> clusterNodes = new HashMap<>();;
|
||||||
// Here we collect multiple things:
|
// Here we collect multiple things:
|
||||||
@ -214,7 +217,8 @@ public class NebulousAppDeployer {
|
|||||||
Set<String> nodeNames = new HashSet<>();
|
Set<String> nodeNames = new HashSet<>();
|
||||||
List<NodeCandidate> candidates = workerCandidates.get(componentName);
|
List<NodeCandidate> candidates = workerCandidates.get(componentName);
|
||||||
if (candidates.size() == 0) {
|
if (candidates.size() == 0) {
|
||||||
log.error("Empty node candidate list for component {}, continuing without creating node", componentName, keyValue("appId", appUUID));
|
log.error("Empty node candidate list for component {}, continuing without creating node", componentName,
|
||||||
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int nodeNumber = 1; nodeNumber <= numberOfNodes; nodeNumber++) {
|
for (int nodeNumber = 1; nodeNumber <= numberOfNodes; nodeNumber++) {
|
||||||
@ -225,7 +229,7 @@ public class NebulousAppDeployer {
|
|||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (candidate == null) {
|
if (candidate == null) {
|
||||||
log.error("No available node candidate for node {} of component {}", nodeNumber, componentName,
|
log.error("No available node candidate for node {} of component {}", nodeNumber, componentName,
|
||||||
keyValue("appId", appUUID));
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Set.of(NodeCandidateTypeEnum.BYON, NodeCandidateTypeEnum.EDGE).contains(candidate.getNodeCandidateType())) {
|
if (Set.of(NodeCandidateTypeEnum.BYON, NodeCandidateTypeEnum.EDGE).contains(candidate.getNodeCandidateType())) {
|
||||||
@ -238,8 +242,8 @@ public class NebulousAppDeployer {
|
|||||||
app.getComponentNodeNames().put(componentName, nodeNames);
|
app.getComponentNodeNames().put(componentName, nodeNames);
|
||||||
}
|
}
|
||||||
Main.logFile("nodenames-" + appUUID + ".txt", app.getComponentNodeNames());
|
Main.logFile("nodenames-" + appUUID + ".txt", app.getComponentNodeNames());
|
||||||
Main.logFile("master-node-" + appUUID + ".txt", masterNodeCandidate);
|
Main.logFile("master-nodecandidate-" + appUUID + ".txt", masterNodeCandidate);
|
||||||
Main.logFile("worker-nodes-" + appUUID + ".txt", clusterNodes);
|
Main.logFile("worker-nodecandidates-" + appUUID + ".txt", clusterNodes);
|
||||||
try {
|
try {
|
||||||
Main.logFile("worker-labels-" + appUUID + ".txt", mapper.writeValueAsString(nodeLabels));
|
Main.logFile("worker-labels-" + appUUID + ".txt", mapper.writeValueAsString(nodeLabels));
|
||||||
} catch (JsonProcessingException e1) {
|
} catch (JsonProcessingException e1) {
|
||||||
@ -280,7 +284,8 @@ public class NebulousAppDeployer {
|
|||||||
try {
|
try {
|
||||||
rewritten_kubevela = yamlMapper.writeValueAsString(rewritten);
|
rewritten_kubevela = yamlMapper.writeValueAsString(rewritten);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
log.error("Failed to convert KubeVela to YAML; this should never happen", keyValue("appId", appUUID), e);
|
log.error("Failed to convert KubeVela to YAML; this should never happen",
|
||||||
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName), e);
|
||||||
}
|
}
|
||||||
Main.logFile("rewritten-kubevela-" + appUUID + ".yaml", rewritten_kubevela);
|
Main.logFile("rewritten-kubevela-" + appUUID + ".yaml", rewritten_kubevela);
|
||||||
|
|
||||||
@ -316,7 +321,8 @@ public class NebulousAppDeployer {
|
|||||||
ExnConnector conn = app.getExnConnector();
|
ExnConnector conn = app.getExnConnector();
|
||||||
app.setDeployGeneration(deployGeneration);
|
app.setDeployGeneration(deployGeneration);
|
||||||
|
|
||||||
log.info("Starting redeployment generation {}", deployGeneration, keyValue("appId", appUUID));
|
log.info("Starting redeployment generation {}", deployGeneration,
|
||||||
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
// The overall flow:
|
// The overall flow:
|
||||||
//
|
//
|
||||||
// 1. Extract node requirements and node counts from the updated
|
// 1. Extract node requirements and node counts from the updated
|
||||||
@ -363,11 +369,12 @@ public class NebulousAppDeployer {
|
|||||||
int nAdd = newCount - oldCount;
|
int nAdd = newCount - oldCount;
|
||||||
allMachineNames = app.getComponentNodeNames().get(componentName);
|
allMachineNames = app.getComponentNodeNames().get(componentName);
|
||||||
log.debug("Adding {} nodes to component {}", nAdd, componentName,
|
log.debug("Adding {} nodes to component {}", nAdd, componentName,
|
||||||
keyValue("appId", appUUID));
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
|
// TODO: filter by app resources (check enabled: true in resources array)
|
||||||
List<NodeCandidate> candidates = conn.findNodeCandidates(newR, appUUID);
|
List<NodeCandidate> candidates = conn.findNodeCandidates(newR, appUUID);
|
||||||
if (candidates.isEmpty()) {
|
if (candidates.isEmpty()) {
|
||||||
log.error("Could not find node candidates for requirements: {}",
|
log.error("Could not find node candidates for requirements: {}",
|
||||||
newR, keyValue("appId", appUUID));
|
newR, keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int nodeNumber = 1; nodeNumber <= nAdd; nodeNumber++) {
|
for (int nodeNumber = 1; nodeNumber <= nAdd; nodeNumber++) {
|
||||||
@ -378,7 +385,7 @@ public class NebulousAppDeployer {
|
|||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (candidate == null) {
|
if (candidate == null) {
|
||||||
log.error("No available node candidate for node {} of component {}", nodeNumber, componentName,
|
log.error("No available node candidate for node {} of component {}", nodeNumber, componentName,
|
||||||
keyValue("appId", appUUID));
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Set.of(NodeCandidateTypeEnum.BYON, NodeCandidateTypeEnum.EDGE).contains(candidate.getNodeCandidateType())) {
|
if (Set.of(NodeCandidateTypeEnum.BYON, NodeCandidateTypeEnum.EDGE).contains(candidate.getNodeCandidateType())) {
|
||||||
@ -399,7 +406,7 @@ public class NebulousAppDeployer {
|
|||||||
// Something for version 2.
|
// Something for version 2.
|
||||||
int nRemove = oldCount - newCount;
|
int nRemove = oldCount - newCount;
|
||||||
log.debug("Removing {} nodes from component {}", nRemove, componentName,
|
log.debug("Removing {} nodes from component {}", nRemove, componentName,
|
||||||
keyValue("appId", appUUID));
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
// We could be a bit smarter here: remove cloud instances
|
// We could be a bit smarter here: remove cloud instances
|
||||||
// first and keep edge nodes in use, on the assumption
|
// first and keep edge nodes in use, on the assumption
|
||||||
// that it's better to keep using edge nodes since cloud
|
// that it's better to keep using edge nodes since cloud
|
||||||
@ -410,18 +417,20 @@ public class NebulousAppDeployer {
|
|||||||
allMachineNames.removeAll(removedInstances);
|
allMachineNames.removeAll(removedInstances);
|
||||||
nodesToRemove.addAll(removedInstances);
|
nodesToRemove.addAll(removedInstances);
|
||||||
} else {
|
} else {
|
||||||
log.debug("Nothing changed for component {}", componentName, keyValue("appId", appUUID));
|
log.debug("Nothing changed for component {}", componentName,
|
||||||
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
allMachineNames = app.getComponentNodeNames().get(componentName);
|
allMachineNames = app.getComponentNodeNames().get(componentName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nodesToRemove.addAll(app.getComponentNodeNames().get(componentName));
|
nodesToRemove.addAll(app.getComponentNodeNames().get(componentName));
|
||||||
allMachineNames = new HashSet<>();
|
allMachineNames = new HashSet<>();
|
||||||
log.debug("Redeploying all nodes of component {}", componentName,
|
log.debug("Redeploying all nodes of component {}", componentName,
|
||||||
keyValue("appId", appUUID));
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
|
// TODO: filter by app resources (check enabled: true in resources array)
|
||||||
List<NodeCandidate> candidates = conn.findNodeCandidates(newR, appUUID);
|
List<NodeCandidate> candidates = conn.findNodeCandidates(newR, appUUID);
|
||||||
if (candidates.size() == 0) {
|
if (candidates.size() == 0) {
|
||||||
log.error("Empty node candidate list for component {}, continuing without creating node", componentName,
|
log.error("Empty node candidate list for component {}, continuing without creating node", componentName,
|
||||||
keyValue("appId", appUUID));
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int nodeNumber = 1; nodeNumber <= componentReplicaCounts.get(componentName); nodeNumber++) {
|
for (int nodeNumber = 1; nodeNumber <= componentReplicaCounts.get(componentName); nodeNumber++) {
|
||||||
@ -432,7 +441,7 @@ public class NebulousAppDeployer {
|
|||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (candidate == null) {
|
if (candidate == null) {
|
||||||
log.error("No available node candidate for node {} of component {}", nodeNumber, componentName,
|
log.error("No available node candidate for node {} of component {}", nodeNumber, componentName,
|
||||||
keyValue("appId", appUUID));
|
keyValue("appId", appUUID), keyValue("clusterName", clusterName));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Set.of(NodeCandidateTypeEnum.BYON, NodeCandidateTypeEnum.EDGE).contains(candidate.getNodeCandidateType())) {
|
if (Set.of(NodeCandidateTypeEnum.BYON, NodeCandidateTypeEnum.EDGE).contains(candidate.getNodeCandidateType())) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user