Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Fixes for edge cluster logic (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Godbehere <114239316+AlexGodbehere@users.noreply.github.com>
  • Loading branch information
amrc-benmorrow and AlexGodbehere authored Jan 15, 2024
1 parent a90eebf commit 81faee8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
11 changes: 9 additions & 2 deletions app/Domain/Nodes/Actions/CreateNodeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,22 @@ public function execute(
]);

$configDB->putConfig(App::Info, $uuid, [
"name" => $nodeName . '/' . $destinationCluster . '/' . $destinationNode,
"name" => sprintf("%s/%s (%s)",
$group->name, $nodeName, $destinationNode),
]);

// Register the Sparkplug address the EA should use
$configDB->putConfig(App::SparkplugAddress, $uuid, [
"group_id" => $group->name,
"node_id" => $nodeName,
]);

// Split the $charts string (comma-delimited) into an array of UUIDs
$charts = explode(',', $charts);

// Create an entry in the Edge Agent Deployment app to trigger the deployment of the edge agent
$configDB->putConfig(App::EdgeAgentDeployment, $uuid, [
"name" => $nodeName,
"name" => sprintf("%s.%s", $group->name, $nodeName),
"charts" => $charts,
"cluster" => $destinationCluster,
"hostname" => $destinationNode,
Expand Down
6 changes: 6 additions & 0 deletions app/Domain/Nodes/Actions/DeleteNodeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public function execute(Node $node)
$configDB = $fplus->getConfigDB();

$configDB->deleteConfig(App::EdgeAgentDeployment, $node->uuid);
$configDB->deleteConfig(App::SparkplugAddress, $node->uuid);

/* XXX This should be a library method to mark an object deleted */
$info = $configDB->getConfig(App::Info, $node->uuid);
$info["deleted"] = true;
$configDB->putConfig(App::Info, $node->uuid, $info);

$node->delete();

Expand Down
5 changes: 3 additions & 2 deletions resources/js/components/Containers/EdgeClusterContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="flex items-center justify-center gap-0">
</div>
</div>
<div v-if="item.status" class="flex items-center text-gray-400 text-xs">{{item.status?.nodes.length}} Nodes
<div v-if="item.status" class="flex items-center text-gray-400 text-xs">{{item.status?.hosts?.length}} Nodes
</div>
<div v-else class="flex items-center text-gray-400 animate-pulse text-xs tracking-wider font-normal gap-1">
<div class="flex items-center justify-center">
Expand Down Expand Up @@ -71,7 +71,7 @@ export default {
},

copyBootstrapCommand (item) {
axios.get(`/api/edge-clusters/${item.name}/bootstrap-command`).then((response) => {
axios.get(`/api/edge-clusters/${item.uuid}/bootstrap-command`).then((response) => {
if (response.data.data) {
this.copyToClipboard(response.data.data)
window.showNotification({
Expand All @@ -93,6 +93,7 @@ export default {
try {
await navigator.clipboard.writeText(text)
} catch (err) {
console.warn(`Failed to copy to clipboard: ${text}`);
window.showNotification({
title: 'Failed to copy to clipboard.',
description: err,
Expand Down
16 changes: 9 additions & 7 deletions resources/js/components/Nodes/NewNodeOverlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,20 @@ export default {
immediate: true,
handler: function (val) {
if (val) {
this.steps.nodeSelection.controls.destination_node.options = Object.keys(val).map((edgeCluster) => {
const control = this.steps.nodeSelection.controls.destination_node;
const params = this.steps.__request.parameters;
control.options = Object.entries(val).map(([edgeCluster, config]) => {
return {
title: edgeCluster,
value: edgeCluster,
options: val[edgeCluster].nodes && Object.keys(val[edgeCluster].nodes)?.map(e => {
options: config.status.hosts.map(host => {
return {
title: val[edgeCluster].nodes[e].hostname,
value: val[edgeCluster].nodes[e].hostname,
title: `${host.hostname} (${host.arch})`,
value: host.hostname,
action: () => {
this.steps.__request.parameters.destination_cluster.data = val[edgeCluster].uuid
this.steps.__request.parameters.destination_node.data = val[edgeCluster].nodes[e].hostname
this.steps.nodeSelection.controls.destination_node.value = val[edgeCluster].nodes[e].hostname
params.destination_cluster.data = config.uuid;
params.destination_node.data = host.hostname;
control.value = host.hostname;
},
}
})
Expand Down

0 comments on commit 81faee8

Please sign in to comment.